[PR #5019] [MERGED] Preload the world data of a launch that names a world #6012

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/5019
Author: @rdbtCVS
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: perf/preload-world-at-launch


📝 Commits (2)

  • e3b213f Preload the world data of a launch that names a world
  • 09a4cd9 Merge main into perf/preload-world-at-launch

📊 Changes

3 files changed (+87 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+16 -1)
📝 crates/horizon-client/src/game/startup_menu.rs (+2 -0)
📝 crates/horizon-client/src/game/world_loading.rs (+69 -6)

📄 Description

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

When a launch names a world (--world, --quickPlaySingleplayer), the game already knows which world it will open. Until now, the world's data (the worldgen bundle, the Overworld decoration, loot data and the sync data) was only read once the open started. Now load_resources starts a "World data preload" thread for that world as soon as the block registry and biomes are loaded. The light tables, pack tables, renderer and the rest loader keep loading beside it, and the world open finds the data in the cache.

  • world_loading::preload_launch_world reuses the existing preload state, so the 60-second drop and world_data_used work as before. It reads the world's data-pack overrides from saves/<folder>, with the same calls make_streaming uses (factored out into worldgen_overrides_of), and uses the final resources root after any pack fallback. So the cache keys match the ones the open asks for.
  • It runs only for a client launch: not with --server or --test-terrain.
  • A cache miss is still correct. For example, a world saved in the Nether builds its own data when it opens, as on main. If the open starts before the preload is done, it waits on the cache lock instead of reading the data twice.

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 ready, new world (10 runs) 4232 ms 3006 ms −1226 ms (−29.0%)
World ready, reopen (12 runs) 2866 ms 2386 ms −480 ms (−16.7%)
Socket, reopen 1595 ms 1654 ms +59 ms (+3.7%)
Socket, new world 1575 ms 1629 ms +54 ms (+3.4%)

Startup itself (the socket) is about 55 ms later, because the preload thread competes with the other startup loaders. The world is ready 0.5–1.2 s sooner.

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

Check Result
Scope ✅ 3 files, +87 −7
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 #4998

🤖 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/5019 **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/preload-world-at-launch` --- ### 📝 Commits (2) - [`e3b213f`](https://github.com/horizon-rust/horizon/commit/e3b213f8f953e4bc7002cb608dab14394ae5b0f8) Preload the world data of a launch that names a world - [`09a4cd9`](https://github.com/horizon-rust/horizon/commit/09a4cd9baf0ffb06a5d5cb0ee91649622fe723cd) Merge main into perf/preload-world-at-launch ### 📊 Changes **3 files changed** (+87 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+16 -1) 📝 `crates/horizon-client/src/game/startup_menu.rs` (+2 -0) 📝 `crates/horizon-client/src/game/world_loading.rs` (+69 -6) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally. When a launch names a world (`--world`, `--quickPlaySingleplayer`), the game already knows which world it will open. Until now, the world's data (the worldgen bundle, the Overworld decoration, loot data and the sync data) was only read once the open started. Now `load_resources` starts a "World data preload" thread for that world as soon as the block registry and biomes are loaded. The light tables, pack tables, renderer and the rest loader keep loading beside it, and the world open finds the data in the cache. - `world_loading::preload_launch_world` reuses the existing preload state, so the 60-second drop and `world_data_used` work as before. It reads the world's data-pack overrides from `saves/<folder>`, with the same calls `make_streaming` uses (factored out into `worldgen_overrides_of`), and uses the final resources root after any pack fallback. So the cache keys match the ones the open asks for. - It runs only for a client launch: not with `--server` or `--test-terrain`. - A cache miss is still correct. For example, a world saved in the Nether builds its own data when it opens, as on main. If the open starts before the preload is done, it waits on the cache lock instead of reading the data twice. ## 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 ready, new world (10 runs) | 4232 ms | 3006 ms | **−1226 ms (−29.0%)** | | World ready, reopen (12 runs) | 2866 ms | 2386 ms | **−480 ms (−16.7%)** | | Socket, reopen | 1595 ms | 1654 ms | +59 ms (+3.7%) | | Socket, new world | 1575 ms | 1629 ms | +54 ms (+3.4%) | Startup itself (the socket) is about 55 ms later, because the preload thread competes with the other startup loaders. The world is ready 0.5–1.2 s sooner. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 37ad1f5c9, 10 min 57 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +87 −7 | | 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 #4998 🤖 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#6012
No description provided.