[PR #6898] [MERGED] Drop a far teleport's chunk columns at once: 16 → 7 ms frame at render distance 32 #7179

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

📋 Pull Request Information

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

Base: main ← Head: perf/bulk-remove-columns


📝 Commits (3)

  • 86f802c Drop a teleport's chunk columns at once: a 10 ms frame at render distance 32
  • 2a5da68 Resident test: build the column set with collect
  • 89edb46 rustfmt

📊 Changes

3 files changed (+109 additions, -13 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+47 -0)
📝 crates/horizon-client-render/src/gfx/resident.rs (+35 -2)
📝 crates/horizon-client/src/game/remote.rs (+27 -11)

📄 Description

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

A far teleport at render distance 32 cost one frame 14–17 ms of render-thread CPU on an M4 Pro (so 30–50 ms on a mid-range PC). The server moves its chunk centre (SetChunkCacheCenter) and the client drops most of its view at once: ~3,700 columns, 27k resident sections.

Where the time went (HORIZON_SPIKES laps, RD 32 teleports):

  • Renderer::remove_columns: 10.6 ms for 3,725 columns. For every section key of every column it looked up 4 maps, then Resident::removed resident sections one by one (each a slot move, a column lookup and a scan). All of those are cache misses.
  • Then the server's ForgetLevelChunk burst (700–3,000 packets) did it again per column, plus a pass over every block entity per packet: 1–5 ms more in the next frames.

Change

  • remove_columns filters each store once (retain by column, and Resident::remove_columns rebuilds the dense list) when the columns hold at least as many section keys as there are resident sections. The per-key path stays for small removals (walking across a chunk border) and whenever far terrain fades sections out.
  • The released sections (their sort centres) drop on the existing "Buffer freeing" thread when there are many.
  • poll_remote forgets a run of consecutive ForgetLevelChunk packets at once, before the next packet whatever it is, so the packet order is unchanged. It reuses the batch helper of the centre change.

A/B (Mac mini M4 Pro, 1280×720 offscreen, RD 32, tools/pacing_bench.py, main 848a87b73 vs this branch, alternated ×3, GPU lock held; the Mac is shared and GPU-bound, so frame columns are GPU noise, and the render-thread CPU columns are the measure):

scenario build p50 p99 p99.9 max 1% low 0.1% low >33 ms CPU p99.9 CPU max (3 runs)
teleport main 0.20 3.69 6.27 16.2 209 105 0 3.57 16.8 / 15.9 / 14.1
teleport this PR 0.19 4.59 7.41 16.5 176 104 0 3.46 7.5 / 9.8 / 7.4
nether main 0.71 2.91 7.32 16.9 232 96 0 3.82 8.7 / 8.0 / 6.4
nether this PR 0.70 2.97 7.26 12.8 229 106 0 3.99 6.4 / 10.3 / 9.1
portal main 0.41 3.01 6.47 13.9 243 118 0 4.04 8.0 / 7.8 / 6.1
portal this PR 0.35 2.53 4.86 12.7 270 126 0 3.30 5.2 / 5.0 / 7.5

(ms; lows in FPS.) The worst update_world among the teleport frames went from 16.1 ms to 7.2 ms. With laps on this branch, the slowest teleport frame is now ~6 ms: rebuilding the store takes 2 ms, releasing arena ranges 0.9 ms and Streaming::forget 1.7 ms.

Tests: the randomised Resident test now also drops whole columns and checks slots, columns and bounds against the model.

Overlap: #6323 changes the same streaming.forget calls (to forget_remote_chunk). Whichever lands second calls it from forget_remote_columns.

pr_ready: the ❌ on the tests row is the horizon-client-render lib tests crashing with SIGSEGV in parallel on playhorizon. Main 848a87b73 does the same (2 crashes in 3 parallel runs). Single-threaded, this branch passes 1048/1048 and main 1049/1049. The horizon-client tests pass.

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at 848a87b73, 8 min 28 s)

