[PR #793] [MERGED] Creaking hearts: scan only sections whose palette holds a heart #2817

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

📋 Pull Request Information

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

Base: main ← Head: perf/creaking-heart-scan


📝 Commits (1)

  • 2c244f1 Creaking hearts: scan only sections whose palette holds a heart

📊 Changes

1 file changed (+5 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/creaking.rs (+5 -2)

📄 Description

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

What

The biggest block entity cost on the server thread while chunks stream was finding creaking hearts in new chunks. A section whose palette holds no heart state is now skipped.

  • scan_for_hearts gives each heart that came with a generated or loaded chunk its block entity, the first time the chunk is seen lit.
  • Before: it read all 4,096 blocks of every section that wasn't all air, up to 98,304 reads per chunk, on the server thread for every new chunk.
  • Now: a section is read only if its palette holds a heart state (PalettedContainer::maybe_has, vanilla's maybeHas). Almost no section does, so almost nothing is read.
  • The result is the same: the same block entities, created in the same order. A palette can only hold more states than the section uses, never fewer, so no heart is missed.

Measured (Mac mini M4 Pro)

Method:

  • Single player with --server-thread --offscreen, RD 12, fresh world, seed 1234.
  • 40 s after launch, the player travels 450 blocks in 15 s (/tp 15 blocks every 0.5 s).
  • macOS sample records the whole process during that travel (1 ms samples).
  • Order main / this / main / this. Main is 9b97ba09.
build server thread: heart scan server thread: all of tick_block_entities
main 243 / 236 ms 368 / 413 ms
this 2 / 4 ms 229 / 271 ms

That is about 16 ms of server-thread time saved per second of travel at RD 12. It grows with render distance and travel speed, and the same code runs in the in-frame single player.

What remains in tick_block_entities is each ticker (hoppers, spawners, vaults, beehives...) walking the whole block entity map for its own kind every tick, 10 walks per tick. That is the next cost here.

Checks

  • cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test -p horizon-client --lib: 838 passed.
  • tools/parity.py --changed origin/main: 16 passed, 0 failed (arrow, block_removal, command_exec, composter, crafter, dedicated_server, dispenser, locator_bar, mace, online_mode, sculk, server_world_gen, use_item_on, user_cache, section_mesh, world_spawn).

Needs Ludovic

Nothing.

🤖 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/793 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/creaking-heart-scan` --- ### 📝 Commits (1) - [`2c244f1`](https://github.com/horizon-rust/horizon/commit/2c244f188824aedc48212955ac87333863c67a30) Creaking hearts: scan only sections whose palette holds a heart ### 📊 Changes **1 file changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creaking.rs` (+5 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The biggest block entity cost on the server thread while chunks stream was finding creaking hearts in new chunks. A section whose palette holds no heart state is now skipped. - `scan_for_hearts` gives each heart that came with a generated or loaded chunk its block entity, the first time the chunk is seen lit. - **Before:** it read all 4,096 blocks of every section that wasn't all air, up to 98,304 reads per chunk, on the server thread for every new chunk. - **Now:** a section is read only if its palette holds a heart state (`PalettedContainer::maybe_has`, vanilla's `maybeHas`). Almost no section does, so almost nothing is read. - The result is the same: the same block entities, created in the same order. A palette can only hold more states than the section uses, never fewer, so no heart is missed. ## Measured (Mac mini M4 Pro) Method: - Single player with `--server-thread --offscreen`, RD 12, fresh world, seed 1234. - 40 s after launch, the player travels 450 blocks in 15 s (`/tp` 15 blocks every 0.5 s). - macOS `sample` records the whole process during that travel (1 ms samples). - Order main / this / main / this. Main is 9b97ba09. | build | server thread: heart scan | server thread: all of `tick_block_entities` | |---|---|---| | main | 243 / 236 ms | 368 / 413 ms | | **this** | **2 / 4 ms** | **229 / 271 ms** | That is about 16 ms of server-thread time saved per second of travel at RD 12. It grows with render distance and travel speed, and the same code runs in the in-frame single player. What remains in `tick_block_entities` is each ticker (hoppers, spawners, vaults, beehives...) walking the whole block entity map for its own kind every tick, 10 walks per tick. That is the next cost here. ## Checks - `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`: clean. - `cargo test -p horizon-client --lib`: 838 passed. - `tools/parity.py --changed origin/main`: 16 passed, 0 failed (arrow, block_removal, command_exec, composter, crafter, dedicated_server, dispenser, locator_bar, mace, online_mode, sculk, server_world_gen, use_item_on, user_cache, section_mesh, world_spawn). ## Needs Ludovic Nothing. 🤖 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:59:18 +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#2817
No description provided.