[PR #6621] [MERGED] Structure block boxes: look only at structure and test blocks each frame #6990

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

📋 Pull Request Information

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

Base: main ← Head: perf/gizmo-box-index


📝 Commits (1)

  • eded4b2 Structure block boxes: look only at structure and test blocks each frame

📊 Changes

2 files changed (+81 additions, -2 deletions)

View changed files

📝 crates/horizon-client-render/src/block_entities.rs (+80 -1)
📝 crates/horizon-client/src/game/structure_blocks.rs (+1 -1)

📄 Description

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

bounding_box_gizmos (structure and test instance block boxes) walked every loaded block entity each frame to find the few blocks whose box it may draw. At RD 32 that's every chest, sign, bed and banner in thousands of chunks: a sample of an RD 32 mountain flight on an M4 Pro (main 1bd24e40) put the scan at 0.12 ms of every frame, in worlds that have no structure block at all.

Now BlockEntities keeps the positions of its structure and test instance blocks, the same way it already keeps the mod block entities. boxes() lists them, and the frame reads only that list. The index follows each way a block entity comes and goes: insert, get_or_insert_with, put, remove, retain, clear and load_chunk. take keeps the position, because the entity comes back with put. A new test checks that the list matches exactly the structure and test blocks through each of those paths.

Measurements

Mac mini M4 Pro, 1080p offscreen, perf_bench scenes, RD 32, 12 s flights. The machine is GPU-bound and shared (load 40-80), so the figure is the main thread's CPU per frame (ps -M before and after each flight). ab1 = this PR + #6620 (monitor listing), alternating with main:

scene main: main-thread ms/frame ab1 run 0 ab1 run 1
village 1.92 1.66 1.81
forest 2.07 1.81 1.92
ocean 2.03 1.93 1.95
mountain 2.67 2.42 2.46

This PR's share is the scan the sample found: it grows with the number of block entities loaded, so with render distance. I didn't measure RD 8/16. Boxes draw exactly as before: the same blocks, in the same order of positions.

Checks

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at dea6dea98, 36 min 58 s)

Check Result
Scope ✅ 2 files, +81 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 586 passed (1 min 15 s)
rustfmt ✅ (15 s)
clippy ✅ (1 min 49 s)
tests: horizon-client, horizon-client-render ❌ 1198 passed, 1 failed (32 min 26 s)
doc tests ✅ 0 passed (4 s)
Parity ➖ 127 affected, to run in CI (--quick)

The one failure, entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation, also fails on main where .local data is present (CI skips it). This change doesn't touch it.

🤖 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/6621 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/gizmo-box-index` --- ### 📝 Commits (1) - [`eded4b2`](https://github.com/horizon-rust/horizon/commit/eded4b24ddf6f9c5a035cf50090bde8df8023ab0) Structure block boxes: look only at structure and test blocks each frame ### 📊 Changes **2 files changed** (+81 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/block_entities.rs` (+80 -1) 📝 `crates/horizon-client/src/game/structure_blocks.rs` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. `bounding_box_gizmos` (structure and test instance block boxes) walked every loaded block entity each frame to find the few blocks whose box it may draw. At RD 32 that's every chest, sign, bed and banner in thousands of chunks: a `sample` of an RD 32 mountain flight on an M4 Pro (main 1bd24e40) put the scan at **0.12 ms of every frame**, in worlds that have no structure block at all. Now `BlockEntities` keeps the positions of its structure and test instance blocks, the same way it already keeps the mod block entities. `boxes()` lists them, and the frame reads only that list. The index follows each way a block entity comes and goes: `insert`, `get_or_insert_with`, `put`, `remove`, `retain`, `clear` and `load_chunk`. `take` keeps the position, because the entity comes back with `put`. A new test checks that the list matches exactly the structure and test blocks through each of those paths. ### Measurements Mac mini M4 Pro, 1080p offscreen, perf_bench scenes, RD 32, 12 s flights. The machine is GPU-bound and shared (load 40-80), so the figure is the main thread's CPU per frame (`ps -M` before and after each flight). `ab1` = this PR + #6620 (monitor listing), alternating with main: | scene | main: main-thread ms/frame | ab1 run 0 | ab1 run 1 | |---|---|---|---| | village | 1.92 | 1.66 | 1.81 | | forest | 2.07 | 1.81 | 1.92 | | ocean | 2.03 | 1.93 | 1.95 | | mountain | 2.67 | 2.42 | 2.46 | This PR's share is the scan the sample found: it grows with the number of block entities loaded, so with render distance. I didn't measure RD 8/16. Boxes draw exactly as before: the same blocks, in the same order of positions. ### Checks **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at dea6dea98, 36 min 58 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +81 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 586 passed (1 min 15 s) | | rustfmt | ✅ (15 s) | | clippy | ✅ (1 min 49 s) | | tests: horizon-client, horizon-client-render | ❌ 1198 passed, 1 failed (32 min 26 s) | | doc tests | ✅ 0 passed (4 s) | | Parity | ➖ 127 affected, to run in CI (--quick) | The one failure, `entities::armor_stand_motion_tests::a_tick_keeps_the_previous_position_for_interpolation`, also fails on main where `.local` data is present (CI skips it). This change doesn't touch it. 🤖 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:31:04 +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#6990
No description provided.