[PR #701] [MERGED] Server: skip the advancement flush for players whose progress didn't change #2741

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

📋 Pull Request Information

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

Base: main ← Head: perf/advancements-flush-idle


📝 Commits (1)

  • c98a4f7 Server advancements: flushDirty skips players whose progress didn't change

📊 Changes

1 file changed (+7 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/lan/advancements.rs (+7 -0)

📄 Description

On a dedicated server, ServerAdvancements::update (PlayerAdvancements.flushDirty) walked the whole advancement tree for every network player every tick, testing each advancement's criteria by name, only to find nothing had changed. With 50 walking bots this was the largest single cost of the server thread.

Vanilla's flushDirty does nothing unless it is the player's first packet or something is in rootsToUpdate / progressChanged. This PR does the same: update returns None straight away when it isn't the first packet and changed is empty.

Why this sends the same packets

  • Visibility depends only on progress and the tree. The tree never changes: SyncData is built once per server.
  • Every change to a guest's progress records itself in changed:
    • the criteria triggers and /advancement grant|revoke call progress_changed, which inserts into adv.changed while a guest is acting;
    • as_guest swaps the guest's advancements_changed in and out together with the progress.
  • Saved progress is loaded at join (load_guest_records), before the first packet.
  • So with an empty changed, the old code always ended with added, removed and progressed empty and returned None, with visible unchanged.

Measured (50 walking bots, same seed, settings and bot paths):

base this PR base this PR
MSPT (/tick query average) 20.7 ms 12.6 ms 38.6 ms 16.0 ms
MSPT P95 61.5 ms 34.9 ms 125.3 ms 50.3 ms
ServerAdvancements::update, share of the server thread (sampled run) 21.4 % 0.1 %

All seven server PRs together (#701 #702 #703 #704 #705 #706 #707), same method, unsampled runs, base/new/base/new:

Bots base all seven base all seven
50 MSPT 23.3 ms 12.5 ms 19.9 ms 10.5 ms
50 MSPT P95 74.3 ms 37.4 ms 62.1 ms 34.9 ms
50 server CPU (one core = 100 %) 73.9 % 70.0 % 75.4 % 68.2 %
25 MSPT 10.9 ms 6.9 ms 13.0 ms 6.3 ms
25 MSPT P95 34.7 ms 24.6 ms 37.6 ms 26.8 ms

Both builds sent the bots the same chunks (about 490 to 500 a second at 50 bots, 240 at 25).

How it was measured

  • Mac mini (M4 Pro, 14 threads, 64 GB), shared: other sessions kept the CPU 75 to 93 % busy (~/fleet/load, load 80 to 140) through every run.
  • tools/server_bench.py from #670: --servers horizon --behaviour walk --bots 50 --warmup 30 --seconds 45 --gamerule locator_bar=false, seed 12345, view and simulation distance 10, bots on the same machine. fast profile.
  • The server under test was main with #586/#670 merged in (vanilla's chunk pacing and the bots), and #623 (since merged).
  • MSPT is the server's own /tick query average. On this busy machine it varies up to 2x between identical runs, so each change is also measured by its share of the server thread: macOS sample, 20 s inside the measured window of a separate run per build.

Checks

  • cargo fmt --all --check: passes.
  • cargo clippy --workspace --all-targets -- -D warnings: passes, run on all seven server PRs together.
  • cargo test -p horizon-client --lib: 814 passed, 0 failed, run on the seven together on main 7fb54b81.
  • tools/parity.py --changed origin/main (PARITY_LOCAL_JOBS=4): 86 of 86 harnesses pass, run once on one integration commit of the seven PRs (#701 #702 #703 #704 #705 #706 #707) on main 7fb54b81. It took 68 min; online_mode passed on its fresh-oracle retry.

🤖 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/701 **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/advancements-flush-idle` --- ### 📝 Commits (1) - [`c98a4f7`](https://github.com/horizon-rust/horizon/commit/c98a4f7a58c2f2f945ef7801ab4dd9711bd54d6c) Server advancements: flushDirty skips players whose progress didn't change ### 📊 Changes **1 file changed** (+7 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/advancements.rs` (+7 -0) </details> ### 📄 Description On a dedicated server, `ServerAdvancements::update` (`PlayerAdvancements.flushDirty`) walked the whole advancement tree for every network player every tick, testing each advancement's criteria by name, only to find nothing had changed. With 50 walking bots this was the largest single cost of the server thread. Vanilla's `flushDirty` does nothing unless it is the player's first packet or something is in `rootsToUpdate` / `progressChanged`. This PR does the same: `update` returns `None` straight away when it isn't the first packet and `changed` is empty. **Why this sends the same packets** - Visibility depends only on progress and the tree. The tree never changes: `SyncData` is built once per server. - Every change to a guest's progress records itself in `changed`: - the criteria triggers and `/advancement grant|revoke` call `progress_changed`, which inserts into `adv.changed` while a guest is acting; - `as_guest` swaps the guest's `advancements_changed` in and out together with the progress. - Saved progress is loaded at join (`load_guest_records`), before the first packet. - So with an empty `changed`, the old code always ended with `added`, `removed` and `progressed` empty and returned `None`, with `visible` unchanged. **Measured** (50 walking bots, same seed, settings and bot paths): | | base | this PR | base | this PR | |---|---:|---:|---:|---:| | MSPT (`/tick query` average) | 20.7 ms | 12.6 ms | 38.6 ms | 16.0 ms | | MSPT P95 | 61.5 ms | 34.9 ms | 125.3 ms | 50.3 ms | | `ServerAdvancements::update`, share of the server thread (sampled run) | 21.4 % | 0.1 % | | | **All seven server PRs together** (#701 #702 #703 #704 #705 #706 #707), same method, unsampled runs, base/new/base/new: | Bots | | base | all seven | base | all seven | |---|---|---:|---:|---:|---:| | 50 | MSPT | 23.3 ms | 12.5 ms | 19.9 ms | 10.5 ms | | 50 | MSPT P95 | 74.3 ms | 37.4 ms | 62.1 ms | 34.9 ms | | 50 | server CPU (one core = 100 %) | 73.9 % | 70.0 % | 75.4 % | 68.2 % | | 25 | MSPT | 10.9 ms | 6.9 ms | 13.0 ms | 6.3 ms | | 25 | MSPT P95 | 34.7 ms | 24.6 ms | 37.6 ms | 26.8 ms | Both builds sent the bots the same chunks (about 490 to 500 a second at 50 bots, 240 at 25). **How it was measured** - Mac mini (M4 Pro, 14 threads, 64 GB), shared: other sessions kept the CPU 75 to 93 % busy (`~/fleet/load`, load 80 to 140) through every run. - `tools/server_bench.py` from #670: `--servers horizon --behaviour walk --bots 50 --warmup 30 --seconds 45 --gamerule locator_bar=false`, seed 12345, view and simulation distance 10, bots on the same machine. `fast` profile. - The server under test was main with #586/#670 merged in (vanilla's chunk pacing and the bots), and #623 (since merged). - MSPT is the server's own `/tick query` average. On this busy machine it varies up to 2x between identical runs, so each change is also measured by its share of the server thread: macOS `sample`, 20 s inside the measured window of a separate run per build. **Checks** - `cargo fmt --all --check`: passes. - `cargo clippy --workspace --all-targets -- -D warnings`: passes, run on all seven server PRs together. - `cargo test -p horizon-client --lib`: 814 passed, 0 failed, run on the seven together on main 7fb54b81. - `tools/parity.py --changed origin/main` (`PARITY_LOCAL_JOBS=4`): **86 of 86 harnesses pass**, run once on one integration commit of the seven PRs (#701 #702 #703 #704 #705 #706 #707) on main 7fb54b81. It took 68 min; `online_mode` passed on its fresh-oracle retry. 🤖 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:42 +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#2741
No description provided.