[PR #4117] [MERGED] Advancements: load the tree once for the server's packets and the game's criteria #5429

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

📋 Pull Request Information

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

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


📝 Commits (2)

  • 923f425 Advancements: load the tree once for the server's packets and the game's criteria
  • 0ec337f Merge main into this branch (world data packs' advancements: a tree is shared only without pack advancements)

📊 Changes

3 files changed (+31 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/advancements.rs (+25 -1)
📝 crates/horizon-client/src/game/advancements.rs (+4 -6)
📝 crates/horizon-client/src/lan/advancements.rs (+2 -2)

📄 Description

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

What and why

Fifth PR of the server plan (#3989, docs/server-next.md §7). Independent of the others.

A server's advancement tree was read and parsed twice from the same data/*/advancement files:

  • once by ServerAdvancements::load (lan/advancements.rs, the advancement packets, kept in the shared SyncData);
  • once by the game that runs the criteria (Game::advancement_tree and its prefetch thread).

That is 7.1 MB each on the dedicated server's live heap.

Tree::shared(data) loads the tree once per data folder and hands out an Arc while anyone holds it. It keeps a
Weak, so nothing lives longer than today. Both owners use it. A second caller waits for the first one's load
instead of parsing the files again. The client's own tree, built from the server's packets, is unchanged.

Measured

Mac mini M4 Pro (load 58–71), fresh scratch dedicated server, seed 12345, nobody on. Main 4cb754474 against this
branch. Malloc "allocated" bytes and live allocations from vmmap -summary:

run main this PR
1 (30 s) 538.3 MB, 2,669,267 530.7 MB, 2,616,234
2 (30 s) 538.9 MB, 2,669,165 543.2 MB, 2,640,777
3 (50 s) 550.6 MB, 2,686,048 531.3 MB, 2,616,238
4 (50 s) 538.4 MB, 2,669,166 530.9 MB, 2,616,231

The steady state is −7.5 MB and 53,000 fewer live allocations. Run 2 of this PR and run 3 of main were caught with
something still being made, which is visible in their node counts. At this load idle RSS swings by up to 70 MB,
so it can't show a gain this size (see #4092).

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 4cb754474, 16 min 53 s)

Check Result
Scope ✅ 3 files, +27 −7
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 475 passed (2 min 5 s)
rustfmt ✅ (14 s)
clippy ✅ (5 min 59 s)
tests: horizon-client ✅ 944 passed (7 min 42 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 32 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, entity_components, forced_end, friends_integration, hardcore_respawn, lan_integration and 20 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: run-parity label for CI.

🤖 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/4117 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/shared-advancement-tree` --- ### 📝 Commits (2) - [`923f425`](https://github.com/horizon-rust/horizon/commit/923f425f199ce234a4d4608a61da7aa65a5ce40b) Advancements: load the tree once for the server's packets and the game's criteria - [`0ec337f`](https://github.com/horizon-rust/horizon/commit/0ec337f17e7a732705b00b20c5b503d2a09b8b45) Merge main into this branch (world data packs' advancements: a tree is shared only without pack advancements) ### 📊 Changes **3 files changed** (+31 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/advancements.rs` (+25 -1) 📝 `crates/horizon-client/src/game/advancements.rs` (+4 -6) 📝 `crates/horizon-client/src/lan/advancements.rs` (+2 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Fifth PR of the server plan (#3989, `docs/server-next.md` §7). Independent of the others. A server's advancement tree was read and parsed twice from the same `data/*/advancement` files: - once by `ServerAdvancements::load` (`lan/advancements.rs`, the advancement packets, kept in the shared `SyncData`); - once by the game that runs the criteria (`Game::advancement_tree` and its prefetch thread). That is 7.1 MB each on the dedicated server's live heap. `Tree::shared(data)` loads the tree once per data folder and hands out an `Arc` while anyone holds it. It keeps a `Weak`, so nothing lives longer than today. Both owners use it. A second caller waits for the first one's load instead of parsing the files again. The client's own tree, built from the server's packets, is unchanged. ## Measured Mac mini M4 Pro (load 58–71), fresh scratch dedicated server, seed 12345, nobody on. Main 4cb754474 against this branch. Malloc "allocated" bytes and live allocations from `vmmap -summary`: | run | main | this PR | |---|---|---| | 1 (30 s) | 538.3 MB, 2,669,267 | **530.7 MB**, 2,616,234 | | 2 (30 s) | 538.9 MB, 2,669,165 | 543.2 MB, 2,640,777 | | 3 (50 s) | 550.6 MB, 2,686,048 | **531.3 MB**, 2,616,238 | | 4 (50 s) | 538.4 MB, 2,669,166 | **530.9 MB**, 2,616,231 | The steady state is −7.5 MB and 53,000 fewer live allocations. Run 2 of this PR and run 3 of main were caught with something still being made, which is visible in their node counts. At this load idle RSS swings by up to 70 MB, so it can't show a gain this size (see #4092). ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 4cb754474, 16 min 53 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +27 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 475 passed (2 min 5 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (5 min 59 s) | | tests: horizon-client | ✅ 944 passed (7 min 42 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 32 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, entity_components, forced_end, friends_integration, hardcore_respawn, lan_integration and 20 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: `run-parity` label for CI. 🤖 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:12:31 +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#5429
No description provided.