[PR #5015] [MERGED] Load the core startup tables in parallel (title screen 42% sooner) #6008

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

📋 Pull Request Information

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

Base: main ← Head: perf/parallel-core-resources


📝 Commits (1)

  • a648bef Load the core tables beside each other: the menu bundle, the block models and the block facts no longer wait in line

📊 Changes

1 file changed (+245 additions, -110 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+245 -110)

📄 Description

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

load_resources used to build the core tables one after another: the menu bundle, then the assets and block models, then the block facts, biomes and environment, then light, then the pack tables, then collision and motion. Most of these steps don't depend on each other. With this change they load beside each other:

[this thread] UI bundle (atlas + panorama; published as soon as it is ready)
   ‖ beside
[worker] load_core:
   Assets::load (registry)
     ├─ render assets → ItemRenderer
     ├─ models::load_visibility
     ├─ Biomes, Environment
     ├─ collisions::load
     └─ behaviour_json → BlockFacts
            ├─ LightTables (own thread)
            └─ MotionResources
join → MeshTables::new → PackResources::assemble → WorldCore
  • Each loader builds its own table from root and the registry (or the facts), with no RNG, so the tables come out the same as before. The only global write, set_block_states, still runs before everything else; lang::set and ui::load_metadata still run after the core.
  • Pack rollback is unchanged: a UI, Assets or render failure at the pack root still retries everything from the vanilla root.
  • When worker_threads() == 1, a small Step helper runs the steps one after another, in the same order as before.
  • PackResources::load (pack reloads) has the same signature; it now calls the new PackResources::assemble.

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
Core ready (async, 12 runs) 1076 ms 546 ms −530 ms (−49.3%)
Title screen ready (async) 1232 ms 708 ms −524 ms (−42.5%)
World-rest ready (async) 1705 ms 1214 ms −491 ms (−28.8%)
Socket, reopen (12 runs) 1595 ms 1112 ms −483 ms (−30.3%)
World ready, reopen 2866 ms 2275 ms −591 ms (−20.6%)
Socket, new world (10 runs) 1575 ms 1075 ms −500 ms (−31.8%)
World ready, new world 4232 ms 2908 ms −1324 ms (−31.3%)
Loading screen shown (async) 161 ms 190 ms +29 ms (+18.0%)
Menu bundle ready (async) 168 ms 205 ms +37 ms (+21.4%)

The two small regressions: the menu bundle now shares the CPU with the core workers, so the first frame comes about 30 ms later. Everything after it comes about half a second sooner.

Notes

  • If several loaders fail at once, the error reported can be a different one than before.
  • #4257 will conflict at the load_resources call site. The fix is to use FaceVisibility::empty() when headless, in the visibility step of load_core.

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

Check Result
Scope ✅ 1 file, +245 −110
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 #4999

🤖 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/5015 **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-core-resources` --- ### 📝 Commits (1) - [`a648bef`](https://github.com/horizon-rust/horizon/commit/a648bef38cfdb4f8952f72220fe74e8eba1bca98) Load the core tables beside each other: the menu bundle, the block models and the block facts no longer wait in line ### 📊 Changes **1 file changed** (+245 additions, -110 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+245 -110) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally. `load_resources` used to build the core tables one after another: the menu bundle, then the assets and block models, then the block facts, biomes and environment, then light, then the pack tables, then collision and motion. Most of these steps don't depend on each other. With this change they load beside each other: ``` [this thread] UI bundle (atlas + panorama; published as soon as it is ready) ‖ beside [worker] load_core: Assets::load (registry) ├─ render assets → ItemRenderer ├─ models::load_visibility ├─ Biomes, Environment ├─ collisions::load └─ behaviour_json → BlockFacts ├─ LightTables (own thread) └─ MotionResources join → MeshTables::new → PackResources::assemble → WorldCore ``` - Each loader builds its own table from `root` and the registry (or the facts), with no RNG, so the tables come out the same as before. The only global write, `set_block_states`, still runs before everything else; `lang::set` and `ui::load_metadata` still run after the core. - Pack rollback is unchanged: a UI, `Assets` or render failure at the pack root still retries everything from the vanilla root. - When `worker_threads() == 1`, a small `Step` helper runs the steps one after another, in the same order as before. - `PackResources::load` (pack reloads) has the same signature; it now calls the new `PackResources::assemble`. ## 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 | | --- | ---: | ---: | ---: | | Core ready (async, 12 runs) | 1076 ms | 546 ms | **−530 ms (−49.3%)** | | Title screen ready (async) | 1232 ms | 708 ms | **−524 ms (−42.5%)** | | World-rest ready (async) | 1705 ms | 1214 ms | **−491 ms (−28.8%)** | | Socket, reopen (12 runs) | 1595 ms | 1112 ms | **−483 ms (−30.3%)** | | World ready, reopen | 2866 ms | 2275 ms | **−591 ms (−20.6%)** | | Socket, new world (10 runs) | 1575 ms | 1075 ms | **−500 ms (−31.8%)** | | World ready, new world | 4232 ms | 2908 ms | **−1324 ms (−31.3%)** | | Loading screen shown (async) | 161 ms | 190 ms | +29 ms (+18.0%) | | Menu bundle ready (async) | 168 ms | 205 ms | +37 ms (+21.4%) | The two small regressions: the menu bundle now shares the CPU with the core workers, so the first frame comes about 30 ms later. Everything after it comes about half a second sooner. ## Notes - If several loaders fail at once, the error reported can be a different one than before. - #4257 will conflict at the `load_resources` call site. The fix is to use `FaceVisibility::empty()` when headless, in the visibility step of `load_core`. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 37ad1f5c9, 14 min 6 s) | Check | Result | | --- | --- | | Scope | ✅ 1 file, +245 −110 | | 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 #4999 🤖 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:34 +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#6008
No description provided.