Repository navigation
fix(agc): let the storage image cache budget follow the heap's use like the sampled one - #7071
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
…ke the sampled one StorageTextureBudget gave the storage image cache a quarter of the VK_EXT_memory_budget budget of the largest device-local heap (capped at TextureCacheBudget, never below 512 MiB) whatever else the heap held, while SampledTextureBudget takes what that budget leaves after the heap's other use. On a 10 GB card the storage cache kept 2024-2170 MiB into a level load whose depth and render target allocations then failed with VK_ERROR_OUT_OF_DEVICE_MEMORY with the heap at its reported budget where a run logged it. The storage image budget is now what the reported budget leaves after the heap's use other than the cached storage images, the unused part of the sampled textures' 2 GiB floor and an eighth of the budget; the caps at a quarter of the budget and at TextureCacheBudget and the 512 MiB floor stay. The sampled budget still reserves TextureCacheBudget for the storage cache, at least the storage cap, and the storage budget reserves the sampled textures alive, so neither counts bytes the other may take; while the sampled textures alive stay within their floor the sampled budget falls first, then the storage budget, and above it both fall together. The budget line also prints when the storage image budget moves by more than a tenth, with its previous value, and StorageTextureCacheBudget is exported for the execution test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
7342518 to
39c2366
Compare
|
Cross-validation on Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 12 GB (driver 596.21), WinLibs MinGW-w64 GCC 15.2.0, Release with
Written with Claude Code assistance (validation by a subagent, reviewed in this session). |
|
Thanks @screamm, especially for the negative control with only the formula reverted, and for two more titles on a 12 GB card. Your results are added under Tested. AI-assisted: yes (Claude Code) |
What
StorageTextureBudgetgave the storage image cache a quarter of theVK_EXT_memory_budgetbudget of the largest device-localheap (capped at
TextureCacheBudget, never below 512 MiB) whatever else the heap held, whileSampledTextureBudgettakes whatthat budget leaves after the heap's other use. On a 10 GB card the storage cache kept 2024-2170 MiB into a level load whose depth
and render target allocations then failed with
VK_ERROR_OUT_OF_DEVICE_MEMORY, the heap at its reported budget where a runlogged it (eight runs below).
The storage image budget is now what the reported budget leaves after the heap's use other than the cached storage images, the
unused part of the sampled textures' 2 GiB floor and an eighth of the budget; the caps at a quarter of the budget and at
TextureCacheBudgetand the 512 MiB floor stay. The sampled budget still reservesTextureCacheBudgetfor the storage cache(at least the storage cap) and the storage budget reserves the sampled textures alive, so neither counts bytes the other may
take; while the sampled textures alive stay within their floor the sampled budget falls first, then the storage budget, and
above it both fall together. Each cache trims at its next insert and both budgets are read at most once a second, as before.
The
[gpu] sampled texture cache budgetline now also prints when the storage image budget moves by more than a tenth, withits previous value, and
StorageTextureCacheBudgetis exported for the execution test.The debt entry "Texture cache budgets" records what is a choice here: the 2 GiB floor and the eighth are the sampled formula's
values reused, the 512 MiB floor and the caps the earlier ones, none measured beyond one title on one 10 GB GPU; a title whose
storage working set exceeds the shrunk budget re-creates storage images at each use.
Measured
007 First Light (PPSA11386) on Linux (CachyOS 7.2.10), NVIDIA GeForce RTX 3080 10 GB (driver 615.78.08), 3840x2160 render
resolution, warm shader cache, scripted pad input, the same save in each pair, logging on. None of the runs is on
mainalone(the title does not reach these points there); every stack is given. "X of Y MiB" figures are the heap's use and budget from the
driver's
[gpu] sampled texture cache budgetlines (printed when a budget moved, so a run's last line is earlier than its stop)or from its host-placement lines; "card use" is
nvidia-smimemory for the whole card, about 885 MiB of it other processes. Thehost-placement counters print at 1-5 allocations and then at powers of two, so they are lower bounds; reclaim lines are exact.
main4186f06 plus the open PRs thetitle needs to reach its level load (the stack of the bring-up thread, discussions/5714), local functional commits (one-slice
volume sampling among them) and diagnostic logging, the executable patched as in 007 First Light (PPSA11386): the terrain crash after Resume is a stale read of a GPU feedback buffer past the title's own wait limits #6172 (two feedback-wait limits widened):
one on the base alone, one on the base + feat(agc): store to images selected through image tables #6402 + fix(agc): store pending image results after the range's writers finish #6364, three on that + fix(agc): release the texture caches when a device allocation runs out of memory #6174 (two with trace logging), one on the base +
fix(agc): store pending image results after the range's writers finish #6364 + fix(agc): release the texture caches when a device allocation runs out of memory #6174, one on the latter with perf(agc): stores beside a range in its 64 KiB block leave the range unchanged #6346 reverted, one on the base + fix(agc): release the texture caches when a device allocation runs out of memory #6174. All eight stopped at the first gameplay presents
(1114-1279):
vkAllocateMemory render target: Vulkan result -2in the two without fix(agc): release the texture caches when a device allocation runs out of memory #6174,vkAllocateMemory depth target: Vulkan result -2in the six with it. Their last budget lines hold 2024-2170 MiB of cached storage images at storage budgetsof 2053-2192 MiB, with 5542-6305 of 8215-8723 MiB in use; the five runs that placed an allocation in host memory through
the budget check (a path already on
main) logged the heap at 8233 of 8259, 8491 of 8491, 8456 of 8457, 8326 of 8364 and7982 of 8022 MiB on that line, 0-14 presents before the stop.
fix(agc): place device memory in host memory when the driver refuses a device-local allocation #5987 (a refused device allocation, depth, render and copy targets included, is placed in host memory instead of failing;
the budget check's up-front placement is limited to host heaps with room), so the entry no longer stops. One run each:
3600 s without, 1500 s with, same cache, save, input and environment; the card's reported budget at start was 9195 MiB
without and 8934 MiB with. The frame-rate drop of the entry starts at present 1270 without and 1250 with (presents 1274 and
1257 at the 600 s sample in both) and the frame rate after it is within 6 %: 0.13 FPS falling to 0.05-0.06 by 1440 s, 77
presents without and 72 with between the 600 s and 1442 s samples, so the slowness there is not this memory. The memory
moves: through present 1332 (the last of the run with the change) the run without had placed at least 128 refused texture
or storage-texture allocations (1204 MiB) and at least 512 refused device buffers of the pool in host memory, with 60 pool
reclaim-and-retry cycles, the first placement at present 1289, and no up-front placement; the run with it placed at least
32 refused allocations (434 MiB, the last a depth copy) and at least 32 allocations (1252 MiB) up front through the budget
check, no pool buffer, with 3 reclaims, the first placement at present 1319. With the change the heap was at its budget at
those placements (8260-8330 of 8284-8334 MiB); the run without logs no heap figure at its refusals. The budget lines in
between show 300-1500 MiB of room at the moments a sampled texture was inserted. The storage budget read 2184 MiB on the
last line before the entry, 1795 MiB at the entry (present 1250) and reached its 512 MiB floor at present 1298, about six
minutes after the entry, leaving it twice (873 and 944 MiB); from the entry on the sampled textures alive were 2009-2404 MiB
(12 of 26 lines below their 2 GiB floor) and the heap's other use 3491-5241 MiB. A storage cache that small re-creates its
images more often: through present 1332 the run without created 7,440 storage images from present 1274 on, the run with
10,942 (47 % more per present; by about 1500 s of run time, 42,260 against 43,712). So on this stack the change means fewer
and later host placements and reclaims at the price of more storage re-creation, with the frame rate within 6 %.
mainbc3c0fc + fix(shader): apply cube output modifiers whenever IEEE mode is off #5799 fix(shader): leave out the all-zero position distance when guest distances fill all eight #6317 fix(shader): repeat phi folding until no phi folds #6332 fix(shader): poison unsupported biased volume table entries #6881 + perf(agc): GPU descriptor heap (APS5_GPU_HEAP) #6947 (which carries perf(agc): draw finisher pipeline (APS5_DRAW_PIPELINE) #6946 and rebasedperf(agc): data-only draw hits compare only the user words a stage reads #5656/perf(agc): spin before blocking on the GPU mutex and the draw committer hand-offs #6632),
APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, no executable patch, one run without and one with thechange from the same cache (two more runs without, with
APS5_DRAW_PIPELINE=1, give the spread). No change the runs canresolve: card use peaks at 8622 MiB without and 8554 MiB with (the two other runs 8553 and 8646), the main menu reached at
~1113 s without and ~1125 s with, 0.48-0.59 FPS (mean 0.56) in the menu without and 0.45-0.58 (mean 0.53) with, 35,364
storage images created in 24 minutes without and 35,192 with. The last budget line of each run, about 210 s in, has the
storage budget at its cap (2172 MiB without, 2175 with); what the budget did in the menu itself is not in these logs, since
the line prints only at sampled-cache lookups.
APS5_DRAW_PIPELINE=1 APS5_GPU_HEAP=1(the same stack's two switches, both off by default): three runs withoutthe change (one also with
APS5_VERIFY_GPU_HEAP=1, one with a different trace window) all stopped between their last presentand the driver's give-up, about 735-785 s, with
vkAllocateMemory storage texture: Vulkan result -2right after a ~7.5minute stall, their last budget lines at 7654 of 8765, 7020 of 8783 and 6202 of 8785 MiB in use with 2184-2194 MiB of
cached storage images at 2191-2196 MiB budgets (a fourth run with the switches on a colder cache stopped at about 835-845 s
on
vkAllocateMemory texture: Vulkan result -2). The run with the change, from the same cache as the first, went to its1800 s limit without a refusal and 0 faults, through the same stall (present 222 from 241 s to 694 s), and on to present 604
at 0.28-0.38 FPS (the runs without died at presents 180-260): at the first pressure peak after the stall (7981 of 8767 MiB
in use, 1427 MiB of sampled textures, 490 MiB of cached storage) the storage budget was at its 512 MiB floor, and afterwards
it moved between 1084 and 2188 MiB as the heap's use swung between 5646 and 7880 MiB (40 of 81 budget lines below
2100 MiB); 24,658 storage images were created in 30 minutes. Card use rose to 9363 MiB by the end; no run without the
change lived long enough with the switches to compare.
The runs show, on a 10 GB card, that the storage cache now gives its memory back when the heap fills, down to its floor, that
the refusals the fixed quarter left to the allocations outside the caches no longer appear in these runs, and that the cost is
storage re-creation when the budget sits at the floor. A run on an 8 GB card, where the budget sits below the cap sooner, or on
RADV would be welcome.
Tested
agc_driver_graphics(newStorageTextureBudgetcases),agc_driver_sampled_cache_budget,agc_driver_sampled_cache_budget_memory(new storage case with a fakeVK_EXT_memory_budgetreporter) andagc_driver_storage_cache_budget: pass on the RTX 3080 (Linux, GCC 16.2.1, Release withBUILD_TESTING=ON) and on lavapipe(Mesa 26.2.4, LLVM 23.1.1, Arch Linux container), on the revision before this commit's final docs-and-message amend (same
code). The two new cases were written first and failed on the previous formula (the quarter where 1792 MiB and 1024 MiB
were expected) before the change; the clamp case fails when the clamp is removed.
ctest -R agc_driver(481 tests, 16 jobs), on the first revision of this commit (same budget code; it lacked only the previous value on the budget line): 11failures, the same 11 on
main6a32550 (msaa_dcc_clear_2/4/8,bc_block_copy,depth_compare_copy,native_multisample_depth,staged_clear_sampled_read,storage_write_back_overhang,native_depth_retirement,native_depth_clears,native_depth_clear_refusals).python3 tools/check_conventions.py --base upstream/mainpasses.value on the budget line.
mainc9e6c45): Windows 11, NVIDIA GeForce RTX 4070 12 GB (596.21), WinLibs GCC 15.2.0, Release withBUILD_TESTING=ON.StorageTextureBudget's body put back tomain's formula,agc_driver_graphicsandagc_driver_sampled_cache_budget_memoryfail on the new cases; restored, all four pass.^agc_driver_serial: 488 of 490; the two FMA denormal failures also fail onmainon that GPU (test: agc_driver_f16_fma_denormal_modes and agc_driver_fma_mix_f16_denormal_modes fail on NVIDIA (NaN sign/payload differs from the AMD table) #7100).[gpu]errors, a 2810 MiB storage image budget in every run on both builds, and 17-23 (PPSA99005) and 13 (PPSA99420) storage images created per run on both. The heap was at 68-1347 of 11243 MiB, so the new formula stayed at its quarter cap; only the tests exercise the shrink path on that card.Related
recovery path; depth and render targets allocate outside that path on
main, and six of the eight stops above ran withfix(agc): release the texture caches when a device allocation runs out of memory #6174. This change keeps the storage cache from holding the room in the first place; the two compose.
StorageTextureBudget; this change moves that base with the heap's use, so the two compose. It replaces thecached.budget = StorageTextureBudget(...)line with its own and calls the two-argumentStorageTextureBudgeton a newfloorline, which would take the two byte arguments here; whichever merges second needs that one-line rebase.TextureCacheBudget, with a thirty-second of headroom, and calls the two-argumentStorageTextureBudgetinsideSampledTextureBudget, so it does not build on top of this change as is. On top of this change its reserve would follow ashrinking storage budget, so the sampled budget grows as the storage budget falls and, if the sampled cache fills it, pushes
the storage budget further down; one side has to keep reserving the other's maximum (here the sampled side reserves
TextureCacheBudget). Worth deciding together if both are wanted.USAGE.md; the paragraph is updated here.Checklist
main; no other open PR implements the same functions (fix(agc): grow the storage cache budget while it evicts under pressure #6194 changesstorageBudgetaround the samebase; see Related)
reserve, floors and eighth are a debt entry)
NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library'stechnical debt file (none added)
.mdfiles or images added to the repositoryLLVM 23.1.1, Arch Linux container). AMD/RADV: not tested here; a run on RADV would be welcome
🤖 Generated with Claude Code