[PR #1977] [MERGED] Collision scans: skip the outer cells of sections no block reaches out of #3905

Closed
opened 2026-11-03 04:13:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: perf/collision-scan-edges


📝 Commits (3)

  • 4459f13 Collision scans: skip the outer cells of sections no block reaches out of
  • a013e35 Collision scans: pass the rest of an outer row in a contained section at once
  • 1fd42f3 Merge remote-tracking branch 'origin/main' into perf/collision-scan-edges

📊 Changes

4 files changed (+201 additions, -28 deletions)

View changed files

📝 crates/horizon-client/src/collisions.rs (+18 -0)
📝 crates/horizon-world/src/block_collision.rs (+7 -0)
📝 crates/horizon-world/src/block_collision_scan.rs (+65 -1)
📝 crates/horizon-world/tests/block_collision_scan.rs (+111 -27)

📄 Description

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

A block-collision scan (mobs, dropped items, players) no longer reads the cells around the box in sections where no block can reach out of its cell.

Vanilla's BlockCollisions walks Cursor3D over the box grown by one block. On the outer cells (Cursor3D types 1 and 2: faces and edges of that shell) it keeps a block only if the block has a large collision shape or is a moving piston; corners (type 3) are skipped. Horizon's BlockCollisionScan already followed that order, but read every outer cell's state to find out. Most sections hold none of those blocks in their palette, so the scan now asks the provider once per section (may_reach_out, answered from the section's palette with the binding's existing scan_flags) and passes those cells without reading them. Along the bottom, top and side rows every cell is outer, so the rest of the row up to the chunk's edge is passed in one step.

The hits and their order are unchanged, and the candidate budget still ends the scan at the same cell: passed cells count toward it. Two new tests check this: a recording provider compares the cells read against vanilla's rule with sections marked contained, including a box across a chunk edge, and a budget test checks the scan stops at the same index.

Measured

ThinkPad (i5-7200U, 4 threads), dedicated server, server_bench --servers horizon --bots 10 --behaviour walk --warmup 60 --seconds 120 --gamerule locator_bar=false, with perf stat -e instructions:u --per-thread on the server's tick thread over 60 s of the measured window. Main at 781b7b87 vs this branch on the same base, alternated.

main this branch
tick thread instructions, 60 s 34.19 G / 33.77 G 31.84 G / 31.48 G
PalettedContainer::get under the collision scan (perf record, share of the tick thread) 5.44% 0.84%
MSPT average 13.97 / 15.08 11.53 / 14.61

−7.3% instructions on the tick thread. Wall MSPT moved the same way but the machine was not quiet (1-minute load 3-6 from a build in another session), so the instruction count is the number to trust. Collision scans were ~17% of the tick thread before (7.7% the scan loop, 5.4% palette reads).

Gameplay paths: the scan is shared by the in-frame path, the server thread and the dedicated server (one BlockCollisionScan, called from collisions.rs), and parity.py --changed origin/main selected 56 harnesses for these files, all passing (the block's "6 passed" is the rerun; the other 50 passed in the first run, before its 2-hour wrapper limit).

Self-check

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at 7fd1f3118, 35 min 30 s)

Check Result
Scope ✅ 4 files, +201 −28
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (16 s)
clippy ✅ (2 min 6 s)
tests: horizon-client, horizon-world ✅ 1480 passed (15 min 49 s)
doc tests ✅ 0 passed (12 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 319 affected, 6 passed (16 min 55 s)

Run before merging main at 1fd42f311 (no conflict, none of these files changed on main).

🤖 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/1977 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/collision-scan-edges` --- ### 📝 Commits (3) - [`4459f13`](https://github.com/horizon-rust/horizon/commit/4459f132fe481be02ed0c2a2e2e41b7666ba3dbe) Collision scans: skip the outer cells of sections no block reaches out of - [`a013e35`](https://github.com/horizon-rust/horizon/commit/a013e35a61f3d888f141364ab5e04f13fbb1a842) Collision scans: pass the rest of an outer row in a contained section at once - [`1fd42f3`](https://github.com/horizon-rust/horizon/commit/1fd42f311f9d2270f859b7a5c33fc30dd4de1ade) Merge remote-tracking branch 'origin/main' into perf/collision-scan-edges ### 📊 Changes **4 files changed** (+201 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/collisions.rs` (+18 -0) 📝 `crates/horizon-world/src/block_collision.rs` (+7 -0) 📝 `crates/horizon-world/src/block_collision_scan.rs` (+65 -1) 📝 `crates/horizon-world/tests/block_collision_scan.rs` (+111 -27) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. A block-collision scan (mobs, dropped items, players) no longer reads the cells around the box in sections where no block can reach out of its cell. Vanilla's `BlockCollisions` walks `Cursor3D` over the box grown by one block. On the outer cells (Cursor3D types 1 and 2: faces and edges of that shell) it keeps a block only if the block has a large collision shape or is a moving piston; corners (type 3) are skipped. Horizon's `BlockCollisionScan` already followed that order, but read every outer cell's state to find out. Most sections hold none of those blocks in their palette, so the scan now asks the provider once per section (`may_reach_out`, answered from the section's palette with the binding's existing `scan_flags`) and passes those cells without reading them. Along the bottom, top and side rows every cell is outer, so the rest of the row up to the chunk's edge is passed in one step. The hits and their order are unchanged, and the candidate budget still ends the scan at the same cell: passed cells count toward it. Two new tests check this: a recording provider compares the cells read against vanilla's rule with sections marked contained, including a box across a chunk edge, and a budget test checks the scan stops at the same index. ## Measured ThinkPad (i5-7200U, 4 threads), dedicated server, `server_bench --servers horizon --bots 10 --behaviour walk --warmup 60 --seconds 120 --gamerule locator_bar=false`, with `perf stat -e instructions:u --per-thread` on the server's tick thread over 60 s of the measured window. Main at 781b7b87 vs this branch on the same base, alternated. | | main | this branch | |---|---|---| | tick thread instructions, 60 s | 34.19 G / 33.77 G | 31.84 G / 31.48 G | | `PalettedContainer::get` under the collision scan (`perf record`, share of the tick thread) | 5.44% | 0.84% | | MSPT average | 13.97 / 15.08 | 11.53 / 14.61 | −7.3% instructions on the tick thread. Wall MSPT moved the same way but the machine was not quiet (1-minute load 3-6 from a build in another session), so the instruction count is the number to trust. Collision scans were ~17% of the tick thread before (7.7% the scan loop, 5.4% palette reads). Gameplay paths: the scan is shared by the in-frame path, the server thread and the dedicated server (one `BlockCollisionScan`, called from `collisions.rs`), and `parity.py --changed origin/main` selected 56 harnesses for these files, all passing (the block's "6 passed" is the rerun; the other 50 passed in the first run, before its 2-hour wrapper limit). ## Self-check **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at 7fd1f3118, 35 min 30 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +201 −28 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (16 s) | | clippy | ✅ (2 min 6 s) | | tests: horizon-client, horizon-world | ✅ 1480 passed (15 min 49 s) | | doc tests | ✅ 0 passed (12 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 319 affected, 6 passed (16 min 55 s) | Run before merging main at 1fd42f311 (no conflict, none of these files changed on main). 🤖 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 04:13:10 +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#3905
No description provided.