[PR #5018] [MERGED] Load the world-rest tables in parallel #6011

Closed
opened 2026-11-03 05:16:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5018
Author: @rdbtCVS
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: perf/parallel-world-rest


📝 Commits (1)

  • eae1e21 Load the world-rest tables in parallel

📊 Changes

1 file changed (+87 additions, -43 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+87 -43)

📄 Description

🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally.

load_world_rest (the world-rest-loader thread, and the synchronous --world path) loaded its tables one after another. Only recipes and stations need Items; everything else reads only the core tables that already exist. They now load inside a std::thread::scope, using the same if threads > 1 pattern as the facts/biomes/environment loads above it:

Task Contents
A Items::load → (Recipes::load, StationData::load)
B Behaviours::load_with_gameplay
C BlockEntityRenderer::load_with_visibility
D AnimateTables, FogTables
E MobTypes, MobData, trial_spawner::load_registry
calling thread Transformers, the player type and arm models, spin_attack
  • None of these loaders has global state that depends on order: trial_spawner::REGISTRY and XMAS are OnceLocks, and PLAYER_TYPES is keyed by path. No RNG is used, so the tables come out the same.
  • With a 1-thread worker budget, everything still runs in order.
  • One difference: an error in one table no longer stops the others from loading. The first error found is the one returned.

Before / after

How it was measured. --profile fast builds of this branch and of its base 37ad1f5c9 (main), run on the same machine (12 cores, RTX 4060, Linux, warm file cache). Runs are interleaved A/B with the order flipped every iteration, after 1 warm-up run. Every run gets fresh scratch homes. The numbers are medians. "Socket" is the time from spawn until the control socket answers (startup done). "World ready" is the time until horizon-ctl wait-ready returns (--offscreen --world W --creative --seed 1). "Reopen" opens a copy of a world made earlier; "new world" creates one. The async rows are the log timings of a plain launch with no control socket (the loading screen path). Other jobs were running on the machine (load 4–8), which is why the runs were interleaved.

Measure main this PR Difference
World-rest ready (async, 12 runs) 1705 ms 1398 ms −307 ms (−18.0%)
Socket, reopen (12 runs) 1595 ms 1301 ms −294 ms (−18.4%)
World ready, reopen 2866 ms 2505 ms −361 ms (−12.6%)
Socket, new world (10 runs) 1575 ms 1259 ms −316 ms (−20.1%)
World ready, new world 4232 ms 3342 ms −890 ms (−21.0%)
Title screen ready (async) 1232 ms 1272 ms +40 ms (+3.3%, noise: this PR doesn't touch that path)

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 37ad1f5c9, 14 min 24 s)

Check Result
Scope ✅ 1 file, +87 −43
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed
rustfmt ✅
clippy ✅
tests: horizon-client ✅ 1318 passed
doc tests ✅ 0 passed
content root tests ➖ content root untouched
launcher ➖ launcher untouched
Parity ➖ affected harnesses run in CI (--quick)

Closes #5000

🤖 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/5018 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `perf/parallel-world-rest` --- ### 📝 Commits (1) - [`eae1e21`](https://github.com/horizon-rust/horizon/commit/eae1e21bd0f76100507cce59b6c5a137d34e01d0) Load the world-rest tables in parallel ### 📊 Changes **1 file changed** (+87 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+87 -43) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally. `load_world_rest` (the world-rest-loader thread, and the synchronous `--world` path) loaded its tables one after another. Only recipes and stations need `Items`; everything else reads only the core tables that already exist. They now load inside a `std::thread::scope`, using the same `if threads > 1` pattern as the facts/biomes/environment loads above it: | Task | Contents | |---|---| | A | `Items::load` → (`Recipes::load`, `StationData::load`) | | B | `Behaviours::load_with_gameplay` | | C | `BlockEntityRenderer::load_with_visibility` | | D | `AnimateTables`, `FogTables` | | E | `MobTypes`, `MobData`, `trial_spawner::load_registry` | | calling thread | `Transformers`, the player type and arm models, `spin_attack` | - None of these loaders has global state that depends on order: `trial_spawner::REGISTRY` and `XMAS` are `OnceLock`s, and `PLAYER_TYPES` is keyed by path. No RNG is used, so the tables come out the same. - With a 1-thread worker budget, everything still runs in order. - One difference: an error in one table no longer stops the others from loading. The first error found is the one returned. ## Before / after **How it was measured.** `--profile fast` builds of this branch and of its base `37ad1f5c9` (main), run on the same machine (12 cores, RTX 4060, Linux, warm file cache). Runs are interleaved A/B with the order flipped every iteration, after 1 warm-up run. Every run gets fresh scratch homes. The numbers are medians. "Socket" is the time from spawn until the control socket answers (startup done). "World ready" is the time until `horizon-ctl wait-ready` returns (`--offscreen --world W --creative --seed 1`). "Reopen" opens a copy of a world made earlier; "new world" creates one. The async rows are the log timings of a plain launch with no control socket (the loading screen path). Other jobs were running on the machine (load 4–8), which is why the runs were interleaved. | Measure | main | this PR | Difference | | --- | ---: | ---: | ---: | | World-rest ready (async, 12 runs) | 1705 ms | 1398 ms | **−307 ms (−18.0%)** | | Socket, reopen (12 runs) | 1595 ms | 1301 ms | **−294 ms (−18.4%)** | | World ready, reopen | 2866 ms | 2505 ms | **−361 ms (−12.6%)** | | Socket, new world (10 runs) | 1575 ms | 1259 ms | **−316 ms (−20.1%)** | | World ready, new world | 4232 ms | 3342 ms | **−890 ms (−21.0%)** | | Title screen ready (async) | 1232 ms | 1272 ms | +40 ms (+3.3%, noise: this PR doesn't touch that path) | **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 37ad1f5c9, 14 min 24 s) | Check | Result | | --- | --- | | Scope | ✅ 1 file, +87 −43 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ✅ 1318 passed | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | launcher | ➖ launcher untouched | | Parity | ➖ affected harnesses run in CI (--quick) | Closes #5000 🤖 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 05:16:36 +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#6011
No description provided.