perf(vk): the image reaper's queue is bounded and gives its memory back near the VRAM allowance #1914

Merged
HumanBean merged 2 commits from dyst/Longshot:perf/reaper-bounded into main 2026-11-20 22:21:25 +00:00
Member

Summary

A follow-up to #792 (merged as afc4d1ad), for the two points of BeanBot's review that were still open there: the reaper's queue had no bound and no answer to VRAM pressure (point 2), and its checks read only the source's text (point 4). This commit was pushed to #792's branch after it merged, so it is here.

  • The cap: past an 8th of the driver's VRAM allowance (128 MB to 1 GB; 1.17 GB on a 10 GB card), an image handed over is destroyed where it was, as before #792.

    • It's a safety net above an arrival's burst. The first cap, a 32nd (64 to 256 MB), was reached at every arrival in Hyrule Field measured on an RTX 3080 and sent 199 to 657 frees back to the render thread there (Testing).
    • A compaction pass open holds the queue, as main's dead list held its images then.
  • VRAM pressure: the queue is the budget line's pool reaper (mem_account.h).

    • Its bytes are counted as the driver's until they are freed, not as "other images".
    • Near the allowance the arbiter asks it first, and reap_now frees it on the asking thread.
    • reap_now returns only what goes back to the driver: its dedicated allocations' bytes (allocation_dedicated, VMA's vmaGetAllocationInfo2). A share of a block freed leaves the block with VMA, so it counts 0 and the arbiter goes on asking the other pools. With only shares queued, it frees every queued entry of that ledger.
    • An entry is chosen by either allocation's ledger (or a sparse texture's chunks, for VRAM): a buffer alone, such as a timed-out write-back's, or a system-memory image with a VRAM buffer.
  • A pass that waits holds the reaper off its next free. With a queue, the reaper began the next free before the waiting pass woke, so a pass could wait for the whole queue. When no pass begins, the reaper is woken again.

    • On main this can't happen: compact_step opens a pass only once the queue is empty, and nothing is handed over between that look and the pass. The lock is now safe without relying on that.
  • A log line: vk: reaper: every 10 s says what went, how much was destroyed where it was handed over, and the queue's most.

  • A test that runs the code: tests/test_image_reaper_threads.py cuts the compaction's and the reaper's code out of vk_vma.cpp and runs it on threads against stub VMA and Vulkan calls. It checks:

    • no free inside a pass;
    • every object destroyed once, and the counts back to 0;
    • a hand-over doesn't wait for the frees;
    • the cap;
    • a pass open;
    • reap_now;
    • RX_VK_REAPER=0;
    • reap_now with dedicated images, with shares of blocks, with mixed ledgers and with a buffer alone.

    Copies of vk_vma.cpp that break one rule each fail it:

    • a reaper that frees inside a pass;
    • one that keeps no count;
    • one with no cap;
    • a reap_now that counts allocation sizes;
    • a reap_now that chooses by the image's ledger alone.

    Writing it found the pass's wait and a count the cap's frees took off without having added.

  • scripts/memtour.py has the new pool's columns.

Read first: gpu/vk/vk_vma.cpp, from destroy_image_later to reap_now, and image_compact_pass; gpu/vk/vk_texture.cpp's account_sample and the pool reaper.

See #792.

Testing

Tested:

  • In the game, on the first cap (afa2a345, a 32nd of the allowance): Windows 11, Ryzen 9 3900X, RTX 3080, NVIDIA 621.14, packed over base 3f2c9b3c. 6 runs interleaved against RX_VK_REAPER=0 on the same runtime.

    • Each run: the camera turning in the Market for 20 s, then 25 s from the teleport to Hyrule Field.
    • 4 runs (2 a side) at the card's own VRAM.
    • 2 runs (1 a side) with a 3 GB card simulated (RX_VK_TEST_VRAM_MB=3072).
    • What was seen:
      • no device loss in any run;
      • the reaper's line logged;
      • the arbiter asked the pool reaper once (one run);
      • no compaction pass ran, even at a simulated 3 GB, so the pressure path and the rule around passes are checked by tests/test_image_reaper_threads.py, not by these runs.
    • The first cap was too tight. Every reaper-on run reached it at the arrival in Hyrule Field: 436-444 images and 255 MB (361 at a simulated 3 GB). 199, 219 and 657 images went back to the render thread there, and in the first run the render thread's time freeing images on arriving was as high as with RX_VK_REAPER=0. Hence the cap of 92e963c0, which these runs are not of.
    Reaper on (afa2a345) against RX_VK_REAPER=0, the range of the runs Reaper on RX_VK_REAPER=0
    The card's own VRAM, 2 runs a side
    Market, turning: tex_frame_ms mean 0.29-0.39 1.10-1.75
    Market, turning: tex_frame_ms p99 1.24-1.53 6.95-12.07
    Market, turning: frame time p99 35.0-61.6 ms 32.7-62.1 ms
    Hyrule Field, arriving: tex_frame_ms mean 0.47-0.98 1.00-1.06
    Hyrule Field, arriving: tex_frame_ms p99 5.15-13.36 10.19-10.72
    Hyrule Field, arriving: tex_frame_ms max 32.4-81.4 77.5-93.6
    Hyrule Field, arriving: frame time p99 53.7-161.1 ms 72.4-87.0 ms
    Peak VRAM, the driver's count 6,928-7,184 MB 6,887-6,896 MB
    Peak private memory 19,772-20,092 MB 19,754-19,840 MB
    The queue at most 436-444 images, 255 MB –
    Destroyed where handed over (the cap) 199-219 –
    A 3 GB card simulated, 1 run a side
    Market, turning: tex_frame_ms p99 2.34 22.60
    Hyrule Field, arriving: tex_frame_ms p99 4.95 17.75
    Hyrule Field, arriving: frame time p99 104.2 ms 102.1 ms
    Peak VRAM, the driver's count 5,287 MB 5,059 MB
    Peak private memory 18,389 MB 17,961 MB
    Destroyed where handed over (the cap) 657 –
    • The PC was busier for these runs than for #792's (about 31-47 fps turning in the Market on both sides, against 39-49 then), and 2 runs a side overlap in every frame-time row.
    • The queue's cost: up to about 300 MB of VRAM at the card's own size (230 MB at a simulated 3 GB). Private memory is about the same on both sides.
  • The checks:

    • tests/run_all.py --changed on this branch over main afc4d1ad: 85 passed, 10 failed. Each of the 10 also fails on a clean main: test_fsr_uniform_ownership, test_linux_pressure, test_low_vram_texture_mips, test_pass_barrier, test_readback_timeout_source, test_replay_write_order, test_sparse_mirror, test_staging_burst, test_texel_buffer_ownership, test_ub_update_batch.
    • tests/test_image_reaper_threads.py passed three times in a row on 92e963c0, and failed against each broken copy.
    • On 92e963c0 the reaper's, accounting and pool checks pass: test_image_reaper, test_image_reaper_threads, test_mem_account, test_target_image_pool, test_target_image_reuse, test_switch_table, test_async_safe_frees.

