[PR #713] [MERGED] Advancements: read the tree on another thread while the world loads #2751

Closed
opened 2026-11-02 15:58:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/advancement-tree-prefetch


📝 Commits (1)

  • d989d40 Advancements: read the tree on another thread while the world loads

📊 Changes

2 files changed (+22 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/advancements.rs (+21 -1)

📄 Description

The first tick after a world loads took 104 to 131 ms. About half of it was the advancement tree. open_world resets the advancement state, and the first criterion trigger of the first tick (enter_block, from the player's own move) then called advancement_tree(). That read and parsed every advancement JSON file on the game thread.

open_world now starts that read on a thread (prefetch_advancement_tree, thread horizon-advancements), while the world loads. The first advancement_tree() takes the thread's result, which is the same Tree::load of the same folder. If the thread failed, it falls back to reading the files there, as before.

Measured

  • Single-player world with seed 1234 and 400 mobs in a pen (perf-server-3's world), render distance 12, offscreen.
  • Timed with perf-server-3's tick and span probe, which is local only and not in this PR.
base this PR base this PR
First tick after the world loads 125.8 ms 58.0 ms 105.8 ms 53.5 ms
of which the motion events (the trigger that loaded the tree) 66.4 ms < 0.5 ms 60.3 ms < 0.5 ms
of which tick_world 68.8 ms 57.6 ms 45.3 ms 53.2 ms
Steady tick mean (800 ticks after load) 7.66 ms 7.63 ms 7.72 ms 7.72 ms

Machine: the same busy Mac mini, with a parity run of mine also going (~/fleet/load: 81 to 90 % busy).

The rest of the first tick is tick_world: mob ticking about 42 ms, block entities 12 to 15 ms.

Checks

  • cargo fmt --all --check: passes.
  • cargo clippy --workspace --all-targets -- -D warnings: passes, on this branch.
  • cargo test -p horizon-client --lib: 812 passed, 0 failed, on this branch.
  • tools/parity.py --changed origin/main (PARITY_LOCAL_JOBS=4) on one integration commit of this PR with #701 to #707, on main 7fb54b81: 86 of 86 harnesses pass. 70 had passed for the same inputs in the seven-PR run; the 16 this change could affect were run again and passed, among them dedicated_server, online_mode, command_exec and world_spawn.

🤖 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/713 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/advancement-tree-prefetch` --- ### 📝 Commits (1) - [`d989d40`](https://github.com/horizon-rust/horizon/commit/d989d4033f2ce9bdc31d72328aeb534c949e5d3c) Advancements: read the tree on another thread while the world loads ### 📊 Changes **2 files changed** (+22 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/advancements.rs` (+21 -1) </details> ### 📄 Description The first tick after a world loads took 104 to 131 ms. About half of it was the advancement tree. `open_world` resets the advancement state, and the first criterion trigger of the first tick (`enter_block`, from the player's own move) then called `advancement_tree()`. That read and parsed every advancement JSON file on the game thread. `open_world` now starts that read on a thread (`prefetch_advancement_tree`, thread `horizon-advancements`), while the world loads. The first `advancement_tree()` takes the thread's result, which is the same `Tree::load` of the same folder. If the thread failed, it falls back to reading the files there, as before. **Measured** - Single-player world with seed 1234 and 400 mobs in a pen (perf-server-3's world), render distance 12, offscreen. - Timed with perf-server-3's tick and span probe, which is local only and not in this PR. | | base | this PR | base | this PR | |---|---:|---:|---:|---:| | First tick after the world loads | 125.8 ms | 58.0 ms | 105.8 ms | 53.5 ms | | of which the motion events (the trigger that loaded the tree) | 66.4 ms | < 0.5 ms | 60.3 ms | < 0.5 ms | | of which `tick_world` | 68.8 ms | 57.6 ms | 45.3 ms | 53.2 ms | | Steady tick mean (800 ticks after load) | 7.66 ms | 7.63 ms | 7.72 ms | 7.72 ms | Machine: the same busy Mac mini, with a parity run of mine also going (`~/fleet/load`: 81 to 90 % busy). The rest of the first tick is `tick_world`: mob ticking about 42 ms, block entities 12 to 15 ms. **Checks** - `cargo fmt --all --check`: passes. - `cargo clippy --workspace --all-targets -- -D warnings`: passes, on this branch. - `cargo test -p horizon-client --lib`: 812 passed, 0 failed, on this branch. - `tools/parity.py --changed origin/main` (`PARITY_LOCAL_JOBS=4`) on one integration commit of this PR with #701 to #707, on main 7fb54b81: **86 of 86 harnesses pass**. 70 had passed for the same inputs in the seven-PR run; the 16 this change could affect were run again and passed, among them `dedicated_server`, `online_mode`, `command_exec` and `world_spawn`. 🤖 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-02 15:58:47 +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#2751
No description provided.