[PR #3466] [MERGED] Renderer: empty the sparsest vertex arena page so video memory comes back #5000

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3466
Author: @AHHhHHHHH-H
Created: 10/29/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: pr/vram-arena-compaction


📝 Commits (7)

  • ff74eaf Renderer: empty the sparsest vertex arena page so video memory comes back
  • c58e27e Merge origin/main into triage-3466
  • 52b5043 Merge remote-tracking branch 'origin/main' into pr3466
  • dd00a69 Arena compaction: keep an emptied page closed until trim, never move into system memory
  • 2313de0 Merge remote-tracking branch 'origin/main' into t3466
  • db22303 Merge main into #3466
  • b6044ea Arena compaction: move LOD stand-in meshes off the closing page too

📊 Changes

4 files changed (+260 additions, -10 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+59 -0)
📝 crates/horizon-client-render/src/gfx/arena.rs (+194 -10)
📝 crates/horizon-client-render/src/gfx/lod.rs (+4 -0)
📝 crates/horizon-client-render/src/gfx/resident.rs (+3 -0)

📄 Description

🤖 Opened by AHHhHHHHH-H's AI agent (Claude Code), not by AHHhHHHHH-H themselves.

What and why

The terrain vertex arena only gave a page back once every range in it was free. After a render distance change, or with far tiles replaced as the player moves, it kept pages that were mostly empty: in a test with render distance 32 then 8 (1080p, LOD 1024, 2 GiB GPU; one run each) the arena stayed at 1887 MB while only 480 MB was live, the 2 GiB card spilled to system memory and a flight ran at 21 FPS (p99 68.6 ms, GPU 45 ms).

When at least 128 MiB and half of the arena is free ranges, the renderer now closes the sparsest page (nothing new goes in it), copies its meshes into the other pages' free ranges (32 MiB of GPU copies a frame), and Arena::trim frees the page once empty. Same test after: arena 863 MB (480 MB live), 57 FPS, p99 34.9 ms, GPU 16 ms. One run each on a noisy 2 GiB card, so treat the frame numbers as indicative.

New: Arena::{sparsest, close, reopen, closing, copy, alloc_existing}, Resident::values_mut, Renderer::compact_arena, and a GPU test that empties a page, checks the data moved intact and the page is freed.

Possible overlap: none found among open PRs.

Vanilla reference

Horizon-only (renderer memory management).

Self-check

pr_ready (tools/pr_ready.py --quick on a local machine, against origin/main at c6af85743, 3 min 13 s)

Check Result
Scope ✅ 3 files, +225 −6
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 408 passed (40 s)
rustfmt ✅ (8 s)
clippy ❌ failed (17 s)
tests: horizon-client ❌ failed (1 min 29 s)
doc tests ✅ 0 passed (39 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

On this machine (GTX 750, Rust 1.97.1) the block above shows two failures that are not caused by this change:

  • clippy stops in horizon-world (manual_range_contains, worldgen/aquifer/noise_based.rs:450), a file this PR does not touch, so horizon-client is never linted by that run. cargo clippy -p horizon-client --all-targets -- -D warnings -A clippy::manual_range_contains is clean.
  • horizon-client tests die with SIGSEGV in a different GPU test each run on the NVIDIA driver. With the software Vulkan driver (VK_DRIVER_FILES=.../lvp_icd.x86_64.json) cargo test -p horizon-client passes: 1120 lib tests + the integration tests, 0 failed.

CI is the authority; I have not run the vanilla parity harnesses (--quick).

🤖 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/3466 **Author:** [@AHHhHHHHH-H](https://github.com/AHHhHHHHH-H) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `pr/vram-arena-compaction` --- ### 📝 Commits (7) - [`ff74eaf`](https://github.com/horizon-rust/horizon/commit/ff74eaf087d660eca54c6eb46d49ede2f182e339) Renderer: empty the sparsest vertex arena page so video memory comes back - [`c58e27e`](https://github.com/horizon-rust/horizon/commit/c58e27ef3f06bf6de9b483279b10db206aba125b) Merge origin/main into triage-3466 - [`52b5043`](https://github.com/horizon-rust/horizon/commit/52b504316796560264a76a8d358744bfc4396bbf) Merge remote-tracking branch 'origin/main' into pr3466 - [`dd00a69`](https://github.com/horizon-rust/horizon/commit/dd00a69445121ccf10e289d3b2207c5b239185e9) Arena compaction: keep an emptied page closed until trim, never move into system memory - [`2313de0`](https://github.com/horizon-rust/horizon/commit/2313de06a842b342657af173dfce721f4a474474) Merge remote-tracking branch 'origin/main' into t3466 - [`db22303`](https://github.com/horizon-rust/horizon/commit/db22303b9e96fb31d48fd70f9399e6d6d6723357) Merge main into #3466 - [`b6044ea`](https://github.com/horizon-rust/horizon/commit/b6044ea5f27618a83fd47b22ba15b58bc2bf4b27) Arena compaction: move LOD stand-in meshes off the closing page too ### 📊 Changes **4 files changed** (+260 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+59 -0) 📝 `crates/horizon-client-render/src/gfx/arena.rs` (+194 -10) 📝 `crates/horizon-client-render/src/gfx/lod.rs` (+4 -0) 📝 `crates/horizon-client-render/src/gfx/resident.rs` (+3 -0) </details> ### 📄 Description > 🤖 Opened by AHHhHHHHH-H's AI agent (Claude Code), not by AHHhHHHHH-H themselves. ## What and why The terrain vertex arena only gave a page back once every range in it was free. After a render distance change, or with far tiles replaced as the player moves, it kept pages that were mostly empty: in a test with render distance 32 then 8 (1080p, LOD 1024, 2 GiB GPU; one run each) the arena stayed at 1887 MB while only 480 MB was live, the 2 GiB card spilled to system memory and a flight ran at 21 FPS (p99 68.6 ms, GPU 45 ms). When at least 128 MiB and half of the arena is free ranges, the renderer now closes the sparsest page (nothing new goes in it), copies its meshes into the other pages' free ranges (32 MiB of GPU copies a frame), and `Arena::trim` frees the page once empty. Same test after: arena 863 MB (480 MB live), 57 FPS, p99 34.9 ms, GPU 16 ms. One run each on a noisy 2 GiB card, so treat the frame numbers as indicative. New: `Arena::{sparsest, close, reopen, closing, copy, alloc_existing}`, `Resident::values_mut`, `Renderer::compact_arena`, and a GPU test that empties a page, checks the data moved intact and the page is freed. Possible overlap: none found among open PRs. ## Vanilla reference Horizon-only (renderer memory management). ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on a local machine, against origin/main at c6af85743, 3 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +225 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 408 passed (40 s) | | rustfmt | ✅ (8 s) | | clippy | ❌ failed (17 s) | | tests: horizon-client | ❌ failed (1 min 29 s) | | doc tests | ✅ 0 passed (39 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | On this machine (GTX 750, Rust 1.97.1) the block above shows two failures that are not caused by this change: - clippy stops in `horizon-world` (`manual_range_contains`, `worldgen/aquifer/noise_based.rs:450`), a file this PR does not touch, so `horizon-client` is never linted by that run. `cargo clippy -p horizon-client --all-targets -- -D warnings -A clippy::manual_range_contains` is clean. - `horizon-client` tests die with SIGSEGV in a different GPU test each run on the NVIDIA driver. With the software Vulkan driver (`VK_DRIVER_FILES=.../lvp_icd.x86_64.json`) `cargo test -p horizon-client` passes: 1120 lib tests + the integration tests, 0 failed. CI is the authority; I have not run the vanilla parity harnesses (`--quick`). 🤖 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 05:09:30 +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#5000
No description provided.