Still to test:

  • Windows, RTX 3080: this PR against main afc4d1ad interleaved, 2 runs a side on the same route with nothing else running, expecting the arrival's burst to stay on the reaper (nothing destroyed where it was handed over), tex_frame_ms no higher than main's, and the peak VRAM and private memory of both sides (by hand)
  • Windows, NVIDIA RTX: 30 minutes of play with compaction on, expecting vk: VRAM compacted lines and no device loss (by hand)
  • Linux, any GPU: 15 minutes of play, expecting no change and no device loss (by hand)

Measurements

Verdict: not settled. Run again alone in the queue, this PR is ahead of main on every row, but its frame-time rows are not a gain. main was as slow in a third pair run after this PR's (30.5-33.9 fps turning). The gap is in the game's CPU threads (game_ms 24-29 against 20), which this PR doesn't touch, and the two runtimes' longshot.exe have identical link maps. Something about the runtimes or the PC, not the change, makes it. The render thread's own time freeing images is less exposed to that, and it agrees with the cap holding:

  • turning: p99 0.97-1.01 ms against 1.33-1.59;
  • arriving in Hyrule Field: p99 3.3-3.6 ms against 4.7-5.1, the worst frame 9-20 ms against 26-42.

The 1 GB cap was still reached in one of the two runs (29 images destroyed back on the render thread). An interleaved series alone in the queue is next.

Setup:

  • Windows 11, Ryzen 9 3900X, RTX 3080, NVIDIA 621.14.
  • Both sides packed over base 3f2c9b3c.
  • The route in Testing: the camera turning in the Market for 20 s, then 25 s from the teleport to Hyrule Field.
  • Each side 2 runs, alone in the PC's queue: main's first, then this PR's.
  • The range of the 2 runs a side.
Before: main @ afc4d1ad After: this PR @ 92e963c0
Market, turning: fps 34.9-36.5 44.7-45.5
Market, turning: frame time p99 49.1-53.6 ms 36.6-40.5 ms
Market, turning: tex_frame_ms mean 0.36-0.38 0.27
Market, turning: tex_frame_ms p99 1.33-1.59 0.97-1.01
Hyrule Field, arriving: fps 40.3-47.5 51.6-55.8
Hyrule Field, arriving: frame time p99 72.6-103.3 ms 49.9-55.2 ms
Hyrule Field, arriving: tex_frame_ms mean 0.48-0.53 0.36-0.39
Hyrule Field, arriving: tex_frame_ms p99 4.67-5.10 3.27-3.62
Hyrule Field, arriving: tex_frame_ms max 25.5-41.5 9.1-19.6
Peak VRAM, the driver's count 7,016-7,018 MB 7,082-7,178 MB
Peak private memory 19,902-20,059 MB 20,003-20,019 MB
The reaper's queue at most not logged on main 724-964 images, 866-1,023 MB
Destroyed where handed over (the cap) none: no cap 6-29
  • The first, interleaved series: 2 runs of this PR with 2 of main, A B B A. Another job on the PC disturbed main's two (14 and 29 fps turning), so those are left out. This PR's two had:
    • 25-65 images destroyed where they were handed over;
    • arriving in Hyrule Field, a tex_frame_ms p99 of 5.0-11.1 ms and frame time p99 78-105 ms.
  • Peak VRAM comes from the budget line, about every 12 s, so a burst's peak can fall between two lines.
  • The first cap's runs against RX_VK_REAPER=0 are in Testing; they chose the cap of 92e963c0.

Risks

What could break:

  • The cap: frees back on the render thread at an arrival's burst. Seen with the first cap at every arrival measured; the cap of 92e963c0 is 4.6 times larger here and is still to be measured.
  • The queue's VRAM: what it holds is the driver's until it is freed: up to about 300 MB at the first cap. With the larger cap it can hold more, up to 1 GB, until the reaper has got through a burst. Near the allowance the arbiter frees it first.
  • reap_now under pressure: frees on the render thread, as main did at every present. It's only asked near the VRAM allowance.

Turning it off: RX_VK_REAPER=0, as for #792, or revert this commit.

After updating: nothing changes for a player beyond where the frees happen.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. Not ticked: the head, 92e963c0, has not run in the game yet; its first cap's 6 runs are in Testing.
  • mise run test passes (any failure that also fails on main is named). Not ticked: only the checks that read this diff ran, not the whole suite.
  • Measured against main, or Measurements says why there is nothing to measure. Not ticked: 92e963c0 against main is building.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Not ticked: it builds on Windows (the pack, llvm-mingw); not built on Linux here.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

πŸ€– Generated with Claude Code

