[PR #5191] [MERGED] Mobs: compare each block write's collision shapes once per tick, not once per pathing mob #6131

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

📋 Pull Request Information

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

Base: main ← Head: perf/path-shape-changes-once


📝 Commits (1)

  • c8146cd Mobs: compare each block write's collision shapes once per tick, not once per pathing mob

📊 Changes

2 files changed (+20 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+2 -1)
📝 crates/horizon-client/src/mobs.rs (+18 -6)

📄 Description

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

Roadmap server-tick (dedicated server at 20 TPS with 50–100 players).

What

ServerLevel.sendBlockUpdated compares a write's old and new collision shapes once, then asks each navigating mob shouldRecomputePath. blocks_changed compared the two shapes again for every pathing mob and every write of the tick (collision_bounds_of twice per pair). With 60 players and ~1800 mobs that was mobs × writes shape lookups per tick.

Now collision_changes keeps the writes whose shape changed, once per tick, and each mob only runs should_recompute_path on those. Same writes, same order, same mobs asked: collision_bounds_of takes no subject (subject: None) and the world doesn't change during the mob loop, so the result is the same.

Numbers

playhorizon, --profile fast, CPUs 0-3 exclusive, 60 server bots (horizon-bots), seed 12345, view/sim distance 10, warm-up 120 s, 90 s window, A/B alternated, 3 rounds each:

MSPT avg (3 rounds) median TPS (median) p99 (median) tick_creature_entities ms/tick
main + spans 114.8 / 117.8 / 113.9 114.8 8.72 146.6 36.8 / 38.9 / 38.5
this PR + spans 103.0 / 101.8 / 102.7 102.7 (−10.5 %) 9.75 128.5 19.9 / 20.2 / 22.4

The mobs' tick (without natural spawning) is roughly halved. The spans come from a separate branch (perf/spans-mob-phases) used only for the measurement. A macOS sample of the tick thread on main showed blocks_changed at 4.5 % of the thread; with this change it is gone from the profile.

Checks

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at bd541458c, 12 min 27 s)

Check Result
Scope ✅ 2 files, +20 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (4 min 8 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 54 s)
tests: horizon-client ✅ 1340 passed (5 min 45 s)
doc tests ✅ 0 passed (2 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 ➖ 56 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot, entity_model and 44 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

pr_ready ran against origin/main bd541458c. The branch is now rebased on af55a7348 with no conflicts (cargo check --bin horizon-client clean). The affected parity harnesses (56, including dedicated_server, server_entities, server_player_damage and mob_ai) run in 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/5191 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `perf/path-shape-changes-once` --- ### 📝 Commits (1) - [`c8146cd`](https://github.com/horizon-rust/horizon/commit/c8146cdba6d5da288857a78c39bfcae86b4522f9) Mobs: compare each block write's collision shapes once per tick, not once per pathing mob ### 📊 Changes **2 files changed** (+20 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -1) 📝 `crates/horizon-client/src/mobs.rs` (+18 -6) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap `server-tick` (dedicated server at 20 TPS with 50–100 players). ## What `ServerLevel.sendBlockUpdated` compares a write's old and new collision shapes once, then asks each navigating mob `shouldRecomputePath`. `blocks_changed` compared the two shapes again for every pathing mob and every write of the tick (`collision_bounds_of` twice per pair). With 60 players and ~1800 mobs that was mobs × writes shape lookups per tick. Now `collision_changes` keeps the writes whose shape changed, once per tick, and each mob only runs `should_recompute_path` on those. Same writes, same order, same mobs asked: `collision_bounds_of` takes no subject (`subject: None`) and the world doesn't change during the mob loop, so the result is the same. ## Numbers playhorizon, `--profile fast`, CPUs 0-3 exclusive, 60 `server` bots (horizon-bots), seed 12345, view/sim distance 10, warm-up 120 s, 90 s window, A/B alternated, 3 rounds each: | | MSPT avg (3 rounds) | median | TPS (median) | p99 (median) | `tick_creature_entities` ms/tick | |---|---|---|---|---|---| | main + spans | 114.8 / 117.8 / 113.9 | **114.8** | 8.72 | 146.6 | 36.8 / 38.9 / 38.5 | | this PR + spans | 103.0 / 101.8 / 102.7 | **102.7 (−10.5 %)** | 9.75 | 128.5 | 19.9 / 20.2 / 22.4 | The mobs' tick (without natural spawning) is roughly halved. The spans come from a separate branch (perf/spans-mob-phases) used only for the measurement. A macOS `sample` of the tick thread on main showed `blocks_changed` at 4.5 % of the thread; with this change it is gone from the profile. ## Checks **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at bd541458c, 12 min 27 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +20 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (4 min 8 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 54 s) | | tests: horizon-client | ✅ 1340 passed (5 min 45 s) | | doc tests | ✅ 0 passed (2 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 | ➖ 56 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot, entity_model and 44 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | pr_ready ran against origin/main bd541458c. The branch is now rebased on af55a7348 with no conflicts (`cargo check --bin horizon-client` clean). The affected parity harnesses (56, including `dedicated_server`, `server_entities`, `server_player_damage` and `mob_ai`) run in 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 06:12:50 +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#6131
No description provided.