[PR #6419] [MERGED] Video memory in 8-64 MiB blocks: half the reserved VRAM was unused (−634 MiB VRAM) #6857

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

📋 Pull Request Information

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

Base: main ← Head: mem-vram-memory-hints


📝 Commits (1)

  • 745fafe Video memory in 8-64 MiB blocks: half the reserved VRAM was unused

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+4 -0)

📄 Description

🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally.

Part of #6418.

What

The device was opened with wgpu's default MemoryHints::Performance: its allocator (gpu-allocator, on Vulkan and DirectX 12) takes video memory in blocks of 128 to 256 MiB and sub-allocates buffers and textures in them. A block is only given back once empty, and the section arena's pages come and go as it grows: a page freed from a 256 MiB block leaves the block alive for a few small buffers placed beside it (the occlusion culler's 0.2 MiB "Section ids by block", for one). After the forest flight below, the allocator held 1,344 MiB for 500 MiB in use: one 256 MiB block with 0.2 MiB in it, another with 42 MiB, a 64 MiB host block holding a few readback buffers.

MemoryHints::MemoryUsage takes blocks of 8 to 64 MiB (wgpu-hal's AllocationSizes). Larger resources (the arena's pages, the 80 MiB GUI atlas) get memory of their own, freed with them. One line in gfx.rs; Metal and OpenGL don't use these hints.

Measured

How it was measured. Arch Linux (zen kernel), Ryzen 5 5600X (12 threads), 32 GB, RTX 4060 8 GB (Vulkan, NVIDIA 615.78), --profile fast, --offscreen 1280x720, fresh scratch homes per start, render distance 12. A start goes to the title screen, creates the perf_bench world (seed 1234, creative), waits for spawn to load, then teleports to and flies tools/perf_bench.py's village and forest paths (12 s each) and samples after each. Video memory: what nvidia-smi attributes to the process, and the game's own allocator totals (status: gpu_allocated_bytes / gpu_reserved_bytes); RSS from /proc/<pid>/status. Three alternated starts per build, medians (range in brackets); main = dea6dea98.

main this PR
video memory, title screen (nvidia-smi) 520 MiB 206 MiB (−314)
video memory after the flights (nvidia-smi) 1,288 [1,288-1,288] MiB 654 [598-654] MiB (−634, −49 %)
allocator: in use / reserved 500 / 1,344 MiB 496 / 650 MiB
RSS after the flights 1,476 [1,474-1,506] MB 1,364 [1,356-1,389] MB (−112: the mapped host blocks)
peak RSS 1,511 MB 1,388 MB
average FPS over the flights 1,832 [1,815-1,904] 1,897 [1,824-1,906]
1 % low FPS 552 [538-636] 591 [570-594]
p99 frame time 1.23 ms 1.16 ms

The frame times don't move (the arena grows rarely and the staging belt reuses its buffers, so there are few more allocations); the memory falls every start.

Tests

No behaviour to test beyond the renderer opening and drawing: started, flew the scenes and saved screenshots on this build. wgpu reads the hint only when the device is made.

pr_ready (tools/pr_ready.py --quick on archlinux, against origin/main at 80dfb5f35, 3 min 10 s)

Check Result
Scope ✅ 2 files, +4 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 594 passed (34 s)
rustfmt ✅ (8 s)
clippy ✅ (1 min 14 s)
tests: horizon-client-render ✅ 928 passed (1 min 6 s)
doc tests ✅ 0 passed (1 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 ➖ 375 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 363 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/6419 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `mem-vram-memory-hints` --- ### 📝 Commits (1) - [`745fafe`](https://github.com/horizon-rust/horizon/commit/745fafeafe9d426643d07acf3d658e8dfa90c37f) Video memory in 8-64 MiB blocks: half the reserved VRAM was unused ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+4 -0) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Claude Code, Claude Opus 5.5), not by rdbtCVS personally. Part of #6418. ## What The device was opened with wgpu's default `MemoryHints::Performance`: its allocator (gpu-allocator, on Vulkan and DirectX 12) takes video memory in blocks of 128 to 256 MiB and sub-allocates buffers and textures in them. A block is only given back once empty, and the section arena's pages come and go as it grows: a page freed from a 256 MiB block leaves the block alive for a few small buffers placed beside it (the occlusion culler's 0.2 MiB "Section ids by block", for one). After the forest flight below, the allocator held **1,344 MiB for 500 MiB in use**: one 256 MiB block with 0.2 MiB in it, another with 42 MiB, a 64 MiB host block holding a few readback buffers. `MemoryHints::MemoryUsage` takes blocks of 8 to 64 MiB (wgpu-hal's `AllocationSizes`). Larger resources (the arena's pages, the 80 MiB GUI atlas) get memory of their own, freed with them. One line in `gfx.rs`; Metal and OpenGL don't use these hints. ## Measured **How it was measured.** Arch Linux (zen kernel), Ryzen 5 5600X (12 threads), 32 GB, RTX 4060 8 GB (Vulkan, NVIDIA 615.78), `--profile fast`, `--offscreen` 1280x720, fresh scratch homes per start, render distance 12. A start goes to the title screen, creates the perf_bench world (seed 1234, creative), waits for spawn to load, then teleports to and flies `tools/perf_bench.py`'s village and forest paths (12 s each) and samples after each. Video memory: what `nvidia-smi` attributes to the process, and the game's own allocator totals (`status`: `gpu_allocated_bytes` / `gpu_reserved_bytes`); RSS from `/proc/<pid>/status`. Three alternated starts per build, medians (range in brackets); `main` = dea6dea98. | | main | this PR | |---|---|---| | video memory, title screen (nvidia-smi) | 520 MiB | **206 MiB** (−314) | | video memory after the flights (nvidia-smi) | 1,288 [1,288-1,288] MiB | **654 [598-654] MiB** (−634, −49 %) | | allocator: in use / reserved | 500 / 1,344 MiB | 496 / 650 MiB | | RSS after the flights | 1,476 [1,474-1,506] MB | **1,364 [1,356-1,389] MB** (−112: the mapped host blocks) | | peak RSS | 1,511 MB | 1,388 MB | | average FPS over the flights | 1,832 [1,815-1,904] | 1,897 [1,824-1,906] | | 1 % low FPS | 552 [538-636] | 591 [570-594] | | p99 frame time | 1.23 ms | 1.16 ms | The frame times don't move (the arena grows rarely and the staging belt reuses its buffers, so there are few more allocations); the memory falls every start. ## Tests No behaviour to test beyond the renderer opening and drawing: started, flew the scenes and saved screenshots on this build. wgpu reads the hint only when the device is made. **pr_ready** (`tools/pr_ready.py --quick` on archlinux, against origin/main at 80dfb5f35, 3 min 10 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +4 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 594 passed (34 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (1 min 14 s) | | tests: horizon-client-render | ✅ 928 passed (1 min 6 s) | | doc tests | ✅ 0 passed (1 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 | ➖ 375 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 363 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:28:15 +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#6857
No description provided.