perf(agc): stage the written elements of address-based compute builds in device memory #8104
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8104"
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-19T21:49:19Z.
What
An address-based (BDA) compute build binds its written V# elements in place in the host imports of the cached address space, and its BDA table points there too, so every access to them goes over PCIe. Descriptor builds already stage written elements in device memory (
stagingEligible); address-based ones were left out because their pointers would still reach the import.Region::overlay), staged like any written element (copy-in, device-local shadow, copy-back).AddressRangescuts the import's table entry around it, so pointers into the element reach the shadow as its descriptor does.resolveOverlayskeeps a cluster of overlapping overlays only inside one direct import region, whenstagingEligibleholds and no in-place range or own region crosses it; otherwise it stays in the import.APS5_BDA_STAGING_MIN_THREADS(512) threads keep the imports (a 64-thread solver got 9 % slower on our bench).APS5_NO_BDA_STAGING=1turns it off.A CPU store into a staged element before its copy-back is rolled back, the trade-off main already accepts for staged elements; it is now listed in the libSceAgcDriver debt file, and the staging comments describe the overlay case.
Related: #7618 changes the window in
stagingEligible, which the clusters reuse; #6185 would apply to these copy-backs too.Tested
mainbf2c63f85, -DBUILD_TESTING=ON: full ctest 1685/1690 (before a clean rebase from252cbc29b); the same 5 fail onmainhere. The staging tests pass after the rebase (8/8,--repeat until-fail:3).agc_bda_staging(table cut, shadow binding, copy-back bytes, a crossing read keeps the import) fails withmain's code: "the staged element's BDA range does not send its addresses to the shadow".ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1: seven staging tests show noVUID-errors onmainor the branch.main.main: the cloth solver (0x80001c0d00) went from 5.6 to 1.8 ms GPU per dispatch on our bench (same output), and from 308 to 103 ms per present in the world. Nomainsummary lines for that scene.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-19T21:49:31Z.
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 Celegans12 on 2026-10-19T23:49:30Z.
There are no
mainnumbers on this one yet, I'm afraid. What I have are two summary lines from our Yōtei tree: the same build, scene, machine and environment, with this change switched off (APS5_NO_BDA_STAGING=1, run gl3-off) and on (run gl2). Over presents 880-891, frame p50 went from 2,828 to 2,536 ms and GPU busy from 1,166 to 884 ms per present. Most of that is the cloth solver (0x80001c0d00): 308 ms of GPU time per present in our baseline run, 103 ms with the change.Some caveats. Our tree isn't
main(it has bindless images, spanned waves and other local changes). The off run also had our local dispatch overlap switched off. That shouldn't matter, because the on run had per-range GPU timestamps on, and those serialize every dispatch anyway (they can only add time).For
mainagainst this branch I need a Yōtei run onmain, and the machine is busy with other game work right now. I'll do that pair when it's free and post both lines here. If the two traces behind the lines below would help in the meantime, I can attach them.Summary lines (our tree, not main)
Off (gl3-off):
On (gl2):
Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T07:39:53Z.
Tested on RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (
1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head69ac2e155:agc_bda_stagingpasses 3 of 3 on both GPUs.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by CPritch on 2026-10-20T12:37:31Z.
Ran this on GTA V (PPSA04263 01.010.002), Linux 7.2.8-zen1-2-zen, NVIDIA GeForce RTX 5060 Laptop GPU, NVIDIA 615.71.09, Graphics Mode Performance, the Story prologue after Resume Story, with no input.
main
d14a186f4against maind14a186f4+ #8104 at 69ac2e155, same machine and session, two runs each in the order A B A B, window frames 3600:700, caches warm, APS5_TRACE_EVENTS=4194304 (BUILD.md's remedy for full trace buffers), no other APS5_TRACE_* or APS5_PROFILE_* switch, log not redirected. The harness navigates the menus from frame dumps in boot and load to present 3420 (APS5_DUMP_FRAMES=114, every 30 presents), which stop before the window.Frame p50: main 80.8, 80.7 ms, with #8104 80.6, 80.3 ms (-0.3 ms, -0.3 %). GPU busy per present: 65.0 and 64.6 ms.
p90: main 89.8, 89.4 ms, with #8104 87.8, 89.0 ms; mean frame -1.292 and -0.139 ms (pair 1 and pair 2). p99 moved both ways.
The summary lines' Driver.EndSubmission (about 2,984 and 2,924 ms per frame) and worker_busy_pct for queue worker 0x0 (about 3,700 and 3,684 %) are not costs: on the pipelined path the Driver.EndSubmission timer stays open through the rewind tail, so nested tails are counted many times over (#8092; #8108 has the fix).
Not tested: other scenes, Fidelity mode, other GPUs.
Written with AI assistance (Claude Code); measured on the machine above.
Summary lines (main, then the PR):
{"commit":"d14a186f4615","dirty":false,"env":{"APS5_DUMP_FRAMES":"114","APS5_DUMP_FRAMES_EVERY":"30","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_FRAMES":"3600:700"},"gpu":"NVIDIA GeForce RTX 5060 Laptop GPU","driver":"NVIDIA 615.71.09","os":"Linux 7.2.8-zen1-2-zen","cpu":"AMD Ryzen AI 9 465 w/ Radeon 880M","cpu_threads":20,"memory_mib":31391,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.010.002","resolution":"3840x2160","window":{"spec":"frames 3600:700","first_present":3600,"ms":57683.201},"presents":700,"frame_ms":{"p50":80.75,"p90":89.76,"p99":113.913,"max":123.846},"gpu_busy_ms_per_present":65.082,"worker_busy_pct":{"queue worker 0x0":3700.498},"top_phases_ms_per_frame":{"Driver.EndSubmission":2983.789,"Driver.Packet":63.297,"Graphics.Draw":59.802,"Graphics.Draw.draw_and_resource_release":56.201,"Driver.Packet.draw":49.923,"Driver.Draw":49.707,"VideoOut.Flip":25.612,"Driver.Present":25.6},"trace_dropped":false,"trace":"aps5-trace-d14a186f4615-2531021.json.gz"}
{"commit":"7900b6edae74","dirty":false,"env":{"APS5_DUMP_FRAMES":"114","APS5_DUMP_FRAMES_EVERY":"30","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_FRAMES":"3600:700"},"gpu":"NVIDIA GeForce RTX 5060 Laptop GPU","driver":"NVIDIA 615.71.09","os":"Linux 7.2.8-zen1-2-zen","cpu":"AMD Ryzen AI 9 465 w/ Radeon 880M","cpu_threads":20,"memory_mib":31391,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.010.002","resolution":"3840x2160","window":{"spec":"frames 3600:700","first_present":3600,"ms":56778.478},"presents":700,"frame_ms":{"p50":80.589,"p90":87.781,"p99":99.906,"max":116.41},"gpu_busy_ms_per_present":64.595,"worker_busy_pct":{"queue worker 0x0":3683.717},"top_phases_ms_per_frame":{"Driver.EndSubmission":2923.746,"Driver.Packet":61.99,"Graphics.Draw":59.005,"Graphics.Draw.draw_and_resource_release":55.465,"Driver.Packet.draw":48.917,"Driver.Draw":48.7,"VideoOut.Flip":25.592,"Driver.Present":25.572},"trace_dropped":false,"trace":"aps5-trace-7900b6edae74-2539174.json.gz"}
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:32:45Z.
@Celegans12, two small things before CI:
bdaStagingTestsreturn 77 withhost imports, device addresses or the address space cache unavailable: address-based staging not testedandhost import of the test block refused: address-based staging not tested.tools/check_skips.pyonly accepts a skip whose line starts withskipped,and names a device limitation fromDEVICE_LIMITATIONon the same line, so either text fails the Linux job if the test ever skips there. Something likeskipped, host imports are unavailable (no device addresses or address space cache)andskipped, host imports are unavailable: the test block's import was refusedmatches it.main's whole "Device-local staging" comment aboveSweptShadowMaxinGuestBufferMemory.cpp(the measurements, the copy-back trade-off and theAPS5_NO_WRITTEN_SHADOW/APS5_NO_ATOMIC_STAGING/*_KIBswitches) and the header comment onstagingEligible. Only the "never address-based ones" sentence became wrong. Please keep both comments and change just that sentence to describe the overlay case.Separately, the
perflabel still needs amain-against-this-branch pair from the same scene (the PPSA26344 numbers come from a tree with other local changes). PPSA04263's pair onmainwas neutral (-0.3 % p50).Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-21T02:21:45Z.
Thanks, both are fixed in
5804207c5, which is also rebased onto current main.The two skip lines now read
skipped, host imports are unavailable (no device addresses or address space cache)andskipped, host imports are unavailable: the test block's import was refused. I checked both againstDEVICE_LIMITATIONin main'scheck_skips.py.Both comments are back as they are on main. The only change is the address-based sentence: the big comment now says that in an address-based build, a written element inside one direct import region becomes an overlay region, and
AddressRangescuts the import's range around it so its pointers reach the shadow. The header comment now says "not address-based unless an overlay region". One thing to flag:check_conventions.pyfails any added or changed comment line unless the PR also touches a debt file. That's why I had dropped the blocks. To keep them, I added one line todocs/dev/debt/libSceAgcDriver.mdfor the copy-back trade-off (a CPU store into a staged range between the copy-in and the copy-back is rolled back). The comment already calls it accepted, and this PR extends it to address-based builds. If you'd rather not have that entry, tell me and I'll find another way.The main-against-branch pair from the same Yōtei scene is still owed; I can't produce it today.