[PR #6729] [MERGED] World open: read the server's sync data beside the worldgen preload (−87 ms to the first frame) #7058

Closed
opened 2026-11-03 06:33:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6729
Author: @Vaspyyy
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: perf/sync-preload-parallel


📝 Commits (1)

  • 189e128 World open: read the server's sync data beside the worldgen preload

📊 Changes

1 file changed (+37 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/world_loading.rs (+37 -3)

📄 Description

Requested by Ransom

🤖 Opened by Vaspyyy's AI agent (Claude Code), not by Vaspyyy personally.

What and why

Fixes #6726.

On a launch into a world, the world data preload read the server's sync data (lan::sync_data: registries, tags, recipes, advancements, ~180 ms) after the worldgen bundle and the loot tables. By the time serve() asked for it (preload_sync_data), the preload hadn't started that read yet. So the server started a second read, and SyncPreload::adopt then blocked on SYNC's lock while the preload read everything again: ~100 ms on the server thread before settle_spawn.

Both preloads (preload_launch_world and preload_world_data from the world screens) now read the sync data on a thread of their own from the start, in parallel with the worldgen and loot reads. The read takes SYNC early, preload_sync_data finds it busy or filled and starts nothing, and the server never waits on a second read. The preload's thread joins the new thread, so PRELOAD_KEPT's "finished" check still covers everything it read.

Timings

python3 tools/startup_trace.py --world T --seed 1234 --runs 2 --warm, three rounds alternating base (upstream/main 435730a40) and this branch, 6 runs each. Ryzen 7 5800X, RTX 3070, NVMe, Linux. Medians:

before after
server.settle_spawn starts 1094 ms 1004 ms (−90)
world.first_frame 1225 ms 1139 ms (−87)
world.view_full 1906 ms 1872 ms (−34; the rest is paced by the server's 64-chunk batches)

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

none (startup ordering only; the data read is unchanged)

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on PunyDev, against upstream/main at 435730a40, 5 min 14 s)

Check Result
Scope ✅ 1 files, +37 −3
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 602 passed (50 s)
rustfmt ✅ (10 s)
clippy ✅ (2 min 13 s)
tests: horizon-client ✅ 598 passed (1 min 52 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
mod API up to date ❌ failed (8 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)

"mod API up to date" also fails on upstream/main 435730a40 without this change: cargo run -p xtask -- mod-api only rewrites one doc line of native_block_placement_state in mod_api/generated.rs, which this PR doesn't touch, so I left it out.

🤖 Generated with Claude Code


🔄 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/6729 **Author:** [@Vaspyyy](https://github.com/Vaspyyy) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/sync-preload-parallel` --- ### 📝 Commits (1) - [`189e128`](https://github.com/horizon-rust/horizon/commit/189e128d0060dfd8cd06905fbaac674d947f40fd) World open: read the server's sync data beside the worldgen preload ### 📊 Changes **1 file changed** (+37 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/world_loading.rs` (+37 -3) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"Vaspyyy"} --> _Requested by **Ransom**_ > 🤖 Opened by Vaspyyy's AI agent (Claude Code), not by Vaspyyy personally. ## What and why Fixes #6726. On a launch into a world, the world data preload read the server's sync data (`lan::sync_data`: registries, tags, recipes, advancements, ~180 ms) **after** the worldgen bundle and the loot tables. By the time `serve()` asked for it (`preload_sync_data`), the preload hadn't started that read yet. So the server started a second read, and `SyncPreload::adopt` then blocked on `SYNC`'s lock while the preload read everything again: ~100 ms on the server thread before `settle_spawn`. Both preloads (`preload_launch_world` and `preload_world_data` from the world screens) now read the sync data on a thread of their own from the start, in parallel with the worldgen and loot reads. The read takes `SYNC` early, `preload_sync_data` finds it busy or filled and starts nothing, and the server never waits on a second read. The preload's thread joins the new thread, so `PRELOAD_KEPT`'s "finished" check still covers everything it read. ### Timings `python3 tools/startup_trace.py --world T --seed 1234 --runs 2 --warm`, three rounds alternating base (upstream/main 435730a40) and this branch, 6 runs each. Ryzen 7 5800X, RTX 3070, NVMe, Linux. Medians: | | before | after | |---|---|---| | `server.settle_spawn` starts | 1094 ms | 1004 ms (**−90**) | | `world.first_frame` | 1225 ms | 1139 ms (**−87**) | | `world.view_full` | 1906 ms | 1872 ms (−34; the rest is paced by the server's 64-chunk batches) | ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [x] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference none (startup ordering only; the data read is unchanged) ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on PunyDev, against upstream/main at 435730a40, 5 min 14 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +37 −3 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 602 passed (50 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (2 min 13 s) | | tests: horizon-client | ✅ 598 passed (1 min 52 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | mod API up to date | ❌ failed (8 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) | "mod API up to date" also fails on upstream/main 435730a40 without this change: `cargo run -p xtask -- mod-api` only rewrites one doc line of `native_block_placement_state` in `mod_api/generated.rs`, which this PR doesn't touch, so I left it out. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:33:01 +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#7058
No description provided.