fix(vk): admit newly needed capture buffer sizes into a full spare pool #2281
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2281
Loading…
Reference in a new issue
No description provided.
Delete branch "tevan/Longshot:fix/capture-spare-admission"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
After an area's buffer sizes change, the capture-spare pool can keep allocating a newly needed size on every submission. Twelve small spares cannot serve a large request, but
cap_buf_freerejects the completed large buffer because those twelve slots remain occupied. A pool full by bytes can reject newly needed sizes even below twelve entries.Let a completed real capture displace oldest-returned spares until its entry and bytes fit the existing limits. Pending prewarm workers keep their byte/slot reservations, and speculative workers cannot evict returned spares. Displaced objects are released after unlocking, through the existing asynchronous path or its synchronous kill switch. The eviction list is a fixed array, so admission itself needs no new heap allocation.
Read
cap_buf_freeingpu/vk/vk_memory.cppandtests/test_capture_spare_admission.pyfirst. See #2220. This proposes a fix for the demonstrated admission bug; mitigation of the reported Lost Woods/Dodongo long-session slowdowns remains unproven. Related merged #1553/#1848/#1933 do not replace unsuitable spares; open #2244 changes when copies run, rather than spare admission, and is not a dependency.The branch is now rebased onto main
0e32bc100dbe9e6c35602c33afa120ed4a88bab5, headac5177783ac9c9791048ab93a15771a3c67b78cb. Review L1 isolates the regression executable from inheritedRX_VK_CAP_MIN_MB; the renderer implementation is unchanged. The branch still reads test first, then fix. The replacement farm request compares the farm-selected main and PR, without historical revision constraints. The older commit IDs in the measurement table identify prior local evidence, not requested farm revisions.Testing
Tested: RX 6800 XT 16 GB, RADV Mesa 26.2.5-arch1.1, Ryzen 5 7600X, 32 GB RAM, Linux 7.2.11-arch1-1.
0e32bc10for the allocation count, not compilation (also reproduced on the earliera2dc5385base). The fix passes with GCC and Clang: sixteen requests use one driver allocation instead of sixteen. Coverage includes entry and byte exhaustion, 24 in-flight captures with mixed sizes, worker reservations, speculative prewarming, pressure limits, and exactly-once release outside the mutex.<array>include for its production-function cut.6caf914cran against current main0e32bc10in Hyrule Field at 3440x1440 / 75% render, frame generation off, uncapped, in queued A/B/A/B runs with isolated saves/options, 30 measured seconds each. Neither side had a frame of 50 ms or more; the short healthy scene did not reproduce the reported long-session problem.cap_buf_get,cap_buf_size,cap_buf_freeandcreate_buffer_cached; it observes real host-cached GPU mappings, not a stand-in allocator. Details and limitations are below.Renderer-identical prior-head validation: Full strict suite on
6caf914c: 936 passed, four failures, 18 explicit platform/GPU skips. All four failures reproduce on unchanged main0e32bc10:tests/test_dev_packs.py,tests/test_mise_build.py,tests/test_pipeline_state_computes.py,tests/test_saveload_warm_cache.py. Skips are not counted as passes. Additionally, all 82 strict changed-source checks pass; focused GCC/Clang, spare-reuse and async-free checks pass; pre-commit checks pass. Complete Linux renderer and Windows renderer cross-build/link/export checks pass. Windows compilation used the project-pinned llvm-mingw 20261104 via the supported CI cross-build path, with no game/dump needed. Actionlint's unchanged SC2016 is the same pre-existing workflow finding described earlier.Historical mechanism evidence carried across the rebase: This fix was already run in-game on this PC at head
5499ba8aagainst maina2dc5385. The entire capture-memory module (including the admission callers, structures and locks) has no upstream changes between that base and current main; the cached Vulkan allocation/destruction functions are also unchanged. The authored fix remains byte-for-byte identical. The historical native fixture therefore measures the same allocation mechanism, and the earlier game run remains an integration smoke test of this change. Upstream changes elsewhere can affect whole-game performance: the old FPS results are not claimed to be current-head measurements or proof of frame-pacing neutrality. The fresh current-head comparison below independently checks the current integration; old numbers are not relabeled.The guide permits other-hardware and rare-path testing during review. The remaining runtime/long-session checks below are still open; none is represented as completed.
Review L1 validation: The original fixture fails with caller
RX_VK_CAP_MIN_MB=256; the corrected fixture removes only that override from the child environment. It passes with both GCC and Clang for caller values 2, 16 and 256. The corrected test still compiles and fails on main for 16 allocations versus the required 1, with both compilers. All 82 strict changed-source checks and pre-commit pass. No renderer source changed from game-tested6caf914c; the game/build evidence below keeps its actual revision labels and applies to identical renderer code.Still to test:
Measurements
Verdict: the admission bug is reproduced on current main and gone with this PR. Current production-function tests make 16 allocations on main and 1 here for the same sixteen requests, under GCC and Clang. That is the demonstrated fix measurement under the project's
fixrule; no whole-game FPS gain or resolution of the original long-session episodes is claimed.Setup: current main
0e32bc10versus headac517778, Linux x86-64, GCC and Clang, C++17 production-function extraction with a counting allocator; twelve unsuitable 2 MiB spares, sixteen requests for the 128 MiB class, return after each request. Baseline compiles and fails the reuse assertion for the allocation count; this PR passes.0e32bc100dac5177783aLatest game comparison (renderer identical to current head):
Verdict: no difference shown: -0.8% fps (median 115.7 against 116.6), within the runs' spread (A 115.7 to 117.5, B 114.6 to 116.8).
Setup: Linux 7.2.11-arch1-1, RX 6800 XT, RADV Mesa 26.2.5-arch1.1; Hyrule Field, child (open, far view) (window 3440x1440); quality preset Custom, resolution 75% (2580x1080), output res 3440x1440 (native), frame generation Off, vsync Off; uncapped (HOS_FPS_MAX=1000); the frame trace, 30 s each after a warm-up until no frame waited for a pipeline, 2 interleaved pairs, the median;
dev.py ab0e32bc106caf914cSpread: observed fps ranges: A 115.7 to 117.5; B 114.6 to 116.8. These ranges do not predict what another run will show.
Historical local measurements (before rebase):
Verdict: fixes the production-function admission regression and reduces real-RADV allocation/mapping work in the reproducer. No gameplay FPS improvement is demonstrated: the short game comparison is within spread. The original long-session mitigation is still to test.
Game setup: same PC above, Hyrule Field (child), windowed 3440x1440, Custom preset, 75% render (2580x1080), frame generation/V-Sync off,
HOS_FPS_MAX=1000, frame trace; at least 10 seconds warm-up until no frame waited for a pipeline, then 30 seconds measured, A/B/A/B. All game runs/builds used the project queue and shared base/pack runtimes.Native experiment setup: same real RX 6800 XT/RADV; twelve initial 2 MiB spares, sixteen requests for 96 MiB (128 MiB allocation class), four CPU-copy workers, A/B/A/B, medians. Both sides use production cached Vulkan allocation via VMA and host-cached mappings. No GPU commands are submitted. It models immediate get/return with synchronous freeing, rather than gameplay's normal asynchronous release and full retirement pipeline; its timings are not gameplay frame-time predictions. Source initialization/instance/device setup are outside the measured loop.
a2dc5385905499ba8adbNative run spread: main major faults 14,869 / 15,101, loop 154.977 / 150.731 ms; branch major faults 854 / 891, loop 92.969 / 91.864 ms. Game FPS ranges overlap; a gain there is not claimed. Peak RAM/VRAM and longer area-load behavior are not yet measured.
Risks
FIFO replacement may release a cold large/prewarmed spare earlier, changing a later area's allocation cost. Mixed-size loading, peak memory and longer play therefore remain explicit validation gaps. Entry/byte ceilings and worker reservations stay unchanged; only completed spares are displaced.
RX_VK_CAP_FREE_ASYNC=0still permits synchronous destruction, outside the pool mutex; no switch is added or changed. A revert restores the old policy. No API, settings, save or cache-format change.No game files, saves, options, binaries, caches, raw profiles or local paths are attached; measurements here are aggregate text.
Checklist
Ready for review
main; the title is a Conventional Commit. Rebased onto0e32bc10.mise run testpasses (any failure that also fails onmainis named). Strict results, the test-only follow-up and four unchanged-main failures are named above; explicit platform/GPU skips are not counted as passes.main, or Measurements says why there is nothing to measure. The current-main production-function regression is demonstrated; renderer-identical game comparison and labeled historical mechanism evidence are included, and unconfirmed long-session work remains in Still to test.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Ready to merge
Tested in game: RX 6800 XT 16 GB, RADV Mesa 26.2.5-arch1.1, Linux 7.2.11-arch1-1: queued isolated Hyrule Field A/B/A/B, 3440x1440 output / 75% render, frame generation and V-Sync off, uncapped, 30 measured seconds per run after warm-up; main
a2dc5385median 116.0 FPS versus head5499ba8a116.2 FPS, within spread, no frames >=50 ms on either side. Candidate rendered normally. The reported long-session Lost Woods/Dodongo slowdown was not reproduced and is not claimed fixed. Source regression and real-RADV-buffer experiments independently demonstrate admission churn and reduced mapping faults.@Beanstalk please validate the Windows renderer build and run this PR on Windows AMD, Windows NVIDIA, and Steam Deck, with a maintainer's approval.
Use main
a2dc5385901812d183c4b7f0f9d48b295f17a510(the tested base) against PR head5499ba8adbeb4cf8a5ec5284b72facbc49f76c1f, identical scene/settings/save copies, two interleaved area-change tours per side through Kokiri Forest, Hyrule Field, Market and Kakariko. Record crashes, rendering errors, peak RAM/VRAM, frame pacing/frames >=50 ms and the renderer's capture-spare/budget lines. Expect the existing entry/byte limits and worker reservations to hold, and no new rendering/load regression. Include a short smoke with RX_VK_CAP_FREE_ASYNC=0 to exercise synchronous release outside the pool lock, alongside the normal default.The PR stays WIP: a rebase and measurements against latest main are separate outstanding author work. Do not attribute a comparison against a different/unmatched base to this admission change. The short Linux game A/B showed no FPS difference beyond spread; the real-RADV allocation/mapping reproducer is the demonstrated gain. These requests do not assert that the reported long-session episodes are fixed.
@tevan only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.Beanstalk test farm
Commit
ac51777· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Rebased onto current main
753fb5af; new heada8369e79. The authored four-file diff and admission functions are unchanged. Focused GCC/Clang checks, full Linux renderer rebuild/export checks and pre-commit checks pass; the current strict suite has 936 passes and four failures reproduced on unchanged current main, all named in the description. Historical game/native measurements remain labeled with the revisions actually tested. The rejected farm request will be replaced with the supported farm-selected main-versus-PR build/area-tour plan, without commit constraints or custom allocator/log assertions. The PR remains WIP for fresh game/memory/long-session and Windows coverage.@Beanstalk please replace the earlier request with this supported main-versus-PR compatibility plan.
Compare the farm's current main and this PR on Windows AMD, Windows NVIDIA and Steam Deck. Use the revisions selected by the farm and record their commit IDs in the results. Build both sides, then run two interleaved area-change tours per side through Kokiri Forest, Hyrule Field, Market and Kakariko Village, with identical settings and save copies per device.
Compare still-scene pictures using the farm's normal image tolerance, crashes, median/p99 frame times, and load times. Flag a frame-time or load-time regression above 10%. Record peak RAM and VRAM for comparison. Add a short startup/area-change smoke with RX_VK_CAP_FREE_ASYNC=0 to check the synchronous-release configuration.
These are build, rendering and area-tour checks. The production-function regression, allocator/fault experiment and reservation/retention invariants are separate local/unit validations; the original long-session slowdown remains a separate validation gap. This request does not select historical commits, parse custom capture-budget log lines, require a particular cache-eviction event, or claim to prove the original hitches fixed.
A BigBeans maintainer may need to approve this replacement request for the rebased head with 👍. Please generate a fresh plan rather than override the earlier rejected plan.
@tevan only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was fora8369e7, and the PR has changed since (6caf914), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.5499ba8adba8369e79a6a8369e79a66caf914c51Rebased again onto current main
0e32bc10, head6caf914c, preserving the unchanged authored admission fix. Full Linux renderer and full Windows renderer cross-build/link/export checks pass; 82 changed-source checks pass; full strict suite has 936 passes and the same four failures reproduced on unchanged current main. The author owns marking this PR ready under the project guide; it will not remain WIP merely for Test Farm/other-hardware runtime coverage. The approved fresh on-PC A/B/A/B is in progress now, after which I will assess ready status. The supported main-versus-PR farm request remains unchanged; historical measurements stay under their original commit labels.Fresh approved current-head Hyrule Field A/B/A/B is complete: main
0e32bc10versus PR6caf914c, identical copied settings/private saves, 30 measured seconds per run after warmup. Median 116.6 versus 115.7 FPS (-0.8%, within observed spread), median frame time 8.57 ms both, p99 10.00 versus 10.34 ms, no measured frames of at least 50 ms. No FPS gain or long-session mitigation is claimed. Current production-function regression remains 16 versus 1 allocations under GCC and Clang. Full strict suite: 936 passed, four named failures reproduced on unchanged main, 18 explicit skips; all 82 changed-source checks, Linux and Windows renderer builds/exports and pre-commit pass. Description/checklists updated; remaining farm, mixed-area and long-session coverage stays explicit for review. Marking ready under the author-owned workflow; no merge requested.WIP: fix(vk): admit newly needed capture buffer sizes into a full spare poolto fix(vk): admit newly needed capture buffer sizes into a full spare pool@review
Recommendation: Approve. The test demonstrates that returned buffers can now enter a full spare pool, but the replacement policy’s effects during area changes and on other supported systems remain unmeasured. CI is also still running. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
Returned capture buffers can displace older spares, avoiding repeated allocations when the needed size mix changes. This may release a prewarmed buffer that a later area needs, trading the fixed allocation churn for a possible later allocation and memory cost.
Should fix (1): not blocking, but worth doing before merging.
tests/test_capture_spare_admission.py:168: The fixture inherits RX_VK_CAP_MIN_MB from the caller, so its allocation-class assertions depend on the developer’s environment. (more on the line) Do: Run the fixture with RX_VK_CAP_MIN_MB removed from its environment, or explicitly set a controlled value.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:1426: Measure replacement during mixed-area and long-session play, including its allocation and memory costs. (more on the line) Do: Compare current main and this head over repeated mixed-area and reported long-session workloads, recording allocation rates, load and frame times, and peak RAM and VRAM.gpu/vk/vk_memory.cpp:1426: Complete the requested Windows AMD, Windows NVIDIA and Steam Deck runtime comparisons. (more on the line) Do: Run the requested main-versus-PR area tours and synchronous-release smoke, comparing rendering, load and frame times and peak memory.@fixcan do L1.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the demonstrated admission bug: the production-function fixture reports 16 allocations on main and 1 on this branch for 16 requests. The current-head game comparison shows no FPS gain outside run-to-run spread; mitigation of the reported long-session slowdown remains unproven.
Other systems: The pool is shared by capture paths on Windows and Linux across GPU vendors. Replacement can change later allocation, release and memory behavior; current game evidence covers a short Linux RADV scene, while mixed-area, Windows and Steam Deck runs remain outstanding.
Switches: None added, changed or removed. Existing RX_VK_CAP_FREE_ASYNC defaults on; displaced buffers use its existing asynchronous or synchronous release path.
Reviewed:
6caf914c51against0e32bc100d: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, both changed tests, the complete diff and commit messages. Read the changed function and surrounding capture allocation, reservation and release code in vk_memory.cpp; the rest of that large code file and architecture.md were skimmed. docs/review-checklist.md and the sibling Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. Author-reported Linux and Windows builds and test results were considered; the listed CI checks are still running.
Overlaps and merge order: The description identifies open #2244 as changing copy scheduling rather than spare admission; no dependency is claimed. Other open pull requests were not available for inspection.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -1416,0 +1423,4 @@// speculative prewarming never displaces a buffer a real submission returned.if (!from_worker && size <= (256ull << 20) && workers < 12 &&pending <= limit && size <= limit - pending) {while (!cap_free.empty() && (cap_free.size() + workers >= 12 ||L2 (should fix): Measure replacement during mixed-area and long-session play, including its allocation and memory costs.
When: A returned small capture can evict an older large prewarmed spare; a later load that needs that class must allocate it again. The short Hyrule Field comparison does not exercise the reported area transitions or measure peak memory.
Do: Compare current main and this head over repeated mixed-area and reported long-session workloads, recording allocation rates, load and frame times, and peak RAM and VRAM.
L3 (should fix): Complete the requested Windows AMD, Windows NVIDIA and Steam Deck runtime comparisons.
When: The same replacement and release path runs on these systems, where allocation and destruction costs can differ from the tested Linux RADV device; no runtime results are yet recorded for them.
Do: Run the requested main-versus-PR area tours and synchronous-release smoke, comparing rendering, load and frame times and peak memory.
@ -0,0 +165,4 @@"""with tempfile.TemporaryDirectory() as folder:path = Path(folder)(path / "test.cpp").write_text(fixture)L1 (should fix): The fixture inherits RX_VK_CAP_MIN_MB from the caller, so its allocation-class assertions depend on the developer’s environment.
When: With RX_VK_CAP_MIN_MB=256, cap_buf_size chooses a 256 MiB minimum; the cold-large-buffer scenario can reuse its existing 256 MiB spare and fails the assertion that one new allocation occurred.
Do: Run the fixture with RX_VK_CAP_MIN_MB removed from its environment, or explicitly set a controlled value.
L1 addressed in head
ac517778(test-first commitde6cc4c0): remove inherited RX_VK_CAP_MIN_MB only from the fixture executable environment, preserving other environment settings. Reproduced the original assertion failure at caller value 256; updated fixture passes GCC and Clang at caller values 2, 16 and 256, and still fails on main for 16 allocations rather than 1 with both compilers. All 82 strict changed-source checks and pre-commit pass. The test-only change is folded into the test commit to preserve test-then-fix history. Renderer/docs are byte-identical to reviewed and game-tested6caf914c, so prior build/game results retain their actual revision labels and no extra game run was needed. L2 remains open: longer mixed-area/Lost Woods/Dodongo comparisons with allocation, load/frame and peak-memory measurements have not run; the short static scene cannot establish those results. L3 remains open for Windows AMD/NVIDIA and Steam Deck runtime coverage; refreshing the stale supported farm request for this head next. CI still requires repository approval. No merge-readiness boxes are ticked.6caf914c51ac5177783a@Beanstalk please renew the supported main-versus-PR compatibility request for current head
ac517778. The prior approval request is stale after the test-only L1 correction; renderer code is unchanged from6caf914c. This covers review L3; L2 long-session testing remains separate.Compare the farm's current main and this PR on Windows AMD, Windows NVIDIA and Steam Deck. Use the revisions selected by the farm and record their commit IDs in the results. Build both sides, then run two interleaved area-change tours per side through Kokiri Forest, Hyrule Field, Market and Kakariko Village, with identical settings and save copies per device.
Compare still-scene pictures using the farm's normal image tolerance, crashes, median/p99 frame times, and load times. Flag a frame-time or load-time regression above 10%. Record peak RAM and VRAM for comparison. Add a short startup/area-change smoke with RX_VK_CAP_FREE_ASYNC=0 to check the synchronous-release configuration.
These are build, rendering and area-tour checks. The production-function regression, allocator/fault experiment and reservation/retention invariants are separate local/unit validations; the original long-session slowdown remains a separate validation gap. This request does not select historical commits, parse custom capture-budget log lines, require a particular cache-eviction event, or claim to prove the original hitches fixed.
A BigBeans maintainer may need to approve this replacement request for this head with 👍. Please generate a fresh plan rather than override the earlier rejected plan.
@tevan only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.L2: I can run the mixed-area/long-session comparison locally on Linux/RADV. L3: I do not have Windows AMD/NVIDIA or Steam Deck systems available for runtime testing, so those comparisons need the Test Farm or another tester; the farm request is posted and awaiting maintainer approval.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.