perf(agc): prefer a pooled buffer of the requested exact size #8913
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8913"
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 Celegans12 on 2026-10-21T05:49:26Z.
What
The pool retains buffers by size class. When a hit's
VkBufferwas made for another exact size,BufferandDeviceBufferdestroy it and bind a new one to the same memory (BindExactBuffer). Since #6763 copies draw inputs on NVIDIA's Windows driver, each draw takes such a buffer per index or vertex range, andTakealways hands out the newest slot of the class, whatever its size. In a Yōtei profile on our tree the draw commit thread spent 1.3 s per 120 s inBindExactBufferand another 0.36 s in the destroys.Takenow scans the newest 64 slots of the class for one whose buffer has the requested size, and takes the newest slot as before when none does.Overlaps: #8748 changes the free-list key a few lines above in
Take(textual only).Tested
-DBUILD_TESTING=ON, RTX 3080 Laptop, based onmain7ab4b2e561: ctest 1824/1828. The 4 failures (log_macros,log_macros_timestamps,guest_kqueue, andagc_driver_image_array_window_past_layer_limit, which doesn't compile with MinGW here) fail onmaintoo.ExactSizeReusecase inagc_buffer_pool: with a 3000-byte and then a 4000-byte buffer released into one class, a 3000-byte request gets the first one back without a rebuild and a 4000-byte request the second. Withmain'sBufferPoolit fails: "a pooled buffer of the requested exact size was passed over for a newer one that had to be rebuilt".main: 1762/1782; the same 20 fail onmain(WSL has no userfaultfd write watching).main, with #8911, #8912 and #8913 switched on and off together in one in-run open-world A/B (9+9 phases): 6.17 vs 5.16 presents per 10 s (paired -0.95 +- 0.20 SE) for the combined set. This PR's own counter in that run: 436k vs 253k exact-size hits, 425k vs 493k rebinds to another size. Themain-vs-change summary lines, traces andtrace_digest.pyoutput for the perf label are still owed.mainvs this change on the same machine (RTX 3080 Laptop, driver 610.62, Windows 11), Ghost of Yōtei (PPSA26344 v1.008) title menu from the same save with no input, warm caches, interleaved runs in one session, perf-report protocol (onlyAPS5_TRACE_FRAMES=150:60, noAPS5_PROFILE_*):maina5a2c946a3againstmaina5a2c946a3+ this PR. Frame p50 131.9 ms (3 runs) against 132.7 ms (2 runs), GPU busy 77.7 against 81.5 ms per present. That's inside the run-to-run spread (main's three runs: 128.2-135.1 ms), as expected for a scene that doesn't exercise this path; our open-world numbers, from our own tree, are in the comments. Traces andtools/trace_digest.pyoutput per run: pl-main-1, pl-main-2, pl-main-3, pl-8913-1, pl-8913-2.aps5-summary.jsonl, pl-main-3 and pl-8913-2 (the run closest to each side's mean; `title` written as `ō`, since the summary writer double-encodes it and GitHub mangles that escape)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-21T05:49:39Z.
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-21T05:52:52Z.
Review: COMMENTED
The
Takechange preserves the existing newest-slot fallback and removes only the selected slot; the regression exercises both exact sizes and checks the buffers are reused. I ranpython3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEAD; both pass. I could not runagc_buffer_poolfrom this Linux checkout because there is no matching configured test binary here. One reporting gap: the performance result combines this PR with #8911 and #8912, while CONTRIBUTING.md and the perf-label bot ask for matchedmain/change trace summaries and both trace artifacts. Please attach the required artifacts or keep the quantified claim clearly scoped to the combined set.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-21T06:18:57Z.
@MarcZX10 thanks for running the conventions check and
git diff --check, and for reading the fallback path inTake.You're right that the speed result mixed this PR with #8911 and #8912. It came from our own Yōtei tree, not
main, with all three switched together. I've changed the description to say so plainly. The exact-size hits vs rebinds counts are the only part specific to this change. Themain/change summary lines, both traces andtrace_digest.pyoutput are still owed. I'll attach them when I have a clean capture, but I can't promise a date.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-21T08:45:53Z.
AMD / Linux (RX 9070 XT, RADV) A/B of #8911 + #8912 + #8913 together on ASTRO BOT: neutral there (no change, no regression). Numbers and trace digest: https://github.com/boykopovar/AnyPS5/pull/8911#issuecomment-6311878368
Tested and written by Claude (AI assistant) on a contributor's machine.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-22T09:49:31Z.
Here's this PR measured alone, as asked on #8912. Plain main can't take Ghost of Yōtei to the open world (the loading screen stops presenting after about 160 s and the game later aborts on a blend into a 10_11_11 unorm target main doesn't support), so this is our tree (our local merge with main of 2026-10-21) with only
APS5_NO_EXACT_SIZE_REUSEflipped every 60 s in one run.The result is mixed. Presents lean its way: 7.23 per 10 s with the exact-size scan vs 6.78 without, paired -0.34 +- 0.28 with it off, about 1.2 SE. But committer time per commit was a little lower with the scan off (258 vs 234 us, paired -19 +- 15 us), so the scan itself isn't free. It does what it says on the buffers: per phase about 490k pooled hits of the exact size with it on against 365k off, and rebinds to another size drop from about 733k to 476k.
I also tried a boot-scene pair on plain main, but those captures turned out to be pipeline-cold on this machine, so I'm not quoting them. Given milescoviello's point about #8888's size classes, I'd rerun this after #8888 lands rather than tune the scan now.
Details
Run
pb-8913, our local merge with main557682ca44, warm caches (NVIDIA pipeline cache readable, dictionary checked before the run), web-teshio-b save, 1,300 s cap,APS5_AB=60:APS5_NO_EXACT_SIZE_REUSEfrom present 760, RTX 3080 Laptop (610.62), Windows 11. B = the switch set, i.e. this PR's change off.