[PR #2108] [MERGED] Worldgen data loads its three biggest parts in parallel #4010

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2108
Author: @ludovic111
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: perf/worldgen-data-parallel-load


📝 Commits (1)

  • 83f0d5b Worldgen data loads its three biggest parts in parallel

📊 Changes

4 files changed (+94 additions, -55 deletions)

View changed files

📝 crates/horizon-client/src/vanillagen.rs (+2 -0)
📝 crates/horizon-world/src/level/data.rs (+4 -2)
📝 crates/horizon-world/src/worldgen/generator.rs (+68 -44)
📝 crates/horizon-world/src/worldgen/generator_blocks.rs (+20 -9)

📄 Description

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

When a world opens, the server thread loads the worldgen data (GeneratorData::load) by itself while the chunk workers wait. On a 2-core ThinkPad this is the 3-5 s of a new world's entry where only one core is busy. Everything was read one part after another.

Change

  • The three biggest parts depend only on the block and fluid tags. They now load on threads of their own ("Worldgen loader") while the server thread reads the rest, and they are joined where they are used:
    • the block tables (BlockBehavior::load),
    • the structure templates,
    • the block behaviours (Behaviours::load).
  • BlockBehavior::load reads its cached-support table on a scoped thread, beside the collision and properties tables.
  • The behaviour exports are parsed from the file's bytes in memory (serde_json::from_slice) instead of through a BufReader. gameplay-facts.json is 55 MB, and a first start parses it before the snapshot in .horizon-cache exists. The client switched its own big JSON files to this in 2217ebcb3.
  • vanillagen::shared_data logs Horizon: worldgen data loaded in ….

The loaded data is the same. Only the order of the reads changes, and an error still surfaces from the same load call.

Numbers

A temporary probe (not committed) times GeneratorData::load six times: the first run has no behaviour snapshot, the next five are warm. Base and this PR were alternated 3 times.

main this PR
ThinkPad (i5-7200U, 2 cores), warm 0.61-0.73 s (mean 0.64) 0.42-0.48 s (mean 0.45)
ThinkPad, first start 2.39-2.42 s 1.98-2.14 s
Mac mini (M4 Pro), warm, last 2 rounds 0.38-0.71 s 0.19-0.28 s
Mac mini, first start, last 2 rounds 1.75-3.07 s 0.88-1.08 s

The Mac numbers are noisy: CI load was 83-90.

Checks

  • tools/lan_e2e.py:
    • Host in-frame: chest, light pass.
    • --server-thread: chest, portals, levels pass.
    • Each check opens new worlds in both modes.

No label: players wait less for a new world but get nothing new.

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at 2a0f4e39a, 62 min 36 s)

Check Result
Scope ✅ 4 files, +94 −55
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (9 s)
clippy ✅ (1 min 39 s)
tests: horizon-client, horizon-world ✅ 1534 passed (12 min 39 s)
doc tests ✅ 0 passed (6 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 93 affected, 93 passed (47 min 39 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/2108 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/worldgen-data-parallel-load` --- ### 📝 Commits (1) - [`83f0d5b`](https://github.com/horizon-rust/horizon/commit/83f0d5bf582166a3114495eb20cf662f21078040) Worldgen data loads its three biggest parts in parallel ### 📊 Changes **4 files changed** (+94 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/vanillagen.rs` (+2 -0) 📝 `crates/horizon-world/src/level/data.rs` (+4 -2) 📝 `crates/horizon-world/src/worldgen/generator.rs` (+68 -44) 📝 `crates/horizon-world/src/worldgen/generator_blocks.rs` (+20 -9) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. When a world opens, the server thread loads the worldgen data (`GeneratorData::load`) by itself while the chunk workers wait. On a 2-core ThinkPad this is the 3-5 s of a new world's entry where only one core is busy. Everything was read one part after another. ### Change - The three biggest parts depend only on the block and fluid tags. They now load on threads of their own ("Worldgen loader") while the server thread reads the rest, and they are joined where they are used: - the block tables (`BlockBehavior::load`), - the structure templates, - the block behaviours (`Behaviours::load`). - `BlockBehavior::load` reads its cached-support table on a scoped thread, beside the collision and properties tables. - The behaviour exports are parsed from the file's bytes in memory (`serde_json::from_slice`) instead of through a `BufReader`. gameplay-facts.json is 55 MB, and a first start parses it before the snapshot in `.horizon-cache` exists. The client switched its own big JSON files to this in 2217ebcb3. - `vanillagen::shared_data` logs `Horizon: worldgen data loaded in …`. The loaded data is the same. Only the order of the reads changes, and an error still surfaces from the same `load` call. ### Numbers A temporary probe (not committed) times `GeneratorData::load` six times: the first run has no behaviour snapshot, the next five are warm. Base and this PR were alternated 3 times. | | main | this PR | |---|---|---| | ThinkPad (i5-7200U, 2 cores), warm | 0.61-0.73 s (mean 0.64) | 0.42-0.48 s (mean 0.45) | | ThinkPad, first start | 2.39-2.42 s | 1.98-2.14 s | | Mac mini (M4 Pro), warm, last 2 rounds | 0.38-0.71 s | 0.19-0.28 s | | Mac mini, first start, last 2 rounds | 1.75-3.07 s | 0.88-1.08 s | The Mac numbers are noisy: CI load was 83-90. ### Checks - `tools/lan_e2e.py`: - Host in-frame: chest, light pass. - `--server-thread`: chest, portals, levels pass. - Each check opens new worlds in both modes. No label: players wait less for a new world but get nothing new. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at 2a0f4e39a, 62 min 36 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +94 −55 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 39 s) | | tests: horizon-client, horizon-world | ✅ 1534 passed (12 min 39 s) | | doc tests | ✅ 0 passed (6 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 93 affected, 93 passed (47 min 39 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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 04:14: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#4010
No description provided.