perf(agc): reclaim idle device buffers under storage cache pressure #8672
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8672"
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 eliasbruno124-dev on 2026-10-20T20:42:22Z.
What
The storage-image cache can repeatedly evict surfaces while the device-buffer pool retains allocations the title has stopped using. GTA III reproduces this below the reported heap budget, where over-budget trimming does not apply.
On storage admission pressure, reclaim independently allocated device buffers unused during a complete one-second observation interval, oldest first and bounded by the admission shortfall. Reread the driver's budget after an actual release; the existing storage-budget formula, reserve, caps and forced-budget override remain in charge. Active buffers, host tiers, slabs, retained image allocations and recently reused buffers are protected. No fixed small pool cap is introduced.
Reclamation requires one device-local heap because retained buffers do not record their heap. The one-second retention choice and unmeasured effects on intermittent reuse are documented in technical debt.
Scope/order agreed with #4472 and #7833: cold-buffer release first; those branches rebase around it. This does not implement #6194's budget growth or #7833's in-flight image retention.
Tested
Current rebase validation
Head
b996e31d8c11956df72031e42d286e4682ebe1feis rebased linearly onto777bdbb4f80bcc03e870dfda0d292c0c6410fd6a, including the updated #8527 review correction (equivalent patches to itsa0ecec3d3head). The header conflict retains upstreamAgcDriver::Mutexand the idle-clock fields. The reclaim policy and retained-image exclusion are unchanged.On the Windows/NVIDIA system below, complete runtimes were built for that main and this head. The same 26 focused tests passed on both with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, real Khronos synchronization validation andctest -V -j1 --timeout 30. Neither run skipped a case or missed the layer. Main nevertheless logged 26 synchronization errors in four tests:agc_import_settle_first_use,agc_import_settle_earlier_import,agc_storage_split_writebackandagc_driver_storage_write_back_overhang. This head logged none. These ordering corrections come from #8527, not the cold-buffer policy. Longest cases: 14.4429s on main and 12.9777s on this head.The three additional #8527 cases (
write_order,write_order_other_familyandwait_failure) also passed on this head without skips or validation errors. Conventions and whitespace checks pass. Pre-push main8eb8e3920was inspected and merges cleanly; it was not the tested runtime. Linux and AMD/Intel were not tested locally.The earlier mixed-pool regression fails without the retained-image exclusion and passes with it; image reuse, an image-only pool, repeated empty scans and exact cleanup remain covered. The title measurements below remain evidence for their explicitly named earlier commits. No new gameplay or performance measurement is claimed for this rebase.
Original title measurements
Windows 10.0.26300, i5-11400H, 32 GiB RAM, NVIDIA RTX 3060 Laptop GPU (6 GiB), driver 617.42. Original GTA III PPSA03527/01.003.000, 3840x2160, stationary first-mission spawn at Callahan Bridge with Claude, Kuruma, HUD and radar.
Pinned main
434e965d4620c48e315b25fb869a2d84b39cfb2dplus the unchanged #8527 dependency gives baseline9552b5e2ccbb297dccd3aba7d8df631bfa9094de; candidatea6c415f7ad63de979e16e39c898c0846ab34465cadds only this policy. Both use the same warmed cache/private-save seed and automatic navigation, default pools, complete runtimes and 61 verified loaded PRXs. Original metadata remained unchanged. No storage error occurred.APS5_TRACE_FRAMES=4440:10captures ten presents per side. Startup-only image exports ended at present 4410; navigation ended before that. No readbacks or input during capture, no additional TRACE/PROFILE options, no redirected game logs. Both traces are complete with no dropped events. The short window is corroborated by longer profiled diagnostics below; it is not a claim of steady gameplay or a general FPS gain.Median frame time fell 36.3%; p90 fell 43.2%. The scene remains slow (about 1.67 vs 2.67 presents/s across these short captures).
Driver.Packet.memory_waitfell from 517.818 to 166.197 ms/frame, inclusive; overlapping phases must not be added. GPU work remains substantial.Earlier paired 98.9/113.6-second diagnostic windows used profiling/readbacks: median logical storage-cache eviction writeback 10272.9 MiB/interval -> 0, retained device pool 586 ->298 MiB. Candidate released 348.875 MiB before and 111.5 MiB within the window; neither side acquired new device-pool allocations between the window's first/last counter rows. These are mechanism observations, not additional clean FPS measurements.
Both pinned runtimes pass the same 28 focused native cases using
ctest -V,ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, and the realVK_LAYER_KHRONOS_validationwith synchronization validation. No missing-layer warning, VUID error or skipped case; longest cases 14.8167s baseline / 13.9844s candidate. Candidate regressions cover bounded release, repeated 384 MiB reuse, active/host/slab protection, allocation failure while collecting releases, backwards time, unsupported heaps and avoiding repeated empty scans. Conventions pass. Linux and AMD/Intel remain untested locally.Both complete
trace_digest.pyoutputs, including the rawaps5-summary.jsonlrecords, follow. The archive contains both raw traces, summary files and digests: gta3-cold-buffer-traces.zipBaseline: complete trace digest and summary
frames 4440:10 from present 4440: 10 presents, frame p50 587.4 / p90 705.2 / p99 705.2 / max 705.2 ms, GPU busy 298.7 ms per present
NVIDIA GeForce RTX 3060 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 9552b5e2ccbb, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 1117.2, Driver.Packet.memory_wait 517.8, Graphics.Draw 319.0, batch 315.4, Graphics.Draw.draw_and_resource_release 297.2, Driver.Packet.device_lock 245.2, Driver.Packet.dispatch 216.3, Resources.Complete 212.1, Driver.Dispatch 204.7, Vulkan.Dispatch 158.2
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Candidate: complete trace digest and summary
frames 4440:10 from present 4440: 10 presents, frame p50 374.1 / p90 400.8 / p99 400.8 / max 400.8 ms, GPU busy 293.6 ms per present
NVIDIA GeForce RTX 3060 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit a6c415f7ad63, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 710.1, batch 324.8, Driver.Packet.dispatch 263.6, Recorder.Sync 201.5, Driver.Packet.device_lock 189.2, Driver.Packet.memory_wait 166.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Fresh pre-publication main
50e0624d7a902d1083368fafee4a019a10296e1eis checked separately for conflicts and changed inputs; it is not the commit measured above.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T20:42:36Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:55:10Z.
Review: APPROVED
I reviewed the reclaim policy and its call site.
Takeadvances the pool clock, so entries reused during the one-second observation window are newer thanreclaimBefore; active allocations are absent from the free tier, and slab allocations are explicitly excluded. The operation removes pool bookkeeping under the mutex and destroys Vulkan allocations after releasing it. The one-device-local-heap guard matches the implementation's lack of per-allocation heap tracking, and the budget is reread only after an actual release.The PR description reports focused Vulkan validation with synchronization validation and paired traces for the same Windows/NVIDIA scene, while clearly limiting the performance claim to that scene. Hosted platform jobs are skipped, so this approval relies on the author's detailed run report rather than an independent build or GPU run here.
Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-20T21:37:16Z.
Rebased to
74b001a9ccafter #7870. Retained images now share the free tier, so idle buffer reclamation explicitly excludes them. The new mixed-pool regression fails without that exclusion and passes with it, including image reuse and exact cleanup.Both complete Windows/NVIDIA runtimes pass the same 28 focused tests with cache disabled and Khronos synchronization validation: no VUID errors or skipped cases. Conventions pass. The description now distinguishes these checks from the earlier title timing evidence.
Prepared with AI assistance.