Check Result
Scope ✅ 3 files, +109 −13
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 607 passed (1 min 14 s)
rustfmt ✅ (16 s)
clippy ✅ (3 min 11 s)
tests: horizon-client, horizon-client-render ❌ 606 passed (2 min 44 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
mod API up to date ✅ (28 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 137 affected, to run in CI (--quick): ambient_sound, armor_stand_frost, arrow, arrow_wind_charge, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal and 125 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/6898 **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/bulk-remove-columns` --- ### 📝 Commits (3) - [`86f802c`](https://github.com/horizon-rust/horizon/commit/86f802cac7d1d3f4d8fbddab2aa46a6eadd28030) Drop a teleport's chunk columns at once: a 10 ms frame at render distance 32 - [`2a5da68`](https://github.com/horizon-rust/horizon/commit/2a5da686743ed4f4265f6357ff6c4a0580db3bc1) Resident test: build the column set with collect - [`89edb46`](https://github.com/horizon-rust/horizon/commit/89edb463b0fec650bfdee3fffcb785b15247b9b3) rustfmt ### 📊 Changes **3 files changed** (+109 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+47 -0) 📝 `crates/horizon-client-render/src/gfx/resident.rs` (+35 -2) 📝 `crates/horizon-client/src/game/remote.rs` (+27 -11) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. A far teleport at render distance 32 cost one frame 14–17 ms of render-thread CPU on an M4 Pro (so 30–50 ms on a mid-range PC). The server moves its chunk centre (`SetChunkCacheCenter`) and the client drops most of its view at once: ~3,700 columns, 27k resident sections. **Where the time went** (HORIZON_SPIKES laps, RD 32 teleports): - `Renderer::remove_columns`: 10.6 ms for 3,725 columns. For every section key of every column it looked up 4 maps, then `Resident::remove`d resident sections one by one (each a slot move, a column lookup and a scan). All of those are cache misses. - Then the server's `ForgetLevelChunk` burst (700–3,000 packets) did it again per column, plus a pass over every block entity per packet: 1–5 ms more in the next frames. **Change** - `remove_columns` filters each store once (`retain` by column, and `Resident::remove_columns` rebuilds the dense list) when the columns hold at least as many section keys as there are resident sections. The per-key path stays for small removals (walking across a chunk border) and whenever far terrain fades sections out. - The released sections (their sort centres) drop on the existing "Buffer freeing" thread when there are many. - `poll_remote` forgets a run of consecutive `ForgetLevelChunk` packets at once, before the next packet whatever it is, so the packet order is unchanged. It reuses the batch helper of the centre change. **A/B** (Mac mini M4 Pro, 1280×720 offscreen, RD 32, `tools/pacing_bench.py`, main 848a87b73 vs this branch, alternated ×3, GPU lock held; the Mac is shared and GPU-bound, so frame columns are GPU noise, and the render-thread CPU columns are the measure): | scenario | build | p50 | p99 | p99.9 | max | 1% low | 0.1% low | >33 ms | CPU p99.9 | CPU max (3 runs) | |---|---|---|---|---|---|---|---|---|---|---| | teleport | main | 0.20 | 3.69 | 6.27 | 16.2 | 209 | 105 | 0 | 3.57 | 16.8 / 15.9 / 14.1 | | teleport | this PR | 0.19 | 4.59 | 7.41 | 16.5 | 176 | 104 | 0 | 3.46 | 7.5 / 9.8 / 7.4 | | nether | main | 0.71 | 2.91 | 7.32 | 16.9 | 232 | 96 | 0 | 3.82 | 8.7 / 8.0 / 6.4 | | nether | this PR | 0.70 | 2.97 | 7.26 | 12.8 | 229 | 106 | 0 | 3.99 | 6.4 / 10.3 / 9.1 | | portal | main | 0.41 | 3.01 | 6.47 | 13.9 | 243 | 118 | 0 | 4.04 | 8.0 / 7.8 / 6.1 | | portal | this PR | 0.35 | 2.53 | 4.86 | 12.7 | 270 | 126 | 0 | 3.30 | 5.2 / 5.0 / 7.5 | (ms; lows in FPS.) The worst `update_world` among the teleport frames went from 16.1 ms to 7.2 ms. With laps on this branch, the slowest teleport frame is now ~6 ms: rebuilding the store takes 2 ms, releasing arena ranges 0.9 ms and `Streaming::forget` 1.7 ms. **Tests:** the randomised `Resident` test now also drops whole columns and checks slots, columns and bounds against the model. **Overlap:** #6323 changes the same `streaming.forget` calls (to `forget_remote_chunk`). Whichever lands second calls it from `forget_remote_columns`. **pr_ready:** the ❌ on the tests row is the `horizon-client-render` lib tests crashing with SIGSEGV in parallel on playhorizon. Main 848a87b73 does the same (2 crashes in 3 parallel runs). Single-threaded, this branch passes 1048/1048 and main 1049/1049. The `horizon-client` tests pass. **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at 848a87b73, 8 min 28 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +109 −13 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 607 passed (1 min 14 s) | | rustfmt | ✅ (16 s) | | clippy | ✅ (3 min 11 s) | | tests: horizon-client, horizon-client-render | ❌ 606 passed (2 min 44 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (28 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 137 affected, to run in CI (--quick): ambient_sound, armor_stand_frost, arrow, arrow_wind_charge, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal and 125 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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:35: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#7179
No description provided.