perf(agc): stop pooling released device buffers over the memory budget #4472
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4472"
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 solbjorg1245 on 2026-10-12T12:52:50Z.
What
The buffer pool's device tier keeps released device-local buffers up to an eighth of the largest device-local heap (at least 512 MiB), however full that heap is. Near the budget that
VK_EXT_memory_budgetreports, this retained memory is what pushes the process over it. Past the budget an allocation can still succeed while the OS starts paging device memory orDeviceMemoryTypeplaces it in host memory, so the out-of-memory trim inBufferPool::AllocateMemorycomes late or not at all.VramBudget(new,Graphics/src/VramBudget.cpp) holds the policy for the largest device-local heap: the target is the reported budget itself (never below a quarter of the heap or 1 GiB, whichever is smaller). It does not query the driver itself. The pool's existing heap budget read (heapOverBudget, at most every 100 ms, the one the image memory path already uses) feeds it, so buffer and image releases share onevkGetPhysicalDeviceMemoryProperties2call.BufferPool::Put: while the reported usage, minus what the pool freed from the device tier since that read, is over the target, the pool first gives back retained image memory (the image path already frees it over the reported budget, and image takes are not demand). Then the device tier keeps released buffers only up to a demand floor: what it handed out (hits and misses) in the last second, in eight 125 ms buckets, capped at a sixteenth of the heap. Anything beyond the floor is destroyed, least recently used first. A title that doesn't churn has a small floor and gives back everything else; one whose working set sits just over the budget keeps what it is about to ask for again instead of re-allocating it every frame. Host tiers, the small tier and slabs are unchanged, and aPutthat lands in another tier is not counted as device memory released.Putevictions, image memory dropped or evicted inPutImageMemory,ReclaimIdleDeviceunder storage cache pressure, andtrim()before an allocation retry. The bytes are counted under the pool mutex before the memory is destroyed, soExcess()never counts a free twice.Context::integratedGpu, set from the device type: there the device-local heap is a carve-out the driver spills into system memory) and withAPS5_NO_VRAM_BUDGET=1.APS5_VRAM_BUDGET_MIBcaps the budget, which lets a large card behave like a smaller one. Both are indocs/dev/ENVIRONMENT.md.[vram]line is printed once, at the first read: the heap, its budget and usage. WithAPS5_PROFILE_DRAW, another[vram]line follows the[bufferpool]line every 10 s with the budget, usage, target, floor, the released device allocations not kept (count and MiB), the device allocations made while the pool was dropping (the churn) and the allocations placed in host memory, both byDeviceMemoryTypeand by the refused-allocation fallback inAllocateMemory(counted inHostPlacements()instead of two function-local statics).When it matters. The pool only drops buffers once the device-local heap is over the budget
VK_EXT_memory_budgetreports. At default settings Minecraft Dungeons II on an 8 GB card settles below it, and nothing changes. It matters for a heap that is already full: a bigger title, a forced or oversizedAPS5_TEXTURE_CACHE_MIB, or other processes using VRAM. There, without this PR, the pool's retained buffers push new device allocations into host memory.The crash it prevents (@AlxcBTW, RTX 5070 Laptop 8 GB, Minecraft Dungeons II world load + walk): with the device-local heap over its budget, the automatic budget evicted a 256 MiB 3D storage texture (1024x1024x256 R8). It was re-created in host memory, and a compute pass over it ran past the 2 s TDR limit (nvlddmkm 153 / LiveKernelEvent 141). Over the earlier rows that stack lost the device in 2 of 11; with this PR, 0 of 5. Logs: to be attached by @AlxcBTW.
Found with Demon's Souls on our fork: on a 16 GiB card the device-local heap reached 15.3 GiB at a level load while about 2 GiB of it was released buffers held for reuse. The demand floor replaces the first version's fixed headroom after @CnRJay's churn review; it is @parl0v's commit, with his lab rows in the thread (RTX 4060 8 GB, forced 3 GiB texture cache: walk 3.94 FPS with the headroom, 5.63 with the 1 s floor). Reclaiming cold cache entries would be a separate follow-up. The change itself has no title check.
Tested
On main
85a4d7f8c:agc_buffer_pool,agc_buffer_pool_small_device_shared,agc_buffer_pool_small_device_no_staging,agc_device_memory_fallback, the sampled and storage cache budget tests andagc_driver_pooled_buffer_rangepass;python tools/check_conventions.py --base origin/mainpasses.agc_buffer_poolbudget tests (mock device, no GPU needed):Putthat evicts from the small tier leavesExcess()unchanged;Puttrims the oldest retained buffers;ReclaimIdleDevicelowerExcess()by their size;Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01VFVE5WbaUJ2vyj8NAW44CS
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:34Z.
Is there a before/after for this change alone? The 15.3 GiB figure is one reading from a fork that carries the whole budget, and this hasn't run in a title on main; perf PRs need numbers for the change itself (#218). The
[vram]line and presents per 10 s at that level load, with and withoutAPS5_NO_VRAM_BUDGET=1, would do.Imported from boykopovar/AnyPS5. Originally posted by solbjorg1245 on 2026-10-13T03:38:22Z.
Thanks, fair point. I could not get a clean before/after of this change alone on main, and I would rather say so than quote the 15.3 GiB figure as if it were one.
What I tried:
compute shader ...: runtime image descriptor is invalid. It never reaches a level load, so there is no level-load reading on main. The[vram]lines up to that point show usage of 4.8 GiB of a 14.9 GiB budget, so the pool trim never engaged.APS5_NO_VRAM_BUDGET=1there turns the whole budget off, not only the pool part. They show what the budget is for, not what this PR contributes by itself.Setup: Windows 11, RTX 5080 16 GiB (heap 15977 MiB, driver budget about 15.2 GiB), same binary and same save, interleaved on / off / off / on, 330 s settle after the load,
APS5_PROFILE_DRAW=1in all four runs (it prints the[present]and[vram]lines, so frame rates are a little lower than without it, equally in both arms).[present]per 10 s, steady windows (mean / min / max)With the budget on the first
[vram]line reads: heap 15977 MiB, budget 15209 MiB, target 14210 MiB. With it off, usage went past the budget the driver reports in 5 and 9 of the 10 s windows (allocations still succeeded; past that budget the OS is free to move device memory to system memory). Mean steady presents were 59.8 with the budget and 52.8 without, two runs each, so the spread between runs (36 to 64 inside a window) is about as large as the difference; I would call the frame rate a small gain at best and the memory behaviour the point.What I can still do: my fork gets past both aborts above, so I can send those fixes as separate PRs first and then post the same two arms on main, or run them on a title that already boots on main. Without a title that loads a level there I cannot give a reading for the pool trim alone.
On #4446: the bot is right that both PRs touch
tests/BufferPool.cpp. The conflict is two places where each PR adds lines next to the other's (the mock device fields and the list of calls inmain). Keeping both sides resolves it, the source files merge cleanly. Whichever lands second will rebase.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T06:51:57Z.
Thanks for saying so plainly. Send the two boot fixes as their own PRs first; this stays open, and the two arms on main once the title reaches a level load will do.
Imported from boykopovar/AnyPS5. Originally posted by solbjorg1245 on 2026-10-13T09:07:56Z.
Update: the two boot aborts I reported are already gone on current main, so there is nothing to send for them. My first try was on this PR's older base, sorry for the noise.
I rebuilt on main (
c2565f014) with this PR on top and ran the title again on the RTX 5080 16 GiB. The depth resummarize draw is accepted now (that is #4049, which merged after my first try), and the compute shader abort did not show up in two runs. The title plays the intro, reaches the main menu and starts loading the save.It then aborts during the load, in a pixel shader recompile:
GetImageResource dword 0 is not a valid runtime value, where the image descriptor address comes from a 64-bit pointer loaded out of memory (the case #758 and #757 implement, both open and not merged). So I still cannot give the on/off numbers at a level load on main.Up to the abort the budget never mattered: device-local usage stayed at about 4.7 GiB of the 14.9 GiB budget, nothing was released over the target, and there were no failures before the shader abort.
I will rerun the two arms (
APS5_NO_VRAM_BUDGETunset and =1, interleaved) as soon as a title reaches a level load on main with this PR, and post the table here. The earlier numbers from my fork stay as they were: they carry the whole budget, not only this change.Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T00:54:07Z.
Review: COMMENTED
One behaviour to check in the title run requested above: allocation churn near the budget.
VK_EXT_memory_budgetusage covers the whole process (textures, images, the pipeline cache, other pools), so the pool can be over target for reasons it can't fix. In that state every device-tierPutdestroys its buffer, and the nextTakeof the same size callsvkAllocateMemoryagain. On Windows/WDDM that allocation can take milliseconds and is a known source of frame-time spikes. A level that sits just over the target would then alternate free and allocate every frame, which is worse than keeping a small pool.Some ways to bound it:
vkAllocateMemorycalls that follow a droppedPutwithin a frame in the[vram]line, so the trace shows whether churn happens.The rest looks good. The integrated-GPU and missing-extension paths are left alone, and reading the budget at most every 100 ms keeps
vkGetPhysicalDeviceMemoryProperties2(which can be a kernel call) off the per-Putpath.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T21:33:26Z.
#757 and #758 merged on 10-14, so the
GetImageResource dword 0 is not a valid runtime valueabort during the save load should be gone on main. Could you rebase and post the on/off numbers at the level load ([vram]line and presents per 10 s, with and withoutAPS5_NO_VRAM_BUDGET=1)?Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T07:53:15Z.
On/off numbers for this change at a level load, on an 8 GB card: RTX 4060 8 GB, i5-14400F, 16 GB RAM, Windows 10. Minecraft Dungeons II (PPSA16064 01.100.100), the first world load from a save without a character (intro cutscene, then the HUD in "Escape from Squid Coast"), then 120 s of scripted walking. Same libs per table,
APS5_TEXTURE_CACHE_MIB=3072, arms alternating, toggled withAPS5_NO_VRAM_BUDGET=1. This PR's head 2d90e03e3 merges with currentmainexcepttests/BufferPool.cpp(main's side kept; tests not built here). The heap reports a 7189 MiB budget, so the target is 6691 MiB (headroom 497).main5d9dcc42d+ #6308 + this PR (#6308 is needed for the world load onmain):[vram]at the endWalking runs at 1.4-1.8 FPS on this base whatever the arm, so these FPS numbers say little. Round 3 "on" is worth a look: the heap stayed above its budget, so new device buffers kept being placed in host memory and released without pooling, 65536 placements and 63.7 GB through host memory in one row.
The same with #5372 and #6490 under it (
main+ #6308 + #5372 + #6490 + this PR, the stack our gameplay rows use), 11 rows, all reached the HUD and survived the walk:APS5_VRAM_HEADROOM_MIB=1vkAllocateMemory ... memoryType=0 ... initialResult=-2(2 of 3 first loads on this box this morning, both before this PR was in).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T08:37:07Z.
Follow-up on the headroom, same box and scene (RTX 4060 8 GB,
main+ #6308 + #5372 + #6490 + this PR, Minecraft Dungeons II first world load + 120 s walk). One batch, arms interleaved so the host load is the same for all of them; GPU busy and idle gaps are per frame over the last 12 windows.APS5_NO_VRAM_BUDGET=1APS5_VRAM_HEADROOM_MIB=128Two earlier rows at 128 MiB gave 5.42 / 5.74 and two at 256 MiB gave 4.97 / 4.53 (a quieter host, so not comparable to the table above). Over the four 128 MiB rows the mean is 5.24 FPS.
How I read it:
So on an 8 GB card the default headroom (a sixteenth of the heap, at least 256 MiB) looks too wide for this title. Something like a sixty-fourth of the heap clamped to 64-256 MiB (124 MiB here, 250 MiB on 16 GB) would land where these rows are best. I have only this card and this title, so take it as one data point for where the default should sit, not a tuned value.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T09:57:36Z.
Last follow-up from me on the headroom question, with two more variants tried on the same box and scene. All walk FPS rows on
main+ #6308 + #5372 + #6490 + this PR today, grouped by arm (every row reached the HUD and survived the walk; rows of different batches mix host load, the interleaved batches above are the cleaner comparisons):APS5_NO_VRAM_BUDGET=1What doesn't work: a trigger that starts dropping only near the budget and then drains down to the target. This title's live footprint (6.9-7.1 GB) sits above the 6691 MiB target, so once it starts it never stops, and it churns like the default (147k-182k buffers per row, 2.48 / 3.09 FPS).
What does: letting the device tier keep a small floor of released buffers while over the target, and destroying only what is beyond it. The churn comes from destroying buffers the title asks for again within milliseconds; once the pool is empty, dropping one more saves nothing. With a 128 MiB floor and the default target the pool holds ~120 MiB, drops 2-9k buffers per row instead of 60-210k, and the walk runs at 5.66 / 4.59 FPS against 3.38 / 3.69 for the default in the same batches. The lab patch I measured (env switch only for the A/B):
Either a narrower default headroom or a floor like this gets the ~30-40 % over off that the placements cost on this card; the floor doesn't depend on where a title's footprint sits relative to the target. Happy to rerun whichever you pick.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-16T11:26:01Z.
A second machine, and the crash this PR prevents there: RTX 5070 Laptop 8 GB (NVIDIA 617.42), Ryzen AI 9 365, 31 GiB RAM, Windows 11. Minecraft Dungeons II (PPSA16064 01.100.100), world load from an in-world save plus a 180 s walk, automatic storage-cache budget, on AC. Base:
main5d9dcc42d+ #6308 + #5372 + #6490 + #6631 + #6632 + #6194 (with the budget revision posted there) + this PR without its test hunk, which conflicts with that base; the code applies cleanly. The same libs serve both arms, andAPS5_NO_VRAM_BUDGET=1turns this PR off.The device loss is a Windows GPU timeout (TDR). The System log has an nvlddmkm 153 entry, or Windows Error Reporting logs a LiveKernelEvent 141 for the same second. In both device losses of the last two days, the automatic budget had evicted a 256 MiB 3D storage texture (1024x1024x256 R8). With the device-local heap over its budget, it was re-created in host memory, and a compute pass over it then ran past the 2 s limit. Across the earlier rows of that stack, the automatic budget lost the device in 2 of 11 rows and the fixed budget in 0 of 45. Five rows per arm is a small sample. The mechanism fits the counts, though: with this PR the released device buffers stop holding the heap, so those textures stay device-local.
Not run: other GPUs on this stack, Linux.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T11:32:57Z.
A caveat on my numbers above: every row ran with
APS5_TEXTURE_CACHE_MIB=3072, a storage cache budget larger than this 8 GB card can hold next to the rest, so the heap sat over its budget and the device-tier pool was what decided where the overflow went. With the cache left onmain's automatic budget the same scene settles at ~6670 MiB of the 7189 MiB budget, nothing is placed in host memory, and this PR drops only ~200 buffers per row; on/off rows there are within the spread (4.78 / 4.94 / 5.59 off, 5.02 / 4.79 on in the same batch). So the effect I measured is for a heap that is already over its budget, as with a forced or oversized cache budget or a bigger title, not for this title at its default settings.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-16T21:46:29Z.
Thanks for the rows, @parl0v and @AlxcBTW. They confirm the churn I raised in the first review: with the default headroom the pool drops 40–210k buffers per row, and the idle gaps grow by about as much as the GPU busy time shrinks. @parl0v's last variant (a pool floor) is the design I'd ask for here, and I'd rather it replace a tuned headroom than sit beside it.
DeviceBudgetdoes for the staging pool.vkAllocateMemorycalls after a droppedPut) and the placements need to be on the[vram]line, so the summary lines of any title show which side it is on.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T21:47:51Z.
@CnRJay agreed on all four points. The fixed 128 MiB was only there to find out whether a floor works at all; it shouldn't ship as a constant.
I'll write the floor sized from demand: the device tier keeps what it handed out over the last N presents (a rolling peak of
Getbytes), drops only what sits above that while the heap is over its target, and the headroom goes away. The[vram]line gets the churn count (vkAllocateMemorycalls that follow a droppedPut) and the host placements next to the drops. Then I'll rerun the same three cases on my RTX 4060 8 GB: the forced 3072 MiB cache, the automatic budget, and the in-world walk.@solbjorg1245 how do you want it: I can send it as a commit on top of your branch for you to pull in, or open it as a separate PR that depends on this one. Your call; it's your PR.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:02:00Z.
I agree with @CnRJay: a floor sized from what the title asked for over the last few presents, replacing the headroom rather than sitting beside it, with the churn count and host placements on the
[vram]line. @solbjorg1245, your call whether @parl0v's change comes in as a commit here or as a PR on top. Please also put @AlxcBTW's device loss in the description with its logs, since that's a crash rather than a few FPS, along with the note that the effect only shows once the heap is over budget. The rebase is onlytests/BufferPool.cpp, so it can go in with the floor change.Imported from boykopovar/AnyPS5. Originally posted by solbjorg1245 on 2026-10-16T23:42:19Z.
@parl0v Do as commit please.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:41:53Z.
A commit here is fine. What is left: the floor replacing the headroom, the churn count and host placements on the
[vram]line, and @AlxcBTW's device loss with its logs in the description. The rebase is onlytests/BufferPool.cpp.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-17T03:36:53Z.
@oneandonlydean @solbjorg1245 the commit is on
parl0v:perf/vram-floor: this PR's commit rebased onto currentmain(bfcf02e3a), then b5da959c9 on top.APS5_VRAM_HEADROOM_MIBandHeadroomForare gone, andAPS5_VRAM_BUDGET_MIBstill caps the budget. The cap is there because a world load hands out over 3 GB per second, and an uncapped floor held 3220 MiB in one of my rows.[vram]line: the floor, the device allocations made while the pool was dropping (the churn), and the host placements. Those areDeviceMemoryType's counters, moved out of function-local statics intoHostPlacements().tests/BufferPool.cppmerges withmain'sHostPlacementtest on the PR's mock. Sincemain'sDeviceMemoryTypeplaces a device buffer in host memory once the heap is over its budget, the budget tests now allocate under the budget and raise the usage before releasing. The integrated test checks!Vram().Enabled()instead of "no budget queries", becauseDeviceMemoryTypequeries the budget either way. New tests: the floor keeps what was taken in the last second, and it gives everything back once the window has passed.agc_buffer_poolandagc_device_memory_fallbackpass, andcheck_conventions.pypasses.Lab numbers for the window, RTX 4060 8 GB, Minecraft Dungeons II world load + 120 s walk, forced
APS5_TEXTURE_CACHE_MIB=3072, on the older base from my earlier rows, one row per arm (so a direction, not a measurement):Not done: an in-game run of the commit itself. On current
mainthis world load stops atstoring storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented, with this PR on and withAPS5_NO_VRAM_BUDGET=1alike, so I couldn't get walk rows on that base. @AlxcBTW's device-loss logs for the description are his to attach.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-17T17:00:30Z.
@solbjorg1245 the PR picked up "needs rebase" again.
parl0v:perf/vram-flooris now both commits rebased onto currentmain(66702f1cf). The only conflict wastests/BufferPool.cpp:mainaddedAllocationFailure.hppand map counters to the mock next to this PR's budget fields, and I kept both sides.agc_buffer_pool, the two newagc_buffer_pool_small_device_*tests frommainandagc_device_memory_fallbackpass, and so doescheck_conventions.py. Resetting your branch to 835062895 clears it.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T21:40:33Z.
Thanks @parl0v for the rebase on
perf/vram-floor(83506289556). Two things before this can go to CI and the gate runs:Small-tier puts report VRAM they didn't free. Since #7056,
tierForsends device-local buffers smaller thanclassLimitto the small tier. InBufferPool::Put,excessis read fromvram.Excess()for any device-tiered allocation before the tier is chosen. For a small-tier put the drop branch is skipped, but the last line still callsvram.Released(freed)with whatever the small tier evicted (that can be host-visible buffers).Excess()then reads low until the next budget query. Suggested fix:if (&tier != &deviceTier) excess = 0;right aftertierFor(...), plus a test: over budget, a small device-tiered Put that evicts from the small tier must leaveExcess()unchanged.Main has moved again. Against current main,
Context.hppandBufferPool.cppconflict with the texture-cache reclaim change (cacheReclaim, #6174): both sides add oneContextmember and one constructor initializer at the same spot. Keeping both should be all it needs. (tests/BufferPool.cppmerges cleanly now.)Could you push the rebased branch with the fix to this PR (or solbjorg1245 can pull it)? Once the head is on the PR, we'll run full CI on it and then the no-harm and constrained gate runs. The description update with AlxcBTW's device-loss logs and the "only matters once the heap is over budget" note is still needed too.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-18T02:22:47Z.
@oneandonlydean both done, on
parl0v:perf/vram-floorat2ac92ca90, rebased onto currentmain(195d0d08a):Putnow clearsexcessright aftertierForwhen the buffer isn't going to the device tier, so the small tier's evictions never reachvram.Released. New testVramSmallTierPutKeepsExcess: over the budget, 160 released 512 KiB device buffers overflow the small tier, andExcess()must be the same before and after. Without the fix it fails with336 -> 320 MiB over; with it, it passes.Context.hppkeeps bothcacheReclaimandintegratedGpu. TheBufferPoolconstructor initializescacheReclaim(context.cacheReclaim), vram(context)in declaration order.tests/BufferPool.cppmerged cleanly, as you said.agc_buffer_pool,agc_buffer_pool_small_device_shared,agc_buffer_pool_small_device_no_stagingandagc_device_memory_fallbackpass, and so doescheck_conventions.py. I can't push to solbjorg1245's fork, so @solbjorg1245, resettingupstream/vram-budget-1to2ac92ca90puts it on the PR.For the description, a section that could go in as is:
@AlxcBTW, the logs themselves are yours to attach.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by solbjorg1245 on 2026-10-18T15:54:19Z.
Thanks @parl0v for the floor and the rebase, and @oneandonlydean for putting it on the branch. I've updated the description for the floor and added the when-it-matters note and the crash section. @AlxcBTW, could you attach your device-loss logs when you get a chance?
Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-18T23:15:59Z.
I am updating #6553 after #5987 merged. Its remaining change checks the reported host-heap budget before a proactive host placement; main's actual-refusal fallback, pool trim and texture-cache reclaim routing are retained.
There is a shared
DeviceMemoryType/buffer-pool test area with this PR; both branches also already need resolution against newer main. I propose #6553 first, then this PR can move successful-placement counters intoHostPlacementswhile retainingHostMemoryTypeWithRoom, the host-budget diagnostics, and the separate diagnostic for keeping a device-local allocation when no host heap fits.The guard's standalone and integrated tests do not establish combined behavior with this PR. Please let me know if the opposite landing order is preferable so we can compose and test it explicitly.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by solbjorg1245 on 2026-10-19T15:32:20Z.
Thanks, #6553 first works for me. Once it lands I'll rebase this past it and #5987, keep
HostMemoryTypeWithRoomand the host-budget diagnostics, and only move the successful-placement counters intoHostPlacements.Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-20T18:06:21Z.
I found storage-cache churn below the reported heap budget on a 6 GB NVIDIA GPU. This is coordination evidence for a possible follow-up; it is not a test of #4472.
GTA III, PPSA03527/01.003.000, stationary at the first "Give me Liberty" spawn beside the Kuruma, with HUD/radar visible. RTX 3060 Laptop 6 GB, NVIDIA 617.42, i5-11400H, 32 GB RAM, Windows 26300. Both runs use the same complete runtime,
eb210d1e1756= main1b08a33b121e+ #8527. The same initial pipeline cache and private profile were checked by SHA-256 before the countercheck; 726 pipeline recipes replayed on both runs. No source change or forced texture-cache budget was used.APS5_STAGING_POOL_MIB=128The last default-pool budget report before the window ended was 4,471 MiB used against 5,161 MiB reported, with a 512 MiB storage-cache budget. That is a logged snapshot, not continuous heap telemetry. It does not meet this PR's over-budget predicate. An earlier default-pool run also gave 1.0-1.1 presents/s, but its starting cache differed, so the table uses the subsequent matched-cache control.
These are profiled diagnostic intervals with a renderer readback every 30 presents, not clean performance captures. The write-back figures are logical surface traffic, not measured PCIe bandwidth. The bounded trace covered an earlier loading phase and overflowed event storage; it cannot support a gameplay speed claim. Neither setting is playable, and this does not justify shipping a fixed 128 MiB pool: #1147 documents a title that needs a larger pool.
The result suggests investigating reclamation of cold idle device buffers when the storage cache is actively evicting below the heap budget, while preserving recent buffer demand. I have not changed this PR's target or implemented a competing retention policy. Please flag any existing follow-up that owns this case so the work can stay coordinated.
Prepared with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by solbjorg1245 on 2026-10-20T18:34:44Z.
Thanks for the data. Nothing I have open covers that case: #4472 only stops pooling released buffers once the heap is over budget, so reclaiming cold idle buffers while the storage cache evicts below budget would be a separate follow-up, and I'm not working on one. If you take it on I'll rebase this around it.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T03:09:53Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix how device allocation releases update the budget accounting.
What I ran
c58f968028ccef496eb2270918aac49579780d6dagainst basemainusingrepo_read.pyto inspect the prepared diff and source files.85a4d7f8c); those results are author supplied.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:627increments the released-byte allowance for every evicted device-tier allocation, including the buffer being returned by the currentPut. That allocation has not necessarily been freed: on the ordinary retention path it is inserted intotier.freeat lines 623–625, whilevram.Released(...)still counts it as released. After usage was sampled, this makesExcess()understate real heap use and can cause laterPutcalls to retain additional buffers over the target. Count only allocations that are actually destroyed; retained allocations must not reduce the reported usage.Non-blocking
Not verified
85a4d7f8c, not this reviewed head.VulkanDevice.cpp,BufferPool.hpp,Context.hpp,VramBudget.hpp,BufferPool.cpp,VramBudget.cpp,PostCompile.cmake,tests/BufferPool.cpp, anddocs/dev/ENVIRONMENT.md. No changed files were excluded by the manifest.To get this to a good state
VramBudget::Released, then rerun the buffer-pool budget tests on the updated head.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.