## Summary A follow-up to #792 (merged as afc4d1ad), for the two points of BeanBot's review that were still open there: the reaper's queue had no bound and no answer to VRAM pressure (point 2), and its checks read only the source's text (point 4). This commit was pushed to #792's branch after it merged, so it is here. - **The cap:** past an 8th of the driver's VRAM allowance (128 MB to 1 GB; 1.17 GB on a 10 GB card), an image handed over is destroyed where it was, as before #792. - It's a safety net above an arrival's burst. The first cap, a 32nd (64 to 256 MB), was reached at every arrival in Hyrule Field measured on an RTX 3080 and sent 199 to 657 frees back to the render thread there (Testing). - A compaction pass open holds the queue, as main's dead list held its images then. - **VRAM pressure:** the queue is the budget line's pool `reaper` (`mem_account.h`). - Its bytes are counted as the driver's until they are freed, not as "other images". - Near the allowance the arbiter asks it first, and `reap_now` frees it on the asking thread. - `reap_now` returns only what goes back to the driver: its dedicated allocations' bytes (`allocation_dedicated`, VMA's `vmaGetAllocationInfo2`). A share of a block freed leaves the block with VMA, so it counts 0 and the arbiter goes on asking the other pools. With only shares queued, it frees every queued entry of that ledger. - An entry is chosen by either allocation's ledger (or a sparse texture's chunks, for VRAM): a buffer alone, such as a timed-out write-back's, or a system-memory image with a VRAM buffer. - **A pass that waits holds the reaper off its next free.** With a queue, the reaper began the next free before the waiting pass woke, so a pass could wait for the whole queue. When no pass begins, the reaper is woken again. - On main this can't happen: `compact_step` opens a pass only once the queue is empty, and nothing is handed over between that look and the pass. The lock is now safe without relying on that. - **A log line:** `vk: reaper:` every 10 s says what went, how much was destroyed where it was handed over, and the queue's most. - **A test that runs the code:** `tests/test_image_reaper_threads.py` cuts the compaction's and the reaper's code out of `vk_vma.cpp` and runs it on threads against stub VMA and Vulkan calls. It checks: - no free inside a pass; - every object destroyed once, and the counts back to 0; - a hand-over doesn't wait for the frees; - the cap; - a pass open; - `reap_now`; - `RX_VK_REAPER=0`; - `reap_now` with dedicated images, with shares of blocks, with mixed ledgers and with a buffer alone. Copies of `vk_vma.cpp` that break one rule each fail it: - a reaper that frees inside a pass; - one that keeps no count; - one with no cap; - a `reap_now` that counts allocation sizes; - a `reap_now` that chooses by the image's ledger alone. Writing it found the pass's wait and a count the cap's frees took off without having added. - `scripts/memtour.py` has the new pool's columns. Read first: `gpu/vk/vk_vma.cpp`, from `destroy_image_later` to `reap_now`, and `image_compact_pass`; `gpu/vk/vk_texture.cpp`'s `account_sample` and the pool `reaper`. See #792. ## Testing **Tested:** - **In the game, on the first cap (afa2a345, a 32nd of the allowance):** Windows 11, Ryzen 9 3900X, RTX 3080, NVIDIA 621.14, packed over base 3f2c9b3c. 6 runs interleaved against `RX_VK_REAPER=0` on the same runtime. - Each run: the camera turning in the Market for 20 s, then 25 s from the teleport to Hyrule Field. - 4 runs (2 a side) at the card's own VRAM. - 2 runs (1 a side) with a 3 GB card simulated (`RX_VK_TEST_VRAM_MB=3072`). - What was seen: - no device loss in any run; - the reaper's line logged; - the arbiter asked the pool `reaper` once (one run); - no compaction pass ran, even at a simulated 3 GB, so the pressure path and the rule around passes are checked by `tests/test_image_reaper_threads.py`, not by these runs. - **The first cap was too tight.** Every reaper-on run reached it at the arrival in Hyrule Field: 436-444 images and 255 MB (361 at a simulated 3 GB). 199, 219 and 657 images went back to the render thread there, and in the first run the render thread's time freeing images on arriving was as high as with `RX_VK_REAPER=0`. Hence the cap of 92e963c0, which these runs are not of. | Reaper on (afa2a345) against `RX_VK_REAPER=0`, the range of the runs | Reaper on | `RX_VK_REAPER=0` | |---|---|---| | **The card's own VRAM, 2 runs a side** | | | | Market, turning: `tex_frame_ms` mean | 0.29-0.39 | 1.10-1.75 | | Market, turning: `tex_frame_ms` p99 | 1.24-1.53 | 6.95-12.07 | | Market, turning: frame time p99 | 35.0-61.6 ms | 32.7-62.1 ms | | Hyrule Field, arriving: `tex_frame_ms` mean | 0.47-0.98 | 1.00-1.06 | | Hyrule Field, arriving: `tex_frame_ms` p99 | 5.15-13.36 | 10.19-10.72 | | Hyrule Field, arriving: `tex_frame_ms` max | 32.4-81.4 | 77.5-93.6 | | Hyrule Field, arriving: frame time p99 | 53.7-161.1 ms | 72.4-87.0 ms | | Peak VRAM, the driver's count | 6,928-7,184 MB | 6,887-6,896 MB | | Peak private memory | 19,772-20,092 MB | 19,754-19,840 MB | | The queue at most | 436-444 images, 255 MB | – | | Destroyed where handed over (the cap) | 199-219 | – | | **A 3 GB card simulated, 1 run a side** | | | | Market, turning: `tex_frame_ms` p99 | 2.34 | 22.60 | | Hyrule Field, arriving: `tex_frame_ms` p99 | 4.95 | 17.75 | | Hyrule Field, arriving: frame time p99 | 104.2 ms | 102.1 ms | | Peak VRAM, the driver's count | 5,287 MB | 5,059 MB | | Peak private memory | 18,389 MB | 17,961 MB | | Destroyed where handed over (the cap) | 657 | – | - The PC was busier for these runs than for #792's (about 31-47 fps turning in the Market on both sides, against 39-49 then), and 2 runs a side overlap in every frame-time row. - The queue's cost: up to about 300 MB of VRAM at the card's own size (230 MB at a simulated 3 GB). Private memory is about the same on both sides. - **The checks:** - `tests/run_all.py --changed` on this branch over main afc4d1ad: 85 passed, 10 failed. Each of the 10 also fails on a clean `main`: `test_fsr_uniform_ownership`, `test_linux_pressure`, `test_low_vram_texture_mips`, `test_pass_barrier`, `test_readback_timeout_source`, `test_replay_write_order`, `test_sparse_mirror`, `test_staging_burst`, `test_texel_buffer_ownership`, `test_ub_update_batch`. - `tests/test_image_reaper_threads.py` passed three times in a row on 92e963c0, and failed against each broken copy. - On 92e963c0 the reaper's, accounting and pool checks pass: `test_image_reaper`, `test_image_reaper_threads`, `test_mem_account`, `test_target_image_pool`, `test_target_image_reuse`, `test_switch_table`, `test_async_safe_frees`. **Still to test:** - Windows, RTX 3080: this PR against `main` afc4d1ad interleaved, 2 runs a side on the same route with nothing else running, expecting the arrival's burst to stay on the reaper (nothing destroyed where it was handed over), `tex_frame_ms` no higher than `main`'s, and the peak VRAM and private memory of both sides (by hand) - Windows, NVIDIA RTX: 30 minutes of play with compaction on, expecting `vk: VRAM compacted` lines and no device loss (by hand) - Linux, any GPU: 15 minutes of play, expecting no change and no device loss (by hand) ## Measurements **Verdict:** not settled. Run again alone in the queue, this PR is ahead of `main` on every row, but its frame-time rows are not a gain. `main` was as slow in a third pair run after this PR's (30.5-33.9 fps turning). The gap is in the game's CPU threads (`game_ms` 24-29 against 20), which this PR doesn't touch, and the two runtimes' `longshot.exe` have identical link maps. Something about the runtimes or the PC, not the change, makes it. The render thread's own time freeing images is less exposed to that, and it agrees with the cap holding: - turning: p99 0.97-1.01 ms against 1.33-1.59; - arriving in Hyrule Field: p99 3.3-3.6 ms against 4.7-5.1, the worst frame 9-20 ms against 26-42. The 1 GB cap was still reached in one of the two runs (29 images destroyed back on the render thread). An interleaved series alone in the queue is next. Setup: - Windows 11, Ryzen 9 3900X, RTX 3080, NVIDIA 621.14. - Both sides packed over base 3f2c9b3c. - The route in Testing: the camera turning in the Market for 20 s, then 25 s from the teleport to Hyrule Field. - Each side 2 runs, alone in the PC's queue: `main`'s first, then this PR's. - The range of the 2 runs a side. | | Before: main @ afc4d1ad | After: this PR @ 92e963c0 | |---|---|---| | Market, turning: fps | 34.9-36.5 | 44.7-45.5 | | Market, turning: frame time p99 | 49.1-53.6 ms | 36.6-40.5 ms | | Market, turning: `tex_frame_ms` mean | 0.36-0.38 | 0.27 | | Market, turning: `tex_frame_ms` p99 | 1.33-1.59 | 0.97-1.01 | | Hyrule Field, arriving: fps | 40.3-47.5 | 51.6-55.8 | | Hyrule Field, arriving: frame time p99 | 72.6-103.3 ms | 49.9-55.2 ms | | Hyrule Field, arriving: `tex_frame_ms` mean | 0.48-0.53 | 0.36-0.39 | | Hyrule Field, arriving: `tex_frame_ms` p99 | 4.67-5.10 | 3.27-3.62 | | Hyrule Field, arriving: `tex_frame_ms` max | 25.5-41.5 | 9.1-19.6 | | Peak VRAM, the driver's count | 7,016-7,018 MB | 7,082-7,178 MB | | Peak private memory | 19,902-20,059 MB | 20,003-20,019 MB | | The reaper's queue at most | not logged on main | 724-964 images, 866-1,023 MB | | Destroyed where handed over (the cap) | none: no cap | 6-29 | - **The first, interleaved series:** 2 runs of this PR with 2 of `main`, A B B A. Another job on the PC disturbed `main`'s two (14 and 29 fps turning), so those are left out. This PR's two had: - 25-65 images destroyed where they were handed over; - arriving in Hyrule Field, a `tex_frame_ms` p99 of 5.0-11.1 ms and frame time p99 78-105 ms. - Peak VRAM comes from the budget line, about every 12 s, so a burst's peak can fall between two lines. - The first cap's runs against `RX_VK_REAPER=0` are in Testing; they chose the cap of 92e963c0. ## Risks **What could break:** - **The cap:** frees back on the render thread at an arrival's burst. Seen with the first cap at every arrival measured; the cap of 92e963c0 is 4.6 times larger here and is still to be measured. - **The queue's VRAM:** what it holds is the driver's until it is freed: up to about 300 MB at the first cap. With the larger cap it can hold more, up to 1 GB, until the reaper has got through a burst. Near the allowance the arbiter frees it first. - **`reap_now` under pressure:** frees on the render thread, as main did at every present. It's only asked near the VRAM allowance. **Turning it off:** `RX_VK_REAPER=0`, as for #792, or revert this commit. **After updating:** nothing changes for a player beyond where the frees happen. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. Not ticked: the head, 92e963c0, has not run in the game yet; its first cap's 6 runs are in Testing. - [ ] `mise run test` passes (any failure that also fails on `main` is named). Not ticked: only the checks that read this diff ran, not the whole suite. - [ ] Measured against `main`, or Measurements says why there is nothing to measure. Not ticked: 92e963c0 against `main` is building. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Not ticked: it builds on Windows (the pack, llvm-mingw); not built on Linux here. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
perf(vk): the reaper's queue is bounded and gives its memory back near the VRAM allowance
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 28s
CI / Conventional Commit title (pull_request) Successful in 26s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 36s
CI / Workflow lint (actionlint) (pull_request) Successful in 38s
Third-party parts / As their notes say (pull_request) Successful in 42s
CI / Website build and checks (pull_request) Has been cancelled
afa2a34502
Review (BeanBot, points 2 and 4): the queue had no bound and no answer to VRAM
pressure, and the checks read only the source's text.

