[PR #7433] [MERGED] Far teleports forget their columns in one sweep (teleport frame 6-13 ms -> ~3 ms of CPU) #7603

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

📋 Pull Request Information

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

Base: main ← Head: perf/teleport-sweep


📝 Commits (1)

  • 360725a perf: a far teleport's forgotten columns leave in one sweep

📊 Changes

4 files changed (+173 additions, -38 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/arena.rs (+46 -6)
📝 crates/horizon-client-render/src/gfx/resident.rs (+23 -1)
📝 crates/horizon-client-render/src/streaming.rs (+97 -14)
📝 crates/horizon-client/src/game/remote.rs (+7 -17)

📄 Description

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

What

At render distance 32, a far teleport (/tp, an ender pearl into unloaded terrain, a portal) makes the client forget every column it holds: ~3,700 columns and ~27,000 resident sections, all in one frame, inside poll_remote. After #6898 that frame still spent 6–13 ms of CPU there on an M4 Pro. Measured step by step (temporary timers, not in this PR):

Step (3,725 columns, 26,843 sections) before after
Streaming forgetting the columns (80,000 compile_started entries filtered) 1.6–1.9 ms 0.1 ms
Resident::remove_columns (a lookup and a re-insert per section) 1.9 ms 0.3 ms
Arena::release_all (27,000 ranges sorted into the free lists) 1.0 ms 0.3 ms
  • Streaming::forget_columns forgets the columns together. When no held column is left, which is the case after a far teleport, the pending-section maps are cleared instead of filtered. This brings back the batched forget from perf/teleport-forget, where the clear was missing; Streaming::forget had no caller left and is removed.
  • Resident::remove_columns empties itself when every column goes.
  • Arena::release_all resets a page when every one of its ranges comes back, instead of sorting tens of thousands of ranges into its free list.

The partial cases (a few columns, a page that keeps ranges) keep their old paths.

A/B (Mac mini M4 Pro, RD 32, offscreen 1920×1080, pacing_bench teleport scenario, alternated)

The Mac's load average was 300–570 during these runs (other sessions' builds), so worst frames and 1%/0.1% lows were scheduler noise (30–220 ms frames with ≤ 1 ms of CPU on both sides). The comparison is the render thread's CPU in poll_remote on the teleport frame, from the HORIZON_SPIKES lines:

main 4956321f71 this PR
Single player (server thread), 5 / 3 runs 6.6, 9.1, 10.9, 8.9, 13.0 ms under the 5 ms log threshold in 3/3; 3.1 ms at a 2 ms threshold
Guest on a dedicated server (/tp in chat), 2 pairs 10.1, 8.6 ms 2.9, 2.9 ms

Tests

  • ranges_released_at_once_free_exactly_their_vertices (arena, on a device): a page whose ranges all come back holds one free range and takes a page-sized range without growing; a page that keeps some frees only the rest.
  • slots_and_columns_follow_inserts_and_removals (Resident's model test) now also removes every column at once and checks the store is empty.
  • forgotten_columns_lose_their_pending_sections_either_way covers the partial forget, by key or by pass.

pr_ready

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at 4956321f7, 17 min 55 s)

Check Result
Scope ✅ 4 files, +173 −38
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (1 min 40 s)
rustfmt ✅ (16 s)
clippy ✅ (3 min 39 s)
tests: horizon-client, horizon-client-render ✅ 1854 passed (10 min 46 s)
doc tests ✅ 0 passed (5 s)
content root tests ➖ content root untouched
mod API up to date ✅ (48 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 141 affected, to run in CI (--quick): ambient_sound, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers and 129 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The render lib tests also pass single-threaded on playhorizon (1158 passed).

🤖 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/7433 **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/teleport-sweep` --- ### 📝 Commits (1) - [`360725a`](https://github.com/horizon-rust/horizon/commit/360725a0ee0ad7d2a4dca92e9b46cecacbe6546f) perf: a far teleport's forgotten columns leave in one sweep ### 📊 Changes **4 files changed** (+173 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/arena.rs` (+46 -6) 📝 `crates/horizon-client-render/src/gfx/resident.rs` (+23 -1) 📝 `crates/horizon-client-render/src/streaming.rs` (+97 -14) 📝 `crates/horizon-client/src/game/remote.rs` (+7 -17) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What At render distance 32, a far teleport (`/tp`, an ender pearl into unloaded terrain, a portal) makes the client forget every column it holds: ~3,700 columns and ~27,000 resident sections, all in one frame, inside `poll_remote`. After #6898 that frame still spent 6–13 ms of CPU there on an M4 Pro. Measured step by step (temporary timers, not in this PR): | Step (3,725 columns, 26,843 sections) | before | after | |---|---|---| | `Streaming` forgetting the columns (80,000 `compile_started` entries filtered) | 1.6–1.9 ms | 0.1 ms | | `Resident::remove_columns` (a lookup and a re-insert per section) | 1.9 ms | 0.3 ms | | `Arena::release_all` (27,000 ranges sorted into the free lists) | 1.0 ms | 0.3 ms | - `Streaming::forget_columns` forgets the columns together. When no held column is left, which is the case after a far teleport, the pending-section maps are cleared instead of filtered. This brings back the batched forget from `perf/teleport-forget`, where the clear was missing; `Streaming::forget` had no caller left and is removed. - `Resident::remove_columns` empties itself when every column goes. - `Arena::release_all` resets a page when every one of its ranges comes back, instead of sorting tens of thousands of ranges into its free list. The partial cases (a few columns, a page that keeps ranges) keep their old paths. ## A/B (Mac mini M4 Pro, RD 32, offscreen 1920×1080, `pacing_bench` teleport scenario, alternated) The Mac's load average was 300–570 during these runs (other sessions' builds), so worst frames and 1%/0.1% lows were scheduler noise (30–220 ms frames with ≤ 1 ms of CPU on both sides). The comparison is the render thread's CPU in `poll_remote` on the teleport frame, from the `HORIZON_SPIKES` lines: | | main 4956321f71 | this PR | |---|---|---| | Single player (server thread), 5 / 3 runs | 6.6, 9.1, 10.9, 8.9, 13.0 ms | under the 5 ms log threshold in 3/3; 3.1 ms at a 2 ms threshold | | Guest on a dedicated server (`/tp` in chat), 2 pairs | 10.1, 8.6 ms | 2.9, 2.9 ms | ## Tests - `ranges_released_at_once_free_exactly_their_vertices` (arena, on a device): a page whose ranges all come back holds one free range and takes a page-sized range without growing; a page that keeps some frees only the rest. - `slots_and_columns_follow_inserts_and_removals` (Resident's model test) now also removes every column at once and checks the store is empty. - `forgotten_columns_lose_their_pending_sections_either_way` covers the partial forget, by key or by pass. ## pr_ready **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at 4956321f7, 17 min 55 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +173 −38 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (1 min 40 s) | | rustfmt | ✅ (16 s) | | clippy | ✅ (3 min 39 s) | | tests: horizon-client, horizon-client-render | ✅ 1854 passed (10 min 46 s) | | doc tests | ✅ 0 passed (5 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (48 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 141 affected, to run in CI (--quick): ambient_sound, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, audio_attributes, auto_jump, blending, block_entity_anim, block_entity_render, block_entity_tickers and 129 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The render lib tests also pass single-threaded on playhorizon (1158 passed). 🤖 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 07:20:37 +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#7603
No description provided.