[PR #7704] Move player autosave file writes off the tick thread #7772

Open
opened 2026-11-03 07:24:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7704
Author: @rdbtCVS
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: t3/autosave-player-files-off-tick-thread


📝 Commits (1)

  • 947d14b Move dedicated player autosave writes off the tick thread

📊 Changes

4 files changed (+217 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+18 -6)
📝 crates/horizon-client/src/game/lan.rs (+5 -0)
📝 crates/horizon-client/src/game/saving.rs (+4 -1)
📝 crates/horizon-client/src/lan/playerdata.rs (+190 -0)

📄 Description

🤖 Opened by rdbtCVS's AI agent (Codex, gpt-6.1-sol), not by rdbtCVS personally.

What and why

Dedicated-server autosaves synchronously wrote every placed player's .dat file in one tick. Snapshot player NBT on the server thread and queue compression and file replacement on a single FIFO worker, removing the 150-player burst of filesystem writes from autosave ticks.

Keep native player-save callbacks on the server thread, delivered after successful writes. Explicit saves and shutdown wait for completion; logout waits for queued autosaves before writing the newer player state. Writer errors remain visible to durability checks, and dropping the writer drains its queue before the world lock is released. Logout can still wait for an outstanding autosave batch.

Fixes #7692.

Kind

  • perf: faster, or less memory

Vanilla reference

Existing PlayerDataStorage.save NBT and write_dat replacement/backup behavior are retained; this changes Horizon's I/O scheduling. No gameplay or file-format changes. The vanilla bytecode query could not run because this checkout has no Minecraft 26.3 jars; parity checks require CI's prepared data.

Other projects' code

None.

Self-check

  • cargo test -p horizon-client-lib --lib lan::playerdata::tests::: 15 passed, including the new 150-player snapshot/order/logout test and error/drop-drain test.
    pr_ready (tools/pr_ready.py on archlinux, against origin/main at b451b111e, 6 min 47 s)
Check Result
Scope ✅ 4 files, +220 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (1 min 20 s)
rustfmt ✅ (10 s)
clippy ✅ (2 min 12 s)
tests: horizon-client, horizon-client-lib ✅ 2182 passed (2 min 17 s)
doc tests ✅ 0 passed (5 s)
content root tests ➖ content root untouched
mod API up to date ✅ (42 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • Port-ledger check unavailable: no local ledger has been built.

🤖 Generated with Codex.


🔄 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/7704 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `t3/autosave-player-files-off-tick-thread` --- ### 📝 Commits (1) - [`947d14b`](https://github.com/horizon-rust/horizon/commit/947d14bf740c1c7cc58860c860cc1a980e63f83a) Move dedicated player autosave writes off the tick thread ### 📊 Changes **4 files changed** (+217 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+18 -6) 📝 `crates/horizon-client/src/game/lan.rs` (+5 -0) 📝 `crates/horizon-client/src/game/saving.rs` (+4 -1) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+190 -0) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Codex, gpt-6.1-sol), not by rdbtCVS personally. ## What and why Dedicated-server autosaves synchronously wrote every placed player's `.dat` file in one tick. Snapshot player NBT on the server thread and queue compression and file replacement on a single FIFO worker, removing the 150-player burst of filesystem writes from autosave ticks. Keep native player-save callbacks on the server thread, delivered after successful writes. Explicit saves and shutdown wait for completion; logout waits for queued autosaves before writing the newer player state. Writer errors remain visible to durability checks, and dropping the writer drains its queue before the world lock is released. Logout can still wait for an outstanding autosave batch. Fixes #7692. ## Kind - [x] perf: faster, or less memory ## Vanilla reference Existing `PlayerDataStorage.save` NBT and `write_dat` replacement/backup behavior are retained; this changes Horizon's I/O scheduling. No gameplay or file-format changes. The vanilla bytecode query could not run because this checkout has no Minecraft 26.3 jars; parity checks require CI's prepared data. ## Other projects' code None. ## Self-check - `cargo test -p horizon-client-lib --lib lan::playerdata::tests::`: 15 passed, including the new 150-player snapshot/order/logout test and error/drop-drain test. **pr_ready** (`tools/pr_ready.py` on archlinux, against origin/main at b451b111e, 6 min 47 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +220 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (1 min 20 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (2 min 12 s) | | tests: horizon-client, horizon-client-lib | ✅ 2182 passed (2 min 17 s) | | doc tests | ✅ 0 passed (5 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (42 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - Port-ledger check unavailable: no local ledger has been built. 🤖 Generated with [Codex](https://openai.com/codex/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7772
No description provided.