fix(agc): give small device-local buffers a pool tier of their own #8912
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8912"
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:10Z.
What
#7056 moved device-local buffers under 1 MiB out of the device tier into the small tier, so the large device buffers' churn stops evicting them. But the small tier's 64 MiB budget is also what the small host buffers live in, so now those two evict each other: every small device miss is a dedicated
vkAllocateMemoryand every eviction avkFreeMemoryon the draw commit thread. In Yōtei on our tree, after we merged #7056 the small tier had 2.5x the misses of our previous build (492k vs 192k).smallDeviceTier) with a budget of max(64 MiB, device tier budget / 8), on top of the device tier's. They get back the device tier's next-class search they had before #7056. The large device buffers and the small host buffers no longer evict them, and they don't evict those.maxMemoryAllocationCount, so four tiers still leave half of it free; the header comment that described three tiers is gone.APS5_BUFFER_POOL_SHAREDstill puts every device buffer in the device tier.trimand the destructor cover the new tier, and the[bufferpool]line reports it.This is a retention fix, not a speed claim: no frame-rate gain was measured (an in-run switch comparison on our own tree found none significant).
Overlaps: #8748 and #11920 have merged, and the branch carries both. #8672's idle reclaim and #4472's VRAM rule walk only the device tier, so small device buffers stay out of their reach, as they are on
maintoday.Tested
mainb4a82720a8: Windows 11, MinGW-w64 GCC 15.2.0, Release,-DBUILD_TESTING=ON, RTX 3080 Laptop with Vulkan validation 1.4.363 loaded:agc_buffer_pool(withSmallDeviceOwnTier),agc_buffer_pool_small_device_shared,agc_buffer_pool_small_device_no_staging,agc_image_memory, the memory-accounting and pooled-buffer-range tests: 10/10, three times, no VUIDs.SmallDeviceOwnTiercase inagc_buffer_pool: a released 256 KiB device buffer survives 80 MiB of small host buffer churn and is reused without an allocation. Withmain'sBufferPoolof 10-21 it failed: "small host buffer churn evicted a retained small device buffer".main7ab4b2e561: ctest 1824/1828 on Windows (the 4 failures fail onmaintoo); Linux (WSL, GCC 13.3, lavapipe), CI's job on the merge withmain: 1762/1782, the same 20 fail onmain.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:23Z.
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-21T06:00:52Z.
I reviewed the new tier selection, budget/slot bound, and trim/destructor coverage; the focused
SmallDeviceOwnTiertest targets the eviction this change is meant to prevent. I could not runagc_buffer_poollocally from this checkout. One evidence gap remains: the performance A/B in the description turns #8911, #8912, and #8913 on/off as a group, so it does not isolate this tier’s effect. The perf-label check also asks for matchedmain/change captures, both summary lines, trace artifacts, andtrace_digest.pyoutput. Please attach those or keep the performance claim scoped to the combined set.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-21T06:18:56Z.
@MarcZX10 thanks for going through the tier selection, the slot bound and the trim/destructor coverage. Good to hear
SmallDeviceOwnTierreads as aimed at the right eviction.Fair point on the A/B: it toggled #8911, #8912 and this PR as a group, on our own Yōtei tree rather than
main, so it doesn't isolate the tier. I've rescoped the speed line to the combined set and kept only this tier's own hit/miss counts as PR-specific. The matchedmain/change captures with summary lines, traces andtrace_digest.pyoutput are still owed. I'll post them here once I can run them, but I don't have a date yet.Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-21T08:45:51Z.
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 CnRJay on 2026-10-21T18:05:55Z.
Review: COMMENTED
Each of these pool changes is small and the reasoning is sound (small device-local buffers evicting small host buffers out of one 64 MiB tier; a hit whose
VkBufferhas another exact size paying a destroy and bind). The problem is the set.main, and "not isolated for this PR". The three cannot be told apart, so none of them is shown to pay for itself, and a regression in one would be hidden by gains in the others.APS5_PROFILE_*. Until then the maintainers cannot tell which of the five is the one that helps, and a pool tuned by five independent heuristics is hard to reason about when the next title's churn pattern differs.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-21T20:33:29Z.
You're right about the set. The 6.17 vs 5.16 A/B toggled #8911, #8912 and #8913 together on our own Yōtei tree, so it can't show that any single one of them pays for itself. And the five pool PRs touch the same tiers and free list, so they interact.
Here's an order I'd suggest, for @LeandroLP23, @milescoviello and @eliasbruno124-dev to weigh in on:
#8911 doesn't touch the pool (it skips the queued-draw read check when a storage flush stores nothing), so it can be measured on its own at any point. If any of you would rather go in a different order, I'm happy to rebase ours around it.
For our three, I'll measure each one alone against
mainon Ghost of Yōtei in the open world, with the summary lines of both builds and noAPS5_PROFILE_*, and post the numbers on each PR. Those runs are queued behind other work on our machine, so I can't give a date yet. Until then I'd treat the earlier combined A/B as a hint, not evidence.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T20:54:12Z.
Thanks @Celegans12, that order works for me, with #8888 second. On the current heads,
git merge-treemerges #8888 cleanly with each of #8748, #8912, #8913 and #8672, so the order is about measurement, not conflicts. The interaction I'd watch is the one you named: with #8888 a large host request takes its size class's capacity, so #8913's exact-size scan meets class-sized buffers on that tier. If #8748 lands first, I'll rerun #8888's BO2 menu A/B on top of it and post the numbers there before asking for review again.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-22T09:49:29Z.
@CnRJay I ran each of the three pool PRs on its own now. 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 I can't give you main-vs-PR summary lines in the world. What I can give is our tree (our local merge with main of 2026-10-21) with only this PR's switch,
APS5_NO_SMALL_DEVICE_TIER, flipped every 60 s in one 1,300 s run: same scene and session for both halves.On presents this one is in the noise: 5.75 per 10 s with the tier vs 5.16 without, but paired against neighbouring phases it's -0.13 +- 0.62, so I wouldn't claim anything there. The per-draw cost is clearer: room wait on queue 0 goes from 94 to 113 us per draw without the tier (+18 +- 4 us, the one difference here well past noise), buffer allocation per upload from 3.5 to 12.7 us and the import lookup from 15 to 37 us. With the tier on, small device-local buffers hit about 88k times per phase against 357 misses.
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 using them. On the order with #8748, #8888 and #8672: I'm happy to rerun this A/B on top of whichever lands first.
Details
Run
pb-8912, 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_SMALL_DEVICE_TIERfrom present 760, RTX 3080 Laptop (610.62), Windows 11. B = the switch set, i.e. this PR's change off.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T11:31:12Z.
Review: CHANGES_REQUESTED
I reviewed the current head
b7fd852e0cba5c2078b742d220a50262d82a5055against livemainba5b5330b37724bca4b99f30faab504653635a04.The pool change and
SmallDeviceOwnTierregression are understandable, and the patch merges cleanly onto currentmain.git diff --checkandtools/check_conventions.pypass on that comparison. The author’s reported focused Windows and WSL test runs are useful; I did not independently run the product tests here. On the current PR head, only conventions/labels ran; the Windows, Linux, write-watch, register-context and relinker jobs are skipped.I’m requesting two follow-ups before approval:
Performance evidence: the title-menu main/change captures are well matched, but the report says this scene does not exercise the new small-device tier, and the measured change is within main’s run-to-run spread. The open-world result combines #8911, #8912 and #8913 on a non-main tree, so it cannot attribute the result to this PR. Please provide a same-title/scene/machine comparison on current
mainversus currentmainplus this PR in a workload that actually exercises the tier, including both summary lines, traces andtrace_digest.pyoutput. If this is intended as a correctness-only change, please remove the unsupported performance claim/label and coordinate that scope with maintainers.Overlap order: #8748 remains open and the PR body acknowledges a shared
BufferPool::Takeedit, but this PR’s checklist still saysDepends on: noneand I could not find an author-agreed landing order. Please agree the order with #8748’s author and record the dependency on the second PR, as the contribution rules require.The current-main merge preview, whitespace check and conventions check are clean; they do not resolve the performance attribution or ordering questions above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T11:09:15Z.
Review: APPROVED
Reviewed — looks good
The reviewed change adds a separate retention tier for small device-local buffers and its regression test; I found no verified blocking defect in the changed code.
What I ran
Reviewed head
edfd2f5dc0b323a5b1db517816c83e6421f9e49ausing the prepared diff and the pinnedrepo_read.pyreader. No tests or build commands were run; the Windows test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Did not run tests or a build, and did not independently verify the author-reported results. The review bundle lists all three changed files as included and reviewed:
core/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hpp,core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp, andcore/libs/prx/libSceAgcDriver/tests/BufferPool.cpp. No changed files were excluded.To get this to a good state
Nothing is required.