[PR #835] [MERGED] Decoration order: dense grids instead of hash maps #2847

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

📋 Pull Request Information

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

Base: main ← Head: perf/decoration-order-grid


📝 Commits (1)

  • cf97a5e Decoration order: dense grids instead of hash maps

📊 Changes

1 file changed (+133 additions, -22 deletions)

View changed files

📝 crates/horizon-world/src/worldgen/decoration_order.rs (+133 -22)

📄 Description

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

The cost

decoration_order::vanilla_order replays vanilla's chunk ticket scheduler over every chunk in view, to decorate chunks in vanilla's order. The streaming update calls it on the render thread each time the player crosses into another chunk (about once a second when flying at 16 blocks/s). At render distance 32 that is 4,225 tickets, each lowering the levels of the 7×7 chunks around it: about 200,000 updates in SipHash HashMaps and HashSets.

In a sample profile of the render thread while flying through new terrain at RD 32 (Mac mini, main), vanilla_order was half of Streaming::update. It ran in a single frame, so it added a spike rather than a steady cost.

The change

Every chunk the replay touches lies within radius + 4 of the centre, so the levels, queued tasks, FULL flags and visited set now live in dense grids over that square instead of hash maps. The heap, the ticket order and the replay itself are unchanged. A test checks the result against the hash map version (kept in the test module) for several centres and radii, up to radius 32 and at ±30,000.

Performance

vanilla_order alone, release build, Mac mini M4 Pro (mean of 5 calls at different centres):

radius main this PR
8 1.32 ms 0.12 ms
16 2.69 ms 0.30 ms
32 8.14 ms 1.06 ms

So the frame where the player enters a new chunk at RD 32 gets about 7 ms shorter. In whole-game paired runs (ABBA, 12 pairs of 3 s at RD 32, exploring), average frame metrics did not show it: the Mac mini was at load average 70–110 from other sessions, and one 7 ms saving per second is well inside that noise (streaming span p99 97.6 → 71.1 ms in one run, 52.3 → 63.2 ms in the other).

Correctness

The decoration order is identical by construction and by test, so worldgen output does not change. The worldgen parity harnesses (decoration, decorated_region, chunk_generation and the rest that read this crate) ran on an integration commit with #834.

Self-check

Run on one integration commit of both PRs (#834 and #835 merged onto origin/main d85a3603):

  • cargo fmt --all --check: ok
  • cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --lib: 861 passed
  • cargo test -p horizon-world --lib: 102 passed
  • Harnesses that cover these files, on that commit (Mac mini): section_mesh, translucency, weather_render, world_border_render, decoration: 5 of 5 pass.
  • tools/parity.py --changed origin/main (Mac mini), on an earlier integration of the same changes: 293 of 294 harnesses pass. tooltip_display fails the same way on plain origin/main: the harness writes Python's False and the fixture parses it as a Rust bool (ParseBoolError).
  • New test worldgen::decoration_order::tests::dense_grids_keep_the_hashed_order.

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/835 **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/decoration-order-grid` --- ### 📝 Commits (1) - [`cf97a5e`](https://github.com/horizon-rust/horizon/commit/cf97a5e1dc164d51d3fef86bf8b0f56d33f45902) Decoration order: dense grids instead of hash maps ### 📊 Changes **1 file changed** (+133 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-world/src/worldgen/decoration_order.rs` (+133 -22) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## The cost `decoration_order::vanilla_order` replays vanilla's chunk ticket scheduler over every chunk in view, to decorate chunks in vanilla's order. The streaming update calls it on the render thread each time the player crosses into another chunk (about once a second when flying at 16 blocks/s). At render distance 32 that is 4,225 tickets, each lowering the levels of the 7×7 chunks around it: about 200,000 updates in SipHash `HashMap`s and `HashSet`s. In a `sample` profile of the render thread while flying through new terrain at RD 32 (Mac mini, main), `vanilla_order` was half of `Streaming::update`. It ran in a single frame, so it added a spike rather than a steady cost. ## The change Every chunk the replay touches lies within `radius + 4` of the centre, so the levels, queued tasks, FULL flags and visited set now live in dense grids over that square instead of hash maps. The heap, the ticket order and the replay itself are unchanged. A test checks the result against the hash map version (kept in the test module) for several centres and radii, up to radius 32 and at ±30,000. ## Performance `vanilla_order` alone, release build, Mac mini M4 Pro (mean of 5 calls at different centres): | radius | main | this PR | | --- | --- | --- | | 8 | 1.32 ms | 0.12 ms | | 16 | 2.69 ms | 0.30 ms | | 32 | 8.14 ms | 1.06 ms | So the frame where the player enters a new chunk at RD 32 gets about 7 ms shorter. In whole-game paired runs (ABBA, 12 pairs of 3 s at RD 32, exploring), average frame metrics did not show it: the Mac mini was at load average 70–110 from other sessions, and one 7 ms saving per second is well inside that noise (`streaming` span p99 97.6 → 71.1 ms in one run, 52.3 → 63.2 ms in the other). ## Correctness The decoration order is identical by construction and by test, so worldgen output does not change. The worldgen parity harnesses (decoration, decorated_region, chunk_generation and the rest that read this crate) ran on an integration commit with #834. ## Self-check Run on one integration commit of both PRs (#834 and #835 merged onto origin/main `d85a3603`): - `cargo fmt --all --check`: ok - `cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --lib`: 861 passed - `cargo test -p horizon-world --lib`: 102 passed - Harnesses that cover these files, on that commit (Mac mini): section_mesh, translucency, weather_render, world_border_render, decoration: 5 of 5 pass. - `tools/parity.py --changed origin/main` (Mac mini), on an earlier integration of the same changes: 293 of 294 harnesses pass. `tooltip_display` fails the same way on plain origin/main: the harness writes Python's `False` and the fixture parses it as a Rust `bool` (`ParseBoolError`). - New test `worldgen::decoration_order::tests::dense_grids_keep_the_hashed_order`. ## 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:33 +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#2847
No description provided.