[PR #1258] [MERGED] Section walk: no per-section frustum test in columns entirely inside (-11% walk at RD 32) #3462

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

📋 Pull Request Information

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

Base: main ← Head: perf/frustum-inside-columns


📝 Commits (1)

  • 8b16f76 Section walk: no per-section frustum test in columns entirely inside

📊 Changes

2 files changed (+75 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+14 -0)
📝 crates/horizon-client/src/gfx/resident.rs (+61 -9)

📄 Description

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

Part of the frame-cost batch (Kira card #23).

What

Resident::visible already tests each column's box against the frustum before its sections. It now also checks whether that box lies entirely inside the frustum (Frustum::contains). If it does, the column's sections skip their own frustum test, because none of them can fail it. Each plane's distance only grows from the column box's nearest corner to a section box's farthest corner, and f32 rounding keeps that order. This is the same argument the existing rejection test relies on.

Why

After #1239, the section walk (visibility span) is the largest render-thread cost on the ThinkPad at render distance 32: 23.5% of the thread at the overview view. That is the walk itself, 5.9% of frustum tests and 5.0% of sorting. At RD 32 most columns are farther away than the distance at which the vertical field of view takes in their whole height, so most of the per-section tests were redundant.

Before / after

ThinkPad: i5 Kaby Lake-U, HD 620, Mesa 26.1.8 Vulkan, 1280×720 offscreen. main b88218d0 against this branch. perf record at RD 32, overview view, 8 s, render thread:

main this branch
section walk (the visibility closure), samples 1606 1426 (−11%)
per frame 1.56 ms 1.37 ms
frustum tests (intersects + contains) 408 105 + 164

The interleaved frame-time runs (2 rounds, RD 16 and 32, 3 views; ab-walk.jsonl) don't separate a 0.2 ms change from the noise of the shared machine: perf-server-14 was running server benchmarks between our runs. On this main, the span measurement patch no longer applied, so there are no span columns.

Parity

  • The list of drawn sections is unchanged, in content and in order. column_walk_finds_exactly_the_sections_in_view compares the walk with a per-section test for every resident section. The new columns_entirely_inside_skip_no_section does the same for a layout where more than 50 columns lie entirely inside (and some don't), and asserts that this happens.
  • Because the draw list is identical, the frames are identical by construction. No screenshot comparison was run.

How tested (Mac mini M4 Pro)

  • cargo fmt --all --check: ok
  • cargo clippy --workspace --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --lib: 996 passed, 0 failed.
  • tools/parity.py --changed origin/main: 102 passed, 0 failed (on b88218d0; since rebased on main without conflicts)

Data: ~/code/horizon-parity/shots/perf-frame-12/ (q-{mainb,walk}-32.folded, ab-walk.jsonl).

What is left in the walk

Sorting the visible sections (5% of the thread) and the reachability lookups in Occlusion::contains for each section.

Label: skip-release (a small frame-time change with no visible difference).

🤖 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/1258 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/frustum-inside-columns` --- ### 📝 Commits (1) - [`8b16f76`](https://github.com/horizon-rust/horizon/commit/8b16f76b3c1f17d12c1b2bd5e1ed85c44a10e361) Section walk: no per-section frustum test in columns entirely inside ### 📊 Changes **2 files changed** (+75 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+14 -0) 📝 `crates/horizon-client/src/gfx/resident.rs` (+61 -9) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of the frame-cost batch (Kira card #23). ## What `Resident::visible` already tests each column's box against the frustum before its sections. It now also checks whether that box lies **entirely** inside the frustum (`Frustum::contains`). If it does, the column's sections skip their own frustum test, because none of them can fail it. Each plane's distance only grows from the column box's nearest corner to a section box's farthest corner, and f32 rounding keeps that order. This is the same argument the existing rejection test relies on. ## Why After #1239, the section walk (`visibility` span) is the largest render-thread cost on the ThinkPad at render distance 32: 23.5% of the thread at the overview view. That is the walk itself, 5.9% of frustum tests and 5.0% of sorting. At RD 32 most columns are farther away than the distance at which the vertical field of view takes in their whole height, so most of the per-section tests were redundant. ## Before / after **ThinkPad**: i5 Kaby Lake-U, HD 620, Mesa 26.1.8 Vulkan, 1280×720 offscreen. `main` b88218d0 against this branch. `perf record` at RD 32, overview view, 8 s, render thread: | | main | this branch | |---|---|---| | section walk (the `visibility` closure), samples | 1606 | 1426 (−11%) | | per frame | 1.56 ms | 1.37 ms | | frustum tests (`intersects` + `contains`) | 408 | 105 + 164 | The interleaved frame-time runs (2 rounds, RD 16 and 32, 3 views; `ab-walk.jsonl`) don't separate a 0.2 ms change from the noise of the shared machine: perf-server-14 was running server benchmarks between our runs. On this main, the span measurement patch no longer applied, so there are no span columns. ## Parity - The list of drawn sections is unchanged, in content and in order. `column_walk_finds_exactly_the_sections_in_view` compares the walk with a per-section test for every resident section. The new `columns_entirely_inside_skip_no_section` does the same for a layout where more than 50 columns lie entirely inside (and some don't), and asserts that this happens. - Because the draw list is identical, the frames are identical by construction. No screenshot comparison was run. ## How tested (Mac mini M4 Pro) - `cargo fmt --all --check`: ok - `cargo clippy --workspace --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --lib`: 996 passed, 0 failed. - `tools/parity.py --changed origin/main`: **102 passed, 0 failed** (on b88218d0; since rebased on main without conflicts) Data: `~/code/horizon-parity/shots/perf-frame-12/` (`q-{mainb,walk}-32.folded`, `ab-walk.jsonl`). ## What is left in the walk Sorting the visible sections (5% of the thread) and the reachability lookups in `Occlusion::contains` for each section. Label: `skip-release` (a small frame-time change with no visible difference). 🤖 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:09:43 +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#3462
No description provided.