[PR #6238] [MERGED] Creaking hearts: scan only the chunks that arrived, not every chunk each tick #6736

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6238
Author: @ludovic111
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: perf/block-entity-scans-arrivals


📝 Commits (1)

  • 06c4662 Creaking hearts: scan only the chunks that arrived, not every chunk each tick

📊 Changes

1 file changed (+115 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/game/creaking.rs (+115 -12)

📄 Description

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

Why

On every tick, scan_for_hearts looked at every loaded chunk to find the ones it hadn't scanned yet, then ran retain over its scanned set. On a server with 50 players and tens of thousands of loaded chunks, that work repeats each tick even when no chunk arrived.

What

CreakingState follows the chunk map's membership deltas (deltas_since, the same pattern other per-chunk caches use):

  • an arriving chunk goes into unscanned;
  • a departing chunk leaves both sets;
  • an unchanged revision skips the walk entirely;
  • when the delta ring overflows, the sets are rebuilt from the map.

Each tick then scans only the arrived chunks that are lit (sorted, as before). The palette scan of a chunk is unchanged. The new test the_heart_scan_follows_arrivals_and_departures covers arrivals, departures and lighting.

Numbers

The 50-bot bench on playhorizon: official server shape, view 8, sim 6, easy, --behaviour server, warm-up 150 s, window 120 s, CPUs 0-3 exclusive, rounds alternated:

run tick_block_entities ms/tick MSPT avg P50 P99 worst mobs
base r1 2.28 81.6 80.8 104.4 129.4 1811
PR r1 1.59 70.9 69.9 89.7 108.5 1470
base r2 1.91 72.4 71.3 96.0 124.7 1708
PR r2 1.67 83.0 82.2 106.9 120.2 1933

The span that holds the scan drops by ~0.45 ms per tick (−22 %). Total MSPT follows the mob count of each run (1470–1933 mobs), so it can't separate a gain this size: don't read the total MSPT rows as a result.

Checks

  • cargo test --profile fast --no-default-features --bin horizon-client -- creaking::tests on playhorizon: 1 passed.
  • Parity: 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/6238 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/block-entity-scans-arrivals` --- ### 📝 Commits (1) - [`06c4662`](https://github.com/horizon-rust/horizon/commit/06c4662593168869763ae9989fe452de0fd70aab) Creaking hearts: scan only the chunks that arrived, not every chunk each tick ### 📊 Changes **1 file changed** (+115 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creaking.rs` (+115 -12) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## Why On every tick, `scan_for_hearts` looked at every loaded chunk to find the ones it hadn't scanned yet, then ran `retain` over its scanned set. On a server with 50 players and tens of thousands of loaded chunks, that work repeats each tick even when no chunk arrived. ## What `CreakingState` follows the chunk map's membership deltas (`deltas_since`, the same pattern other per-chunk caches use): - an arriving chunk goes into `unscanned`; - a departing chunk leaves both sets; - an unchanged revision skips the walk entirely; - when the delta ring overflows, the sets are rebuilt from the map. Each tick then scans only the arrived chunks that are lit (sorted, as before). The palette scan of a chunk is unchanged. The new test `the_heart_scan_follows_arrivals_and_departures` covers arrivals, departures and lighting. ## Numbers The 50-bot bench on playhorizon: official server shape, view 8, sim 6, easy, `--behaviour server`, warm-up 150 s, window 120 s, CPUs 0-3 exclusive, rounds alternated: | run | `tick_block_entities` ms/tick | MSPT avg | P50 | P99 | worst | mobs | |---|---|---|---|---|---|---| | base r1 | 2.28 | 81.6 | 80.8 | 104.4 | 129.4 | 1811 | | PR r1 | **1.59** | 70.9 | 69.9 | 89.7 | 108.5 | 1470 | | base r2 | 1.91 | 72.4 | 71.3 | 96.0 | 124.7 | 1708 | | PR r2 | **1.67** | 83.0 | 82.2 | 106.9 | 120.2 | 1933 | The span that holds the scan drops by ~0.45 ms per tick (−22 %). Total MSPT follows the mob count of each run (1470–1933 mobs), so it can't separate a gain this size: don't read the total MSPT rows as a result. ## Checks - `cargo test --profile fast --no-default-features --bin horizon-client -- creaking::tests` on playhorizon: 1 passed. - Parity: 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:25:51 +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#6736
No description provided.