[PR #1043] [MERGED] Keep world saves and exit responsive while preserving durability #3010

Closed
opened 2026-11-02 16:00:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1043
Author: @rdbtCVS
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @ludovic111

Base: main ← Head: t3/async-world-save-exit


📝 Commits (2)

  • d5d3f5b Prepare world save snapshots incrementally and poll durable completion
  • ab9e0cd Use if let for the integrated server stop request

📊 Changes

10 files changed (+565 additions, -49 deletions)

View changed files

📝 crates/horizon-client/examples/save_bench.rs (+1 -1)
📝 crates/horizon-client/src/game.rs (+78 -16)
📝 crates/horizon-client/src/game/control.rs (+10 -2)
📝 crates/horizon-client/src/game/integrated.rs (+72 -8)
📝 crates/horizon-client/src/game/persist.rs (+9 -6)
📝 crates/horizon-client/src/game/remote.rs (+4 -1)
➕ crates/horizon-client/src/game/saving.rs (+249 -0)
📝 crates/horizon-client/src/save.rs (+112 -13)
📝 crates/horizon-client/src/streaming.rs (+24 -0)
📝 crates/horizon-client/tests/generation_saves.rs (+6 -2)

📄 Description

World saves prepared all live snapshots and waited for generation and disk flushes in the window's event handlers. Saving or leaving a dirty world could therefore hold up the window for hundreds of milliseconds.

Prepare local chunk and entity snapshots across event-loop turns, with a 16-snapshot cap and a 2 ms budget checked after each snapshot. Poll generation and region-writer completion while drawing a save screen. Local save / save-all commands acknowledge only after durable completion, and returning to the title keeps the session lock until writes finish. Integrated-server exit requests shutdown first and joins after its thread completes.

Preserve a synchronous fallback for native application termination, overlap entity preparation with chunk writes in synchronous saves, and propagate region-writer/server failures instead of reporting a successful save. Failed region snapshots remain readable in memory.

Validation:

  • cargo fmt --all -- --check
  • cargo check -p horizon-client --no-default-features --tests --examples
  • Save unit tests: 18 passed, including blocked-writer polling, newest-write ordering, deletion and persistent I/O failure coverage.
  • Streaming unit tests: 7 passed, 1 ignored.
  • Client binary unit tests: 79 passed, 2 ignored, including nonblocking shutdown requests and server-save failure propagation.

The generation/reopen integration fixture now uses the incremental generation-save path. Its prepared world resources are unavailable in this checkout, so the original 411 ms / 326 ms / 84 ms timings and resource-backed parity fixture have not been rerun. Small world metadata files still use the existing synchronous write path; normal region completion is polled, and forced native termination still waits to retain durability.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1043 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `t3/async-world-save-exit` --- ### 📝 Commits (2) - [`d5d3f5b`](https://github.com/horizon-rust/horizon/commit/d5d3f5b3c7b7c472aaddd93c846e11bd4a76f0cc) Prepare world save snapshots incrementally and poll durable completion - [`ab9e0cd`](https://github.com/horizon-rust/horizon/commit/ab9e0cdea4859f79f3599477185aef37e3e8f4ba) Use if let for the integrated server stop request ### 📊 Changes **10 files changed** (+565 additions, -49 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/save_bench.rs` (+1 -1) 📝 `crates/horizon-client/src/game.rs` (+78 -16) 📝 `crates/horizon-client/src/game/control.rs` (+10 -2) 📝 `crates/horizon-client/src/game/integrated.rs` (+72 -8) 📝 `crates/horizon-client/src/game/persist.rs` (+9 -6) 📝 `crates/horizon-client/src/game/remote.rs` (+4 -1) ➕ `crates/horizon-client/src/game/saving.rs` (+249 -0) 📝 `crates/horizon-client/src/save.rs` (+112 -13) 📝 `crates/horizon-client/src/streaming.rs` (+24 -0) 📝 `crates/horizon-client/tests/generation_saves.rs` (+6 -2) </details> ### 📄 Description World saves prepared all live snapshots and waited for generation and disk flushes in the window's event handlers. Saving or leaving a dirty world could therefore hold up the window for hundreds of milliseconds. Prepare local chunk and entity snapshots across event-loop turns, with a 16-snapshot cap and a 2 ms budget checked after each snapshot. Poll generation and region-writer completion while drawing a save screen. Local `save` / `save-all` commands acknowledge only after durable completion, and returning to the title keeps the session lock until writes finish. Integrated-server exit requests shutdown first and joins after its thread completes. Preserve a synchronous fallback for native application termination, overlap entity preparation with chunk writes in synchronous saves, and propagate region-writer/server failures instead of reporting a successful save. Failed region snapshots remain readable in memory. Validation: - `cargo fmt --all -- --check` - `cargo check -p horizon-client --no-default-features --tests --examples` - Save unit tests: 18 passed, including blocked-writer polling, newest-write ordering, deletion and persistent I/O failure coverage. - Streaming unit tests: 7 passed, 1 ignored. - Client binary unit tests: 79 passed, 2 ignored, including nonblocking shutdown requests and server-save failure propagation. The generation/reopen integration fixture now uses the incremental generation-save path. Its prepared world resources are unavailable in this checkout, so the original 411 ms / 326 ms / 84 ms timings and resource-backed parity fixture have not been rerun. Small world metadata files still use the existing synchronous write path; normal region completion is polled, and forced native termination still waits to retain durability. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 16:00:47 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3010
No description provided.