perf(agc): pool large host buffers by size class #8888
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8888"
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 milescoviello on 2026-10-21T04:46:34Z.
What
BufferPoolreuses a large host-visible buffer (1 MiB or more) only for a later request of exactly the same size. Large device-local buffers have used size classes since28345b0eac, an eighth of their octave; host ones kept exact sizes.Draw snapshots of guest buffers are large host buffers, and their size changes by a few bytes almost every time. With exact sizes the large tier fills its 512 MiB budget with buffers that later requests never match. It misses and evicts several buffers per frame, and each miss and eviction pays an allocation and an unmap in the driver.
In CoD BO2's (PPSA34502) war-room menu, with #5499 and #8756 applied, the large tier hits 373 to 385 times per 10 s and misses 606 to 835 times. On the draw thread, freeing those buffers takes about 12 % of its samples, allocating them about 10 %, and the driver's map and unmap ioctls about 18 %.
Now large host requests take the same classes as device-local ones:
VkBufferand its mapping keep the requested size; a buffer taken from a larger class gets an exact-sizeVkBufferbound over it, as device-local buffers already do.A host request still takes only its own class, not the larger ones a device-local request may use, so at most an eighth of an octave is wasted. The budget and eviction are unchanged.
Capacityno longer depends on the memory properties, so the parameter is gone.Tested
Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02, on
main7ab4b2e561.Test.
AddressAndHostUnchangedintests/BufferPool.cppasserted that large host buffers keep exact sizes. It's nowAddressAndHostClasses(the device-address half is unchanged) and checks that:VkBufferand mapping (Bytes()) keep the requested size;VkBuffer;Built against
main's pool code, the new test fails 3 of 3 at those three checks. With this PR it passes 3 of 3.Suites.
agc_buffer_poolandagc_driver_pooled_buffer_range: 3 of 3.ctest -R '^agc_': 850 of 850.mainand on this branch: the pool, pooled-range, snapshot and kept-bytes tests (agc_buffer_pool,agc_driver_pooled_buffer_range,agc_draw_snapshot_cap,agc_draw_inputs_copied,agc_draw_inputs_in_place,agc_recorder_kept_bytes,agc_copy_input_kept_bytes,agc_depth_copy_kept_bytes,agc_driver_large_tracked_snapshot) pass 9 of 9 on both, with no VUID.CoD BO2 (PPSA34502), war-room menu. The title needs #5499 to get there. Both builds are #5499 rebased on
maineea640a5bfplus #8756, and the second adds this change. Release libs, warm caches,APS5_PROFILE_DRAW=1, two runs each, alternated. The figures are the 10 s intervals in the menu:[bufferpool])Trace windows of a third pair of runs, 30 s from 175 s in the menu (
APS5_TRACE_SECONDS=175:30), digested withtools/trace_digest.py:Files:
Super Meat Boy 3D (PPSA31162), level 1-1, as a check of a second title. The builds are
main7ab4b2e561and this PR, four runs alternated. This title's large tier already misses 0 times per 10 s onmain, because its large sizes repeat exactly, and that stays 0 with this PR. Its per-draw cost follows the run-to-run modes in #8840 on both builds (211 to 273 us in the slow mode). There's no change I can attribute to this PR.agc_buffer_pool*tests pass 3 of 3 onmainand 3 of 3 with this change.Not tested: AMD, Intel, other titles. Host memory use stays inside the same 512 MiB large-tier budget; each retained buffer can be up to an eighth of an octave larger than the request it serves.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T04:46:46Z.
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 milescoviello on 2026-10-21T05:16:01Z.
Windows run (Win11 26H2, WinLibs GCC 15.2 r7, Vulkan SDK 1.4.363, GT 1030), main
7ab4b2e561vs this branchf24d9ce50c, BUILD_TESTING on, both test targets built from clean:agc_buffer_poolagc_driver_pooled_buffer_rangeBoth builds succeeded. The size-class test (
AddressAndHostClasses) passes on Windows too.AI-assisted: yes (Claude Code)