host: keep command allocators instead of remaking them for age (VICTORY_KEEP_HOST_BUFFERS) #332

Manually merged
github merged 1 commit from github-bot/gh-332 into main 2026-12-03 16:46:29 +00:00 AGit
Owner

@⁠t-jonesy on GitHub · 2026-12-03 15:42 UTC · original
t-jonesy:upstream/keep-host-buffers → main · +191 −6 · 3 files · 1 commits · merged 2026-12-03 16:30 UTC

Problem

At its first reset after 60 s, every host list's and prelude's command allocator was made anew, and host lists idle for 60 s were let go. An allocator holds RADV's command memory: an 80 KiB command block and a 16 KiB upload block per command buffer, doubled as recordings grow, each its own buffer in the card's memory.

A remake freed them all, and the new allocator grew back block by block. A kernel trace of the game threads over 5 s showed ~110 maps and ~107 unmaps a second of exactly those sizes. Each unmap goes through amdgpu_vm_clear_freed, whose page-table job waits for all queued work in the VM. The next submission then waits for that job and flushes the TLB.

Changes

  • VICTORY_KEEP_HOST_BUFFERS=1 (off by default): allocators are not remade for age, and idle lists are not let go for age, while the card's memory in use is under budget (checked every 100 ms). Past the budget, the old trimming applies. A list's command memory stays at the largest it recorded, which it grows back to within seconds of a remake anyway.
  • A per-second line counts allocators made and let go, by reason.
  • docs/SETTINGS.md lists the switch.

Results

3 alternating pairs, normal priority:

off on
fps 32.2 / 32.4 / 32.0 → 32.2 32.6 / 32.7 / 32.5 → 32.6 (+1.2%), won 3/3
1% low 19.1 20.3 (+6%)
CPU prep 9.4 ms 7.9 ms

A kernel trace (5 s) showed the game's host-buffer maps going from 110/s to 31/s, and VM-flushed gfx jobs from 123/s to 72/s.

All of these numbers come from one machine:

  • Ryzen 9 7950X3D, RX 9070 XT (RDNA4)
  • RADV / Mesa 26.3.1 with this project's patches, Linux 7.3
  • 4K with FSR 4 performance, RT on
  • a steady camera, alternating A/B runs

They were measured on a fork whose base is about 150 commits behind current main; this branch is the same change rebased (only the README conflicted; the setting moved to docs/SETTINGS.md). Untested on other GPUs and on cards with less VRAM, where the budget check matters more. Not re-measured in game after the rebase.

#306's reuse of send buffers works on a different kind of memory (upload buffers, not command allocators), so the two should combine. That combination is untested.

Testing

  • ./build.sh (release) builds.
  • victory-gpu unit tests (Windows target under Wine, RADV): the 5 new host::keep_tests pass. The full suite has 313 passed and 6 failed; the same 6 tests (indirect::tests::host_list_* and watch::*) fail on unmodified main in the same environment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ETU6PfySRvsjk18uHFtWya

**@⁠t-jonesy** on GitHub · 2026-12-03 15:42 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/332) `t-jonesy:upstream/keep-host-buffers` → `main` · +191 −6 · 3 files · 1 commits · merged 2026-12-03 16:30 UTC ## Problem At its first reset after 60 s, every host list's and prelude's command allocator was made anew, and host lists idle for 60 s were let go. An allocator holds RADV's command memory: an 80 KiB command block and a 16 KiB upload block per command buffer, doubled as recordings grow, each its own buffer in the card's memory. A remake freed them all, and the new allocator grew back block by block. A kernel trace of the game threads over 5 s showed ~110 maps and ~107 unmaps a second of exactly those sizes. Each unmap goes through `amdgpu_vm_clear_freed`, whose page-table job waits for all queued work in the VM. The next submission then waits for that job and flushes the TLB. ## Changes - **`VICTORY_KEEP_HOST_BUFFERS=1`** (off by default): allocators are not remade for age, and idle lists are not let go for age, while the card's memory in use is under budget (checked every 100 ms). Past the budget, the old trimming applies. A list's command memory stays at the largest it recorded, which it grows back to within seconds of a remake anyway. - A per-second line counts allocators made and let go, by reason. - `docs/SETTINGS.md` lists the switch. ## Results 3 alternating pairs, normal priority: | | off | on | |---|---|---| | fps | 32.2 / 32.4 / 32.0 → **32.2** | 32.6 / 32.7 / 32.5 → **32.6 (+1.2%)**, won 3/3 | | 1% low | 19.1 | **20.3 (+6%)** | | CPU prep | 9.4 ms | 7.9 ms | A kernel trace (5 s) showed the game's host-buffer maps going from 110/s to 31/s, and VM-flushed gfx jobs from 123/s to 72/s. All of these numbers come from **one machine**: - Ryzen 9 7950X3D, RX 9070 XT (RDNA4) - RADV / Mesa 26.3.1 with this project's patches, Linux 7.3 - 4K with FSR 4 performance, RT on - a steady camera, alternating A/B runs They were measured on a fork whose base is about 150 commits behind current `main`; this branch is the same change rebased (only the README conflicted; the setting moved to `docs/SETTINGS.md`). **Untested on other GPUs** and on cards with less VRAM, where the budget check matters more. Not re-measured in game after the rebase. #306's reuse of send buffers works on a different kind of memory (upload buffers, not command allocators), so the two should combine. That combination is untested. ## Testing - `./build.sh` (release) builds. - victory-gpu unit tests (Windows target under Wine, RADV): the 5 new `host::keep_tests` pass. The full suite has 313 passed and 6 failed; the same 6 tests (`indirect::tests::host_list_*` and `watch::*`) fail on unmodified `main` in the same environment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ETU6PfySRvsjk18uHFtWya
Every host list's and prelude's command allocator was made anew at its first
reset after 60 s (allocator_refresh), and idle host lists were let go after
60 s idle. An allocator holds the driver's command memory: in RADV each
command buffer's 80 KiB command block and 16 KiB upload block (doubled as a
recording outgrows them; the largest kept at a reset), each a buffer of its
own in the card's memory (SAM). A remake freed all of them when the old
allocator was buried (victory-relay / victory-submit) and the new one grew
back block by block on the list threads, each growth freeing the smaller
block at the next reset (victory-late-wait). A kernel trace (game threads,
5 s): ~120 maps and ~150 unmaps a second of exactly those sizes (80/160/320/
640 KiB command blocks, 16/32 KiB upload blocks); the run's log had ~3,000
host lists alive and 50-90 allocators remade a second around the trace.
Each unmap goes through amdgpu_vm_clear_freed, whose page-table job waits
for all queued work in the VM; the next submission waits for that job and
flushes the TLB.

With VICTORY_KEEP_HOST_BUFFERS=1 allocators are not remade for age and idle
lists are not let go for age while the card's memory in use is under its
budget (looked at every 100 ms); past the budget the old trimming applies.
A list's command memory then stays at the largest it recorded, which it
grows back to within seconds of a remake anyway.

A line each second counts allocators made and let go by why (new host
lists, new preludes, remade for age, lists dropped, preludes let go) and the
remakes the switch left out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ETU6PfySRvsjk18uHFtWya
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 15:42:58 +00:00
github manually merged commit 4e02e387b3 into main 2026-12-03 16:46:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.