[PR #6065] [MERGED] Load loot and live features beside the world as it opens (−150 ms start) #6637

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

📋 Pull Request Information

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

Base: main ← Head: perf/world-prepare-overlap


📝 Commits (1)

  • 6530425 Load loot and live features beside the world as it opens

📊 Changes

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

View changed files

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

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

WorldRequest::prepare (every world opens there: on the server thread, on a dedicated server) ran three independent steps one after the other:

step (dedicated server, 4 CPUs, main) time cores busy
loot data (structure_blocks::loot_data) 38-41 ms 1
world: level data, worldgen data (322-334 ms), generator (256-261 ms, of which decoration 201-206 ms on one core), streaming ~590 ms 1-1.9
live features (bone meal's and saplings', install_live_features) 46-47 ms 1

Neither the loot nor the live features need the world. They now run on two scoped threads beside it and are joined before prepare returns, so the loot data is still loaded before any chunk is read and the live features are installed before the world opens, as before. The worldgen bundle the live features read is the generator's own (vanillagen::shared_data holds its lock while it loads), so it still loads once. With a single worker thread (res.threads() <= 1) the three run in order, as they did. A panic on a helper thread is resumed on the caller's.

Measured

playhorizon, --cpus 0-3 --exclusive, dedicated server, new world, fresh data folders per start, MIMALLOC_ALLOW_THP=0, alternated with main 5bbecdc49, idle 32 s after Done.

main this PR
Done, series 1 (5 starts each) 1.889 / 1.927 / 2.008 / 1.947 / 1.856 s, median 1.927 1.862 / 1.766 / 1.807 / 1.752 / 1.783 s, median 1.783 (−144 ms)
Done, series 2 (6 starts each) 1.880 / 1.927 / 1.845 / 1.869 / 1.906 / 1.963 s, median 1.893 1.723 / 1.750 / 1.792 / 1.729 / 1.743 / 1.693 s, median 1.736 (−157 ms)
faster than main's start just before it (same round) 11 of 11
idle anonymous memory (median of each series) 180.4 / 181.8 MiB 182.9 / 183.0 MiB (+1.2 to +2.5)
20 bots, MSPT (5 alternated rounds) 33.85¹ / 25.22 / 27.32 / 29.25 / 26.75 25.44 / 24.94 / 28.42 / 28.76 / 27.85 (same)

¹ that round ran beside a pr_ready on the host's other CPUs.

The idle memory is 1-2.5 MiB higher: what the helper threads allocate (the loot data, the live features) stays in allocator pages of threads that have exited. A variant that started the live features only once the generator had loaded the worldgen bundle (so the bundle never loads on a helper thread) kept the same +1.2 MiB and saved only 51 ms (bench/sp2-ovl-b), so this is the simpler one.

Tests

No behaviour changes: the world, the loot data and the live features are the same, loaded in another order. cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check clean (Mac).

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at b01a37b40, 21 min 10 s)

Check Result
Scope ✅ 1 files, +37 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 515 run, FAILED (failures=2, skipped=1) (56 s)
rustfmt ❌ failed
clippy ❌ failed
tests: horizon-client ✅ 1691 passed (19 min 57 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 43 affected, to run in CI (--quick): blending, block_removal, block_tint, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn and 31 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Notes: playhorizon's toolchain has no rustfmt/clippy, so both ran on the Mac (clean). The two Python failures are that host's virtual-screen tests (OK on the Mac). Players see a faster world open but nothing new: skip-release.

🤖 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/6065 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/world-prepare-overlap` --- ### 📝 Commits (1) - [`6530425`](https://github.com/horizon-rust/horizon/commit/6530425ace076d452301271e61e76e0bf814abac) Load loot and live features beside the world as it opens ### 📊 Changes **1 file changed** (+37 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/world_loading.rs` (+37 -6) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `WorldRequest::prepare` (every world opens there: on the server thread, on a dedicated server) ran three independent steps one after the other: | step (dedicated server, 4 CPUs, main) | time | cores busy | |---|---|---| | loot data (`structure_blocks::loot_data`) | 38-41 ms | 1 | | world: level data, worldgen data (322-334 ms), generator (256-261 ms, of which decoration 201-206 ms on one core), streaming | ~590 ms | 1-1.9 | | live features (bone meal's and saplings', `install_live_features`) | 46-47 ms | 1 | Neither the loot nor the live features need the world. They now run on two scoped threads beside it and are joined before `prepare` returns, so the loot data is still loaded before any chunk is read and the live features are installed before the world opens, as before. The worldgen bundle the live features read is the generator's own (`vanillagen::shared_data` holds its lock while it loads), so it still loads once. With a single worker thread (`res.threads() <= 1`) the three run in order, as they did. A panic on a helper thread is resumed on the caller's. ## Measured playhorizon, `--cpus 0-3 --exclusive`, dedicated server, new world, fresh data folders per start, `MIMALLOC_ALLOW_THP=0`, alternated with main 5bbecdc49, idle 32 s after Done. | | main | this PR | |---|---|---| | Done, series 1 (5 starts each) | 1.889 / 1.927 / 2.008 / 1.947 / 1.856 s, median 1.927 | 1.862 / 1.766 / 1.807 / 1.752 / 1.783 s, **median 1.783 (−144 ms)** | | Done, series 2 (6 starts each) | 1.880 / 1.927 / 1.845 / 1.869 / 1.906 / 1.963 s, median 1.893 | 1.723 / 1.750 / 1.792 / 1.729 / 1.743 / 1.693 s, **median 1.736 (−157 ms)** | | faster than main's start just before it (same round) | | 11 of 11 | | idle anonymous memory (median of each series) | 180.4 / 181.8 MiB | 182.9 / 183.0 MiB (+1.2 to +2.5) | | 20 bots, MSPT (5 alternated rounds) | 33.85¹ / 25.22 / 27.32 / 29.25 / 26.75 | 25.44 / 24.94 / 28.42 / 28.76 / 27.85 (same) | ¹ that round ran beside a pr_ready on the host's other CPUs. The idle memory is 1-2.5 MiB higher: what the helper threads allocate (the loot data, the live features) stays in allocator pages of threads that have exited. A variant that started the live features only once the generator had loaded the worldgen bundle (so the bundle never loads on a helper thread) kept the same +1.2 MiB and saved only 51 ms (`bench/sp2-ovl-b`), so this is the simpler one. ## Tests No behaviour changes: the world, the loot data and the live features are the same, loaded in another order. `cargo clippy --workspace --all-targets -- -D warnings` and `cargo fmt --check` clean (Mac). **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at b01a37b40, 21 min 10 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +37 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 515 run, FAILED (failures=2, skipped=1) (56 s) | | rustfmt | ❌ failed | | clippy | ❌ failed | | tests: horizon-client | ✅ 1691 passed (19 min 57 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 43 affected, to run in CI (--quick): blending, block_removal, block_tint, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn and 31 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Notes: playhorizon's toolchain has no rustfmt/clippy, so both ran on the Mac (clean). The two Python failures are that host's virtual-screen tests (OK on the Mac). Players see a faster world open but nothing new: `skip-release`. 🤖 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:24:10 +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#6637
No description provided.