[PR #3834] [MERGED] Scheduled ticks: run the due ticks against one level #5242

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

📋 Pull Request Information

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

Base: main ← Head: perf/scheduled-one-level


📝 Commits (1)

  • 20acff0 Scheduled ticks: run the due ticks against one level

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game.rs (+11 -2)
📝 crates/horizon-client/src/game/spill.rs (+7 -4)

📄 Description

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

What

tick_scheduled ran each due block and fluid tick in its own with_level, and every with_level builds the level again: the boxes of every minecart, arrow and LAN guest, the fire-spreading players, the game rules, the loot data lock, the ticket levels. With 50 to 100 players and their fluid ticks, that rebuild was a large part of the scheduled ticks.

Now the due ticks run in one with_level while each leaves nothing for the game to apply between them. The only things the game does between two steps are process_level_events (when the step queued level events) and flush_spill (when it spilled items, orbs or removed block entities); the loop stops at the first step that leaves either, the game handles it as before, and the next with_level sees the result. So every tick still sees what the ones before it did, in the same order: behaviour unchanged.

Spill::is_empty is the check flush_spill already made.

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

A/B against the same build without this change (both with #3815), interleaved, two passes each; the Mac mini was shared and busy (load 60 to 75), so the evidence is the spans (HORIZON_SPIKES=0, mean per tick) and sample of the tick thread:

pass tick_blocks ms/tick before → after tick thread CPU ms before → after tick_scheduled share of the tick thread
1 15.43 → 10.43 36.7 → 31.7 8.9 % → 6.3 %
2 14.84 → 9.34 34.6 → 28.7 10.6 % → 7.1 %

A 100-bot pass against origin/main with both changes: tick_blocks 18.5 → 7.0 ms/tick (mob counts differed between those runs, so their total MSPT is not comparable).

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at d601fc2e5, 6 min 33 s)

Check Result
Scope ✅ 2 files, +18 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 423 passed (2 min 58 s)
rustfmt ✅ (11 s)
clippy ✅ (12 s)
tests: horizon-client ✅ 860 passed (2 min 56 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 ➖ 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)

Harnesses: the 31 affected (block_removal, command_exec, composter, dedicated_server, dispenser, lan_integration…) run in CI (label run-parity); a local probe build did not finish within an hour on the loaded Mac mini.

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/3834 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/scheduled-one-level` --- ### 📝 Commits (1) - [`20acff0`](https://github.com/horizon-rust/horizon/commit/20acff0b3c7e4dfa913d3933c01b0443f54b8711) Scheduled ticks: run the due ticks against one level ### 📊 Changes **2 files changed** (+18 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+11 -2) 📝 `crates/horizon-client/src/game/spill.rs` (+7 -4) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `tick_scheduled` ran each due block and fluid tick in its own `with_level`, and every `with_level` builds the level again: the boxes of every minecart, arrow and LAN guest, the fire-spreading players, the game rules, the loot data lock, the ticket levels. With 50 to 100 players and their fluid ticks, that rebuild was a large part of the scheduled ticks. Now the due ticks run in one `with_level` while each leaves nothing for the game to apply between them. The only things the game does between two steps are `process_level_events` (when the step queued level events) and `flush_spill` (when it spilled items, orbs or removed block entities); the loop stops at the first step that leaves either, the game handles it as before, and the next `with_level` sees the result. So every tick still sees what the ones before it did, in the same order: behaviour unchanged. `Spill::is_empty` is the check `flush_spill` already made. ## Measurements (dedicated server, Mac mini M4 Pro, `fast` profile, 50 `mixed` bots, view/simulation distance 10) A/B against the same build without this change (both with #3815), interleaved, two passes each; the Mac mini was shared and busy (load 60 to 75), so the evidence is the spans (`HORIZON_SPIKES=0`, mean per tick) and `sample` of the tick thread: | pass | `tick_blocks` ms/tick before → after | tick thread CPU ms before → after | `tick_scheduled` share of the tick thread | |---|---|---|---| | 1 | 15.43 → 10.43 | 36.7 → 31.7 | 8.9 % → 6.3 % | | 2 | 14.84 → 9.34 | 34.6 → 28.7 | 10.6 % → 7.1 % | A 100-bot pass against origin/main with both changes: `tick_blocks` 18.5 → 7.0 ms/tick (mob counts differed between those runs, so their total MSPT is not comparable). **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at d601fc2e5, 6 min 33 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +18 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 423 passed (2 min 58 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (12 s) | | tests: horizon-client | ✅ 860 passed (2 min 56 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 | ➖ 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) | Harnesses: the 31 affected (block_removal, command_exec, composter, dedicated_server, dispenser, lan_integration…) run in CI (label `run-parity`); a local probe build did not finish within an hour on the loaded Mac mini. 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:12 +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#5242
No description provided.