perf(agc): let the storage image cache take up to half of the heap budget #10044
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10044"
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?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-23T06:07:21Z.
What
The storage image cache's budget is what the reported heap budget leaves after three things: the heap's use outside the texture caches, the live sampled textures, and an eighth of the budget. That result is then capped at the smaller of
TextureCacheBudget(a quarter of the heap, at least 2 GiB) and a quarter of the budget. On an 8 GB GPU, the quarter caps bind first, at about 1.5-1.7 GiB, even when the budget formula leaves far more.Echoes of the End (PPSA25636) needs about 3.5-4 GiB of storage images in play. With the quarter caps it re-creates them all the time. In gameplay, with the default budgets, it evicted about 2000 storage images (about 22 GiB) every 10 s, and re-created and re-uploaded them on their next use. The technical debt entry for the budgets describes this case: "a title whose storage working set exceeds the shrunk budget re-creates storage images at each use".
This PR changes only the caps, to half of the heap's size and half of the reported budget. The reserve is unchanged: the other use, the live sampled textures and the eighth of the budget are still kept out. The 512 MiB floor and the fallback without
VK_EXT_memory_budgetare also unchanged. A heap under pressure therefore still shrinks the storage cache as before. The higher cap applies only when the budget has room.Tested
storageTextureBudgetTestsis revised on purpose:9904c737ca(adds the sampled-budget storage reservation from review). Exact-head gate:main1b5efcc8d916/16; this PR with the new reservation reverted 15/16, failing only "a storage image cache larger than TextureCacheBudget was not reserved in full"; this PR 16/16. 4 layer insertions and 0 VUIDs per arm. Details: https://github.com/boykopovar/AnyPS5/pull/10044#issuecomment-6377087529. The joint sweep asserts that above the floors neither cache budget plus the other cache's held bytes exceeds the reported budget less its eighth.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -V -j1 -R '^(agc_driver_graphics|agc_sparse_.*|agc_heap_mirror_.*|agc_host_import.*)$'. Machine: Linux 7.2.9, RX 6650 XT, RADV (Mesa 26.2.4).Results:
b7a451d62bb7a451d62b+tests/Graphics.cppfrom the changeagc_driver_graphicsfails with "a 10 GiB budget on the 16 GiB heap does not limit the storage image cache to half of the budget"92b3bf8f8b(the same source and tests as the heada2f89cad59, whose later commit only condenses the debt entry)Every arm prints only the two existing Windows guest-arena skips ("heap mirrors not tested", "heap mirrors of imported ranges not tested").
e3f17c7043) and with it (52893755e9), in one build directory. Both carry private diagnostic commits; none of them is part of this PR.Each arm starts from the same seed (the save in play, the shader caches and a private Mesa cache) and gets the same scripted input. Capture:
APS5_TRACE_SECONDS=1150:300, a static scene in play.The reported heap budget is pinned. The VK_EXT_memory_budget heap budget varies by about 1 GiB from run to run on this machine, with other VRAM users, and moves the storage budget as much as the cap does. So a private override,
APS5_DIAG_HEAP_BUDGET_MIB(not part of this PR), sets the value both budget functions read. The device's real memory use is not pinned.At 6900 MiB this change gives about 1 GiB more storage budget, +24-26 % presents, -13 to -17 % frame p50 and -17 to -19 % GPU busy, in both orders. Other workers' compilations overlapped the first pair's "without" arm; the repeat is clean.
At 6300 MiB the reserve, not the cap, limits the storage cache. The difference is within noise. This change helps only where the budget has room above a quarter.
0 amdgpu kernel events in every arm. Both traces of the repeat dropped some queue-worker events, so their phase totals are partial.
Summary JSON lines of the repeat pair (without, with):
Superseded: the first unpinned pair (296 -> 557 presents) and an alternating four-arm repeat. Both were confounded by the reported budget, which was 485-640 MiB higher in every "with" arm; see the comments.
Traces, digests and comparisons: https://github.com/JJenkx/AnyPS5/releases/tag/storage-half-evidence
Independent, attributed, limited: @Rajkamalcode measured Squirrel with a Gun (PPSA22102) on an RTX 3070 8 GB under Windows. The base is an old one that runs the title, not current
main. They used their own pinned 6900 MiB budget and one quarter -> half pair:They make no frame-rate claim, because of long zero-present intervals, and their free-running A/B was inconclusive because the reported budget moved by several GiB. Details: https://github.com/boykopovar/AnyPS5/pull/10044#issuecomment-6369594293
Diagnostic-only occupancy runs (private overrides): with a 4096 MiB storage budget, Echoes in play held about 4077 MiB of storage images, with 250 MiB of sampled textures and about 2.2 GiB outside both caches. Its storage working set is about 3.5-4 GiB.
Checklist
main; no other open PR implements the same functions. #6194 grows the storage budget while it evicts, but keeps at least 2 GiB of headroom, so on this 8 GB GPU near its budget it does not grow.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (no unimplemented path added).mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:09:31Z.
Review: APPROVED
Reviewed exact head
511ef5dd6a92cbb4ce9073497aac07605337d70b. The implementation changes only the storage-cache cap from the prior quarter-budget / quarter-heap-derived cap tomin(heap / 2, budget / 2). The existing headroom formula, sampled-texture reservation, pressure response, fallback, and 512 MiB floor remain unchanged. The revised unit cases cover both caps, the pressure floor, monotonic shrinkage under added non-cache use, and the reserved headroom invariant. Current-main sync is clean (1 ahead / 0 behind),git diff --checkpasses, and hosted eligibility, intake, conventions, labels, and report checks pass. Product build/test jobs are skipped by repository policy.I could not execute the Vulkan test locally: CMake configuration stops because SDL2 is uninitialized in this checkout and the host lacks XRandR development support. The author reports 15/15 focused Vulkan tests on the rebased patch, including a test-only negative control that fails on main. I downloaded the linked release summaries and traces and reran
tools/performance_compare.py; it reproduces the reported 296 to 557 presents, p50 1018.7 to 529.3 ms, and GPU busy 466.6 to 277.7 ms per present. The comparison flagswindow.first_presentas the only recorded configuration difference; the PR explains both measured windows begin in the same static scene. Both traces dropped detailed events, so phase attribution is partial, while the summary frame/GPU metrics remain available. I have not independently run the title or verified the physical scene.One non-blocking maintainability note: the local conventions checker emits a debt-length warning for the updated texture-budget entry (1,522 characters); the hosted conventions check passes. Trimming it to the essential contract and evidence would clear the warning.