- A cap: past a 32nd of the driver's VRAM allowance (64 to 256 MB) an image
  handed over is destroyed where it was, as before. A pass open holds the queue
  as main's dead list held its images then.
- The queue is the budget line's pool "reaper" (mem_account.h): its bytes are
  the driver's until freed, not "other images"; near the allowance the arbiter
  asks it first, and reap_now frees it on the asking thread.
- A pass waiting holds the reaper off its next free: with a queue it began the
  next one before the pass woke, and the pass could wait for the whole queue.
  When no pass begins, the reaper is woken again.
- "vk: reaper:" every 10 s: what went, how much where it was handed over, the
  queue's most.
- tests/test_image_reaper_threads.py: the compaction's and the reaper's code
  cut out of vk_vma.cpp and run on threads against stub VMA and Vulkan calls
  (no free in a pass, every object once, the counts back to 0, the hand-over
  not waiting, the cap, a pass open, reap_now, RX_VK_REAPER=0). A copy whose
  reaper frees in a pass, keeps no count or has no cap fails it.
- scripts/memtour.py has the new pool's columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, Ryzen 9 3900X, RTX 3080, NVIDIA 621.14: the Market with the camera turning and the arrival in Hyrule Field, one run a side against RX_VK_REAPER=0 so far. No device loss; the reaper's line logged; the queue reached its cap (255 MB) on arriving in Hyrule Field and 199 images went back to the render thread, so the cap is still being chosen. The rest of the series (2 runs a side, and a 3 GB VRAM run a side) is running.

Tested in game: Windows 11, Ryzen 9 3900X, RTX 3080, NVIDIA 621.14: the Market with the camera turning and the arrival in Hyrule Field, one run a side against RX_VK_REAPER=0 so far. No device loss; the reaper's line logged; the queue reached its cap (255 MB) on arriving in Hyrule Field and 199 images went back to the render thread, so the cap is still being chosen. The rest of the series (2 runs a side, and a 3 GB VRAM run a side) is running.
BeanBot left a comment

Recommendation: Request changes. The cap puts a substantial burst of image destruction back on the render thread in the reported arrival run, and the pressure path can count pooled allocations as memory returned to the driver when their blocks remain allocated. The cap and pressure behavior need correction and measurement against main before this can merge.

The change bounds most of the reaper queue, exposes its allocations in the memory budget, and lets the arbiter destroy queued objects under pressure. That addresses queue growth, but the proposed cap can restore the stutter the reaper was introduced to avoid, and allocation accounting does not establish how much VRAM the driver gets back.

Does it help: Unproven. The PR reports one Windows RTX 3080 run per side against RX_VK_REAPER=0, not repeated runs against base afc4d1ad. At the arrival, 199 images fell back to the render thread and its freeing-time p99 was 13.4 ms versus 10.7 ms with the reaper off; the PR cites 3.4 ms for #792 without the cap. Repeated matched runs against main, including frame times, 1% lows, peak VRAM and RAM, are needed.
Other systems: The changed path also runs on Linux, AMD, Intel and Steam Deck, and interacts with VMA compaction and the memory arbiter. The reported run covers Windows and NVIDIA only; Linux builds and runs, Tier 1 coverage, pressure behavior and sustained compaction remain unverified.
Switches: No switches added, changed or removed. Existing RX_VK_REAPER defaults on and provides a fallback, but the cap applied while on is not yet supported by measurements across affected systems.

Reviewed: afa2a34502 against afc4d1ad08: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the PR template, commit and complete diff; read the changed reaper and compaction sections, accounting and arbiter paths, and the new threaded fixture. Skimmed the rest of the large changed source files and memtour; did not read those files in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No earlier reviews or comments were supplied; overlapping PRs beyond the referenced merged #792 could not be checked offline.; nothing run (a code review).
Checked and fine:

  • The reaper marks frees in flight under the compaction lock, and a successful pass excludes the worker until its end.
  • The new fixture exercises actual extracted code, including both switch states, and the author reports negative controls.
  • The change has one stated topic, records AI assistance, and does not touch third_party or generated assets.

Blocking (to change before merge)

  1. gpu/vk/vk_vma.cpp:430: The fixed 64–256 MB cap sends excess frees to the handing-over thread. In the reported Hyrule Field arrival on an RTX 3080, 199 images took that path and render-thread freeing-time p99 reached 13.4 ms, versus 3.4 ms reported for the uncapped reaper. Choose and validate a bound or pressure strategy that preserves the arrival burst benefit, then measure its frame pacing and memory cost against main across affected hardware.
  2. gpu/vk/vk_vma.cpp:464: reap_now returns allocation sizes as bytes given back, even when a texture allocation is suballocated from a VMA block that remains with the driver. If those sizes satisfy the arbiter's request, it stops asking other pools although driver usage may not have fallen, leaving the system under pressure. Account for actual driver memory returned, or distinguish reusable block space from memory returned to the driver and let the arbiter continue appropriately.
  3. gpu/vk/vk_vma.cpp:460: Selection uses only the image ledger, although a queued entry can contain a buffer in a different ledger or a buffer without an image. For example, a RAM image paired with a VRAM buffer is skipped when VRAM is requested, so the arbiter cannot reclaim that queued VRAM. Select entries by either allocation's requested ledger and count only bytes in that ledger; add mixed-ledger and buffer-only coverage.

Testing: No code or tests were run for this review. The author reports three passes of the threaded fixture and 85 passes plus 10 failures also seen on main for changed checks; the full suite, Linux build, repeated measurements and listed hardware runs remain outstanding.
Overlaps and merge order: Only the merged predecessor #792 was supplied; other overlapping PRs could not be checked with the network closed.


Automated code review by BeanBot (gpt-6.1-terra), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The cap puts a substantial burst of image destruction back on the render thread in the reported arrival run, and the pressure path can count pooled allocations as memory returned to the driver when their blocks remain allocated. The cap and pressure behavior need correction and measurement against main before this can merge. The change bounds most of the reaper queue, exposes its allocations in the memory budget, and lets the arbiter destroy queued objects under pressure. That addresses queue growth, but the proposed cap can restore the stutter the reaper was introduced to avoid, and allocation accounting does not establish how much VRAM the driver gets back. **Does it help:** Unproven. The PR reports one Windows RTX 3080 run per side against RX_VK_REAPER=0, not repeated runs against base afc4d1ad. At the arrival, 199 images fell back to the render thread and its freeing-time p99 was 13.4 ms versus 10.7 ms with the reaper off; the PR cites 3.4 ms for #792 without the cap. Repeated matched runs against main, including frame times, 1% lows, peak VRAM and RAM, are needed. **Other systems:** The changed path also runs on Linux, AMD, Intel and Steam Deck, and interacts with VMA compaction and the memory arbiter. The reported run covers Windows and NVIDIA only; Linux builds and runs, Tier 1 coverage, pressure behavior and sustained compaction remain unverified. **Switches:** No switches added, changed or removed. Existing RX_VK_REAPER defaults on and provides a fallback, but the cap applied while on is not yet supported by measurements across affected systems. **Reviewed:** afa2a34502fd against afc4d1ad08ca: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the PR template, commit and complete diff; read the changed reaper and compaction sections, accounting and arbiter paths, and the new threaded fixture. Skimmed the rest of the large changed source files and memtour; did not read those files in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. No earlier reviews or comments were supplied; overlapping PRs beyond the referenced merged #792 could not be checked offline.; nothing run (a code review). **Checked and fine:** - The reaper marks frees in flight under the compaction lock, and a successful pass excludes the worker until its end. - The new fixture exercises actual extracted code, including both switch states, and the author reports negative controls. - The change has one stated topic, records AI assistance, and does not touch third_party or generated assets. **Blocking** (to change before merge) 1. gpu/vk/vk_vma.cpp:430: The fixed 64–256 MB cap sends excess frees to the handing-over thread. In the reported Hyrule Field arrival on an RTX 3080, 199 images took that path and render-thread freeing-time p99 reached 13.4 ms, versus 3.4 ms reported for the uncapped reaper. Choose and validate a bound or pressure strategy that preserves the arrival burst benefit, then measure its frame pacing and memory cost against main across affected hardware. 2. gpu/vk/vk_vma.cpp:464: reap_now returns allocation sizes as bytes given back, even when a texture allocation is suballocated from a VMA block that remains with the driver. If those sizes satisfy the arbiter's request, it stops asking other pools although driver usage may not have fallen, leaving the system under pressure. Account for actual driver memory returned, or distinguish reusable block space from memory returned to the driver and let the arbiter continue appropriately. 3. gpu/vk/vk_vma.cpp:460: Selection uses only the image ledger, although a queued entry can contain a buffer in a different ledger or a buffer without an image. For example, a RAM image paired with a VRAM buffer is skipped when VRAM is requested, so the arbiter cannot reclaim that queued VRAM. Select entries by either allocation's requested ledger and count only bytes in that ledger; add mixed-ledger and buffer-only coverage. **Testing:** No code or tests were run for this review. The author reports three passes of the threaded fixture and 85 passes plus 10 failures also seen on main for changed checks; the full suite, Linux build, repeated measurements and listed hardware runs remain outstanding. **Overlaps and merge order:** Only the merged predecessor #792 was supplied; other overlapping PRs could not be checked with the network closed. --- <sub>Automated code review by BeanBot (gpt-6.1-terra), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -380,1 +427,4 @@
}
// (past the cap: destroyed here, as before, unless a pass is open, when nothing of the pools may be freed: then it waits
// for the pass's end, as it waited in texture_frame's dead list)
if (!reap_queue.empty() && reap_held() + r.image_bytes + r.buffer_bytes > cap && !compact_in_pass) {
Member

The reported arrival already sends 199 frees back to the render thread, with 13.4 ms freeing-time p99 versus the cited 3.4 ms uncapped. Please choose and measure a bound or pressure strategy that retains the burst benefit, including its VRAM and RAM cost against main.

The reported arrival already sends 199 frees back to the render thread, with 13.4 ms freeing-time p99 versus the cited 3.4 ms uncapped. Please choose and measure a bound or pressure strategy that retains the burst benefit, including its VRAM and RAM cost against main.
@ -388,0 +457,4 @@
std::lock_guard lk(reap_mu);
if (compact_in_pass) return 0; // (nothing of the pools freed inside a pass)
for (auto it = reap_queue.begin(); it != reap_queue.end() && got < want;) {
if ((it->ledger == 0) != vram) {
Member

This filters by the image ledger alone. A RAM image with a VRAM buffer, or a buffer-only entry in VRAM, is skipped for a VRAM request. Please select by either allocation's ledger and test mixed-ledger and buffer-only entries.

This filters by the image ledger alone. A RAM image with a VRAM buffer, or a buffer-only entry in VRAM, is skipped for a VRAM request. Please select by either allocation's ledger and test mixed-ledger and buffer-only entries.
@ -388,0 +461,4 @@
++it;
continue;
}
got += it->image_bytes + (it->buffer_ledger == it->ledger ? it->buffer_bytes : 0);
Member

These are allocation sizes, not necessarily bytes returned to the driver: a freed texture suballocation can leave its VMA block allocated. The arbiter may therefore stop asking other pools while driver usage stays high. Please report actual returned memory or distinguish reusable block space so the arbiter can continue.

These are allocation sizes, not necessarily bytes returned to the driver: a freed texture suballocation can leave its VMA block allocated. The arbiter may therefore stop asking other pools while driver usage stays high. Please report actual returned memory or distinguish reusable block space so the arbiter can continue.
fix(vk): the reaper's cap is a safety net, and reap_now counts what goes back to the driver
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 17s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 18s
Third-party parts / As their notes say (pull_request) Successful in 19s
PR description / Description follows the template (pull_request_target) Failing after 7s
CI / Website build and checks (pull_request) Failing after 2m10s
92e963c093
Review (BeanBot on #1914):

- The cap was a 32nd of the VRAM allowance (64 to 256 MB). Every measured
  arrival in Hyrule Field reached it on an RTX 3080 (436-444 images, 255 MB)
  and 199-657 images went back to the render thread there. It is now an 8th
  (128 MB to 1 GB), a safety net above the burst; VRAM pressure is the
  arbiter's to answer.
- reap_now said a queued image's allocation size was given back, though a
  share of a VMA block leaves the block with VMA: the arbiter could stop
  asking the other pools with the driver's count unchanged. It now returns
  only what its dedicated allocations give back (allocation_dedicated, VMA's
  vmaGetAllocationInfo2), and with only shares queued frees all of that
  ledger and says 0.
- reap_now chose by the image's ledger alone: a buffer alone (a timed-out
  write-back's) or a system-memory image with a VRAM buffer was skipped for
  VRAM. An entry is now chosen by either allocation's ledger (or a sparse
  texture's chunks, VRAM), counting only that ledger's bytes.
- tests/test_image_reaper_threads.py: dedicated and shares, mixed ledgers, a
  buffer alone; a copy counting sizes, or choosing by the image's ledger
  alone, fails it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

The review's three points, in 92e963c0:

  1. The cap. Agreed: every measured arrival in Hyrule Field reached it on the RTX 3080.
    • 4 runs with the reaper on: 436-444 images and 255 MB, with 199-657 images back on the render thread.
    • The cap is now an 8th of the VRAM allowance (128 MB to 1 GB; 1.17 GB on this card), a safety net above the burst. VRAM pressure is the arbiter's to answer.
    • The measurement against main (afc4d1ad, the reaper with no cap) is building now: 2 runs a side, with peak VRAM and RAM.
  2. What reap_now returns. Right: a share of a block leaves the block with VMA.
    • It now returns only what its dedicated allocations give back (allocation_dedicated, VMA's vmaGetAllocationInfo2).
    • With only shares queued, it frees every queued entry of that ledger and says 0, so the arbiter goes on asking the other pools.
  3. Choosing by the image's ledger alone. Right: a buffer alone (a timed-out write-back's), or a system-memory image with a VRAM buffer, was skipped.
    • An entry is now chosen by either allocation's ledger, or by a sparse texture's chunks for VRAM, counting only that ledger's bytes.
    • tests/test_image_reaper_threads.py has the cases: dedicated images, shares, mixed ledgers, a buffer alone. A copy that counts allocation sizes, or chooses by the image's ledger alone, fails it.

Measured on the old cap, one run a side with a simulated 3 GB card (RX_VK_TEST_VRAM_MB=3072):

Reaper on RX_VK_REAPER=0
Time freeing images (tex_frame_ms) p99, camera turning in the Market 2.3 ms 22.6 ms
Same, arriving in Hyrule Field 5.0 ms 17.8 ms
Peak VRAM, the driver's count 5,287 MB 5,059 MB
  • RAM is about the same on both sides.
  • No device loss.
  • No compaction pass ran, and the arbiter didn't ask the reaper: the pressure path hasn't run in the game yet.

πŸ€– Generated with Claude Code

The review's three points, in 92e963c0: 1. **The cap.** Agreed: every measured arrival in Hyrule Field reached it on the RTX 3080. - 4 runs with the reaper on: 436-444 images and 255 MB, with 199-657 images back on the render thread. - The cap is now an 8th of the VRAM allowance (128 MB to 1 GB; 1.17 GB on this card), a safety net above the burst. VRAM pressure is the arbiter's to answer. - The measurement against `main` (afc4d1ad, the reaper with no cap) is building now: 2 runs a side, with peak VRAM and RAM. 2. **What `reap_now` returns.** Right: a share of a block leaves the block with VMA. - It now returns only what its dedicated allocations give back (`allocation_dedicated`, VMA's `vmaGetAllocationInfo2`). - With only shares queued, it frees every queued entry of that ledger and says 0, so the arbiter goes on asking the other pools. 3. **Choosing by the image's ledger alone.** Right: a buffer alone (a timed-out write-back's), or a system-memory image with a VRAM buffer, was skipped. - An entry is now chosen by either allocation's ledger, or by a sparse texture's chunks for VRAM, counting only that ledger's bytes. - `tests/test_image_reaper_threads.py` has the cases: dedicated images, shares, mixed ledgers, a buffer alone. A copy that counts allocation sizes, or chooses by the image's ledger alone, fails it. **Measured on the old cap, one run a side with a simulated 3 GB card** (`RX_VK_TEST_VRAM_MB=3072`): | | Reaper on | `RX_VK_REAPER=0` | |---|---|---| | Time freeing images (`tex_frame_ms`) p99, camera turning in the Market | 2.3 ms | 22.6 ms | | Same, arriving in Hyrule Field | 5.0 ms | 17.8 ms | | Peak VRAM, the driver's count | 5,287 MB | 5,059 MB | - RAM is about the same on both sides. - No device loss. - No compaction pass ran, and the arbiter didn't ask the reaper: the pressure path hasn't run in the game yet. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
Author
Member

Measured 92e963c0 against main afc4d1ad (#792's reaper, no cap) on Windows 11, RTX 3080, NVIDIA 621.14: 4 runs interleaved A B B A, the camera turning in the Market, then the arrival in Hyrule Field. The table is in Measurements.

The 1 GB cap is still reached on arriving in Hyrule Field.

  • The queue at most: 761-1,015 images and 1,023 MB.
  • 25-65 images were destroyed back on the render thread there, against 199-657 with the first cap.
  • The render thread's time freeing images on arriving: p99 5.0-11.1 ms, against main's 2.4-5.4. Its worst frame: 43-54 ms, against main's 75-93.
  • Turning in the Market, the two are alike: p99 1.2-1.5 ms against 1.4-1.8.

So a fixed cap is the wrong bound. Leaving the Market lets go of more than 1 GB at once.

  • Next: a bound by the room left under the arbiter's 90 % line. The queue holds a burst while the driver's count plus the queue stays under that line, and past it frees in place, as main did before #792.

main's two runs were disturbed. Another job on the PC ran at the series' start: 14 and 29 fps turning, against 39-49 in every earlier run. Their frame times can't be compared. They're being run again with nothing else in the queue.

Peak VRAM, the driver's count: 6,854-7,947 MB here against 7,057-7,093 on main. It comes from the budget line about every 12 s, so a burst's peak can fall between two lines.

Still WIP.

πŸ€– Generated with Claude Code

Measured 92e963c0 against `main` afc4d1ad (#792's reaper, no cap) on Windows 11, RTX 3080, NVIDIA 621.14: 4 runs interleaved A B B A, the camera turning in the Market, then the arrival in Hyrule Field. The table is in Measurements. **The 1 GB cap is still reached on arriving in Hyrule Field.** - The queue at most: 761-1,015 images and 1,023 MB. - 25-65 images were destroyed back on the render thread there, against 199-657 with the first cap. - The render thread's time freeing images on arriving: p99 5.0-11.1 ms, against `main`'s 2.4-5.4. Its worst frame: 43-54 ms, against `main`'s 75-93. - Turning in the Market, the two are alike: p99 1.2-1.5 ms against 1.4-1.8. **So a fixed cap is the wrong bound.** Leaving the Market lets go of more than 1 GB at once. - Next: a bound by the room left under the arbiter's 90 % line. The queue holds a burst while the driver's count plus the queue stays under that line, and past it frees in place, as `main` did before #792. **`main`'s two runs were disturbed.** Another job on the PC ran at the series' start: 14 and 29 fps turning, against 39-49 in every earlier run. Their frame times can't be compared. They're being run again with nothing else in the queue. Peak VRAM, the driver's count: 6,854-7,947 MB here against 7,057-7,093 on `main`. It comes from the budget line about every 12 s, so a burst's peak can fall between two lines. Still WIP. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
First-time contributor

On Linux this does not compile (clang 23.1.5, the AppImage toolchain), so nightly-627 + this PR fails in vk_vma.cpp:

gpu/vk/vk_vma.cpp:404:9: error: return type 'unsigned long' must match previous return type 'unsigned long long' when lambda expression has unspecified explicit return type

The lambda in reap_cap() returns 256ull << 20 (unsigned long long) on one path and std::clamp<uint64_t>(...) (unsigned long, since uint64_t is unsigned long on Linux) on the other; on Windows both are unsigned long long, which is why it builds there. return static_cast<uint64_t>(256ull << 20); on the fallback path makes both returns uint64_t and the Linux build proceeds.

On Linux this does not compile (clang 23.1.5, the AppImage toolchain), so nightly-627 + this PR fails in `vk_vma.cpp`: ``` gpu/vk/vk_vma.cpp:404:9: error: return type 'unsigned long' must match previous return type 'unsigned long long' when lambda expression has unspecified explicit return type ``` The lambda in `reap_cap()` returns `256ull << 20` (unsigned long long) on one path and `std::clamp<uint64_t>(...)` (unsigned long, since `uint64_t` is `unsigned long` on Linux) on the other; on Windows both are `unsigned long long`, which is why it builds there. `return static_cast<uint64_t>(256ull << 20);` on the fallback path makes both returns `uint64_t` and the Linux build proceeds.
Author
Member

main afc4d1ad run again, 2 runs, alone in the queue. Measurements now has these as its main column.

main, run again this PR @ 92e963c0
Market, turning: fps 34.9-36.5 33.5-42.1
Market, turning: frame time p99 49-54 ms 42-54 ms
Market, turning: tex_frame_ms p99 1.33-1.59 1.19-1.53
Hyrule Field, arriving: frame time p99 72.6-103.3 ms 78.4-104.6 ms
Hyrule Field, arriving: tex_frame_ms p99 4.67-5.10 5.01-11.13
Hyrule Field, arriving: tex_frame_ms max 25.5-41.5 42.8-53.9
Peak VRAM, the driver's count 7,016-7,018 MB 6,854-7,947 MB
  • Frame times: within the spread.
  • Arriving in Hyrule Field: this PR's time freeing images is a little higher than main's, as the 25-65 frees its cap sends back to the render thread there would make it.
  • So: the 1 GB cap costs a little and gains nothing over main. It will change to a bound by the free room under the arbiter's line.
  • Caveat: these main runs came right after this PR's, not interleaved with them.

πŸ€– Generated with Claude Code

`main` afc4d1ad run again, 2 runs, alone in the queue. Measurements now has these as its `main` column. | | `main`, run again | this PR @ 92e963c0 | |---|---|---| | Market, turning: fps | 34.9-36.5 | 33.5-42.1 | | Market, turning: frame time p99 | 49-54 ms | 42-54 ms | | Market, turning: `tex_frame_ms` p99 | 1.33-1.59 | 1.19-1.53 | | Hyrule Field, arriving: frame time p99 | 72.6-103.3 ms | 78.4-104.6 ms | | Hyrule Field, arriving: `tex_frame_ms` p99 | 4.67-5.10 | 5.01-11.13 | | Hyrule Field, arriving: `tex_frame_ms` max | 25.5-41.5 | 42.8-53.9 | | Peak VRAM, the driver's count | 7,016-7,018 MB | 6,854-7,947 MB | - **Frame times:** within the spread. - **Arriving in Hyrule Field:** this PR's time freeing images is a little higher than `main`'s, as the 25-65 frees its cap sends back to the render thread there would make it. - **So:** the 1 GB cap costs a little and gains nothing over `main`. It will change to a bound by the free room under the arbiter's line. - **Caveat:** these `main` runs came right after this PR's, not interleaved with them. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
Author
Member

This PR @ 92e963c0 run again, 2 runs, alone in the queue, right after main's rerun. Measurements now compares the two reruns.

main, run again this PR, run again
Market, turning: fps 34.9-36.5 44.7-45.5
Market, turning: frame time p99 49-54 ms 37-41 ms
Hyrule Field, arriving: frame time p99 73-103 ms 50-55 ms
Hyrule Field, arriving: tex_frame_ms p99 4.7-5.1 3.3-3.6
Hyrule Field, arriving: tex_frame_ms max 26-42 9-20
The reaper's queue at most not logged 724-964 images, 866-1,023 MB
Destroyed where handed over (the cap) none 6-29

Not settled. The sides ran one after the other, not interleaved. This PR is also 25 % faster turning in the Market, where the reaper should change the frame little. So the PC's state probably moved between the two pairs, and the frame times can't be credited to the change.

The render thread's own time freeing images is less exposed to that, and it agrees with the cap holding on these arrivals. One of the two runs still reached the 1 GB cap.

Next: an interleaved series, A B B A, with nothing else in the queue.

πŸ€– Generated with Claude Code

This PR @ 92e963c0 run again, 2 runs, alone in the queue, right after `main`'s rerun. Measurements now compares the two reruns. | | `main`, run again | this PR, run again | |---|---|---| | Market, turning: fps | 34.9-36.5 | 44.7-45.5 | | Market, turning: frame time p99 | 49-54 ms | 37-41 ms | | Hyrule Field, arriving: frame time p99 | 73-103 ms | 50-55 ms | | Hyrule Field, arriving: `tex_frame_ms` p99 | 4.7-5.1 | 3.3-3.6 | | Hyrule Field, arriving: `tex_frame_ms` max | 26-42 | 9-20 | | The reaper's queue at most | not logged | 724-964 images, 866-1,023 MB | | Destroyed where handed over (the cap) | none | 6-29 | **Not settled.** The sides ran one after the other, not interleaved. This PR is also 25 % faster turning in the Market, where the reaper should change the frame little. So the PC's state probably moved between the two pairs, and the frame times can't be credited to the change. The render thread's own time freeing images is less exposed to that, and it agrees with the cap holding on these arrivals. One of the two runs still reached the 1 GB cap. Next: an interleaved series, A B B A, with nothing else in the queue. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
Author
Member

main run a third pair, alone in the queue, right after this PR's rerun: 30.5-33.9 fps turning in the Market, against this PR's 44.7-45.5.

So main was slower both before and after this PR's pair, and the PC's drift over time doesn't explain the gap.

The difference is on the game's CPU threads, not the renderer's. Medians a run:

main (4 runs alone) this PR (2 runs alone)
game_ms, turning in the Market 24.4-29.2 19.9-20.4
render_ms, turning in the Market 0.4-0.5 0.4
gpu_wait_ms, turning in the Market 0.06-0.07 0.05

This PR changes only the renderer (longshot_vk.dll). The two runtimes' longshot.exe have identical link maps (1,306,036 lines, all but the link timestamp the same), and their logs' setup lines match: switches, driver, cores, policy.

So the frame-time gap between the two runtimes is not this change, and the frame-time rows in Measurements are not a gain. The render thread's own tex_frame_ms rows are what this PR moves.

A comparison that leaves the runtime out: one runtime, with only longshot_vk.dll swapped between main's and this PR's before each run, interleaved.

πŸ€– Generated with Claude Code

`main` run a third pair, alone in the queue, right after this PR's rerun: 30.5-33.9 fps turning in the Market, against this PR's 44.7-45.5. So `main` was slower both before and after this PR's pair, and the PC's drift over time doesn't explain the gap. **The difference is on the game's CPU threads, not the renderer's.** Medians a run: | | `main` (4 runs alone) | this PR (2 runs alone) | |---|---|---| | `game_ms`, turning in the Market | 24.4-29.2 | 19.9-20.4 | | `render_ms`, turning in the Market | 0.4-0.5 | 0.4 | | `gpu_wait_ms`, turning in the Market | 0.06-0.07 | 0.05 | This PR changes only the renderer (`longshot_vk.dll`). The two runtimes' `longshot.exe` have identical link maps (1,306,036 lines, all but the link timestamp the same), and their logs' setup lines match: switches, driver, cores, policy. So the frame-time gap between the two runtimes is not this change, and **the frame-time rows in Measurements are not a gain.** The render thread's own `tex_frame_ms` rows are what this PR moves. A comparison that leaves the runtime out: one runtime, with only `longshot_vk.dll` swapped between `main`'s and this PR's before each run, interleaved. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
HumanBean changed title from WIP: perf(vk): the image reaper's queue is bounded and gives its memory back near the VRAM allowance to perf(vk): the image reaper's queue is bounded and gives its memory back near the VRAM allowance 2026-11-20 22:21:17 +00:00
HumanBean deleted branch perf/reaper-bounded 2026-11-20 22:21:26 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!1914
No description provided.