[PR #3847] [MERGED] Spawners: no level built while no player is in range #5245

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

📋 Pull Request Information

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

Base: main ← Head: perf/spawner-idle


📝 Commits (1)

  • e28ed6d Spawners: no level built while no player is in range

📊 Changes

2 files changed (+34 additions, -18 deletions)

View changed files

📝 crates/horizon-client/src/game/natural_spawning.rs (+25 -18)
📝 crates/horizon-client/src/game/spawner.rs (+9 -0)

📄 Description

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

What

BaseSpawner.serverTick returns first thing when no alive player is within the spawner's required_player_range (isNearPlayer) or spawner_blocks_work is off, before any random draw or change. Horizon's spawner tick still built the natural-spawn GameLevel first, every tick, for every spawner in a ticking chunk: every player with its box and mode (level_players), the nearest-player list and the mob world (teams, rules, local difficulty).

Now server_tick_spawner asks Game::alive_player_near first: the same hasNearbyAlivePlayer test over the same players (the shared LevelPlayer::alive_near), read one at a time without collecting them (level_players_iter, which level_players now collects). With a player in range, everything runs as before.

Measurements (dedicated server, Mac mini M4 Pro, fast profile, 100 mixed bots, view/simulation distance 10)

One interleaved A/B against origin/main on a shared, busy Mac mini (load 35 to 70), so the evidence is sample of the tick thread and the span:

origin/main this
natural_level share of the tick thread 1.6 % 0.5 % (what is left is the natural spawner's own, once a tick)
tick_block_entities share 2.4 % 1.8 %
tick_block_entities span, ms/tick 1.91 1.56

Total MSPT isn't comparable between these runs: the mob count and the machine's load differ from run to run.

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

Check Result
Scope ✅ 2 files, +34 −18
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 423 passed (1 min 58 s)
rustfmt ✅ (7 s)
clippy ❌ failed (50 s)
tests: horizon-client ❌ 673 passed, 1 failed (5 min 17 s)
doc tests ✅ 0 passed (3 min 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 ➖ 31 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 19 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The two failures are main's, not this branch's: clippy's log_display is never used (crates/horizon-client-render/src/gfx.rs:6204, macOS only; this branch doesn't touch it; with that one lint allowed locally, cargo clippy -p horizon-client --all-targets -- -D warnings is clean), and entity_nbt::axolotl_nbt_tests::bucket_cooldown_and_brain_memories_survive_and_expired_cooldown_is_removed fails the same way on origin/main 7ebf7d26c.

Harnesses: those affected run in CI (label run-parity); the Mac mini was too loaded to run them locally.

Part of roadmap item server-tick (servers at 20 TPS with 50 to 100 players). Nothing needs Ludovic.

🤖 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/3847 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/spawner-idle` --- ### 📝 Commits (1) - [`e28ed6d`](https://github.com/horizon-rust/horizon/commit/e28ed6d87799abad611c857a2794669f2b3eac7b) Spawners: no level built while no player is in range ### 📊 Changes **2 files changed** (+34 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/natural_spawning.rs` (+25 -18) 📝 `crates/horizon-client/src/game/spawner.rs` (+9 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `BaseSpawner.serverTick` returns first thing when no alive player is within the spawner's `required_player_range` (`isNearPlayer`) or `spawner_blocks_work` is off, before any random draw or change. Horizon's spawner tick still built the natural-spawn `GameLevel` first, every tick, for every spawner in a ticking chunk: every player with its box and mode (`level_players`), the nearest-player list and the mob world (teams, rules, local difficulty). Now `server_tick_spawner` asks `Game::alive_player_near` first: the same `hasNearbyAlivePlayer` test over the same players (the shared `LevelPlayer::alive_near`), read one at a time without collecting them (`level_players_iter`, which `level_players` now collects). With a player in range, everything runs as before. ## Measurements (dedicated server, Mac mini M4 Pro, `fast` profile, 100 `mixed` bots, view/simulation distance 10) One interleaved A/B against origin/main on a shared, busy Mac mini (load 35 to 70), so the evidence is `sample` of the tick thread and the span: | | origin/main | this | |---|---|---| | `natural_level` share of the tick thread | 1.6 % | 0.5 % (what is left is the natural spawner's own, once a tick) | | `tick_block_entities` share | 2.4 % | 1.8 % | | `tick_block_entities` span, ms/tick | 1.91 | 1.56 | Total MSPT isn't comparable between these runs: the mob count and the machine's load differ from run to run. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at cbea22fbb, 12 min 4 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +34 −18 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 423 passed (1 min 58 s) | | rustfmt | ✅ (7 s) | | clippy | ❌ failed (50 s) | | tests: horizon-client | ❌ 673 passed, 1 failed (5 min 17 s) | | doc tests | ✅ 0 passed (3 min 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 | ➖ 31 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 19 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The two failures are main's, not this branch's: clippy's `log_display` is never used (crates/horizon-client-render/src/gfx.rs:6204, macOS only; this branch doesn't touch it; with that one lint allowed locally, `cargo clippy -p horizon-client --all-targets -- -D warnings` is clean), and `entity_nbt::axolotl_nbt_tests::bucket_cooldown_and_brain_memories_survive_and_expired_cooldown_is_removed` fails the same way on origin/main 7ebf7d26c. Harnesses: those affected run in CI (label `run-parity`); the Mac mini was too loaded to run them locally. Part of roadmap item `server-tick` (servers at 20 TPS with 50 to 100 players). Nothing needs Ludovic. 🤖 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:11:14 +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#5245
No description provided.