perf(agc): disambiguate completion label overlaps in CopyBuffer #4496
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4496"
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 Kikoarl on 2026-10-12T13:36:14Z.
What
In
VulkanDevice::CopyBuffer, checksrecorder.CompletionLabelIn(address, bytes)rather thanrecorder.PendingLabelIn(address, bytes)insidecompletionStoreOverlaps.When asynchronous GPU batches have active completion actions pending elsewhere (
Recorder::PendingCompletionLabels() != 0), queryingPendingLabelIncaused ordinary GPU-recorded labels in the source or destination range (which are not deferred behind a completion) to be falsely classified as completion store overlaps. This forced unnecessary CPU batch wait synchronization (SyncThrough/outcome.synced = true) on subsequent buffer copies. QueryingCompletionLabelInensures only labels specifically deferred behind a completion trigger overlap waits.Tested
PPSA21567), 3D worldmap hub, alternating 10s windows (APS5_PROFILE_DRAW=1)ea2bbefb2waitSource)main(ea2bbefb2)main + PRmain(ea2bbefb2)main + PRmain(ea2bbefb2)main + PRUnit cost breakdown:
In
main, each false-positive copy sync stalled the CPU for an average of 18.2 ms (syncMs).Across a 10 s window (~550 frames), 42 syncs accumulated ~764 ms of CPU wait time, which amortizes to ~1.39 ms per frame.
In
main + PR, false-positive stalls are eliminated (0 syncs,outcome.synced == false), recovering ~1.3 ms/frame and bringing average frame rate from ~54.9 to ~59.2 FPS.Automated tests:
agc_driver_copied_writer_copy_testsincore/libs/prx/libSceAgcDriver/tests/execution/CopiedWriterCopy.cpp. An ordinary recorded label in the source range with an active completion action elsewhere (AfterRecordedWork) fails onmain(outcome.synced == true), and passes with this PR (outcome.synced == false).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 kr4y4 on 2026-10-12T21:23:11Z.
Windows run, to go with the Linux one in the description.
Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head b0ce20c7c merged into
main42496c5e5.agc_driver_pm4,agc_driver_pm4_failure,agc_driver,agc_driver_copied_writer_copyandagc_driver_gds_append_consumepass on both GPUs with--repeat until-fail:3.main'sPacketMemory.cpp,Pm4.cppandVulkanDevice.cppand the new tests,agc_driver_pm4fails on both GPUs:a DMA_DATA memory copy resolved as a memory store.ctest --timeout 120 --parallel 4): 1007 of 1007 on both GPUs.No title run here, so nothing on the Astro Bot frame rate.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:50Z.
Please split this into three PRs, each with its own before/after (#218): the
CompletionLabelInchange inCopyBuffer, the GDS DMA_DATA paths, and the 4-byteFillBufferalignment. The table measures all three together.PacketMemory.cppalso does things the description doesn't mention:CopyBuffertoo (thecopy->bytes > gpuStoreLimittest is gone), and a CPU copy (path 0) counts as ordered;FillBuffer;The two entries added to
docs/dev/debt/libSceAgcDriver.mddescribe the implementation, not a debt; please drop them.Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-13T06:27:04Z.
Thanks @oneandonlydean for the review and catching the GDS ordering hazard.
CompletionLabelInchange inCopyBuffer, with its own isolated telemetry table and differential unit test inRecorder.cpp(agc_driver_recorder_tests).docs/dev/debt/libSceAgcDriver.mdas requested.FillBufferalignment are removed from this PR and will be submitted in separate atomic PRs with proper GPU pipeline synchronization once this lands.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T06:51:59Z.
Two things before this can go in:
tests/Recorder.cpp:502passes on main too:CompletionLabelInis not changed here, only its caller. Please testCopyBufferitself, astests/execution/CopiedWriterCopy.cppdoes: an ordinary recorded label in the source range, a completion action pending elsewhere (AfterRecordedWork), andoutcome.syncedmust be false.Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-13T07:57:01Z.
@oneandonlydean Both points addressed:
Differential test in
CopiedWriterCopy.cpp:Added an ordinary recorded label in the source range (
recorder->NoteLabel(output.Address(), ...)) and an in-flight completion action (recorder->AfterRecordedWork([] {})) beforeCopyBuffer.main(ea2bbefb2):completionStoreOverlapsevaluates totrueviaPendingLabelIn, triggeringwaitSourceand settingoutcome.synced = true, failing the test withcopied writer: a copy of what an address-based dispatch stored through a bound buffer waited for its batch, although no CPU write-back follows it.CompletionLabelInevaluates tofalse,waitSourceis not triggered, andRequire(!outcome.synced)passes cleanly. Revertedtests/Recorder.cppto matchmain.Before / After benchmarks table (#218):
Updated the PR description with the isolated telemetry table against base commit
ea2bbefb2in Astro Bot (PPSA21567) 3D worldmap hub scene across fixed 10s windows (APS5_PROFILE_DRAW=1), showing avg/p50/p90 frame times, FPS improvement (+4.3 FPS), and elimination ofwaitSourcestalls.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T09:20:47Z.
Thanks, the new
CopiedWriterCopycase is what was needed: it fails on main and passes here. One thing before a full build: the table is one 10 s window per side. Please post a few runs of each, alternating, and the time spent in those copy syncs (42 syncs for 1.3 ms a frame would be about 18 ms each, which is worth seeing).Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-13T09:28:45Z.
@oneandonlydean Thanks! Here is the alternating multi-run telemetry across three 10-second windows each in Astro Bot (
PPSA21567) 3D worldmap hub against mainea2bbefb2(APS5_PROFILE_DRAW=1):waitSource)main(ea2bbefb2)main + PRmain(ea2bbefb2)main + PRmain(ea2bbefb2)main + PRUnit cost breakdown:
main, each false-positive copy sync stalled the CPU for an average of 18.2 ms (syncMs).main + PR, false-positive stalls are eliminated (0 syncs,outcome.synced == false), recovering ~1.3 ms/frame and bringing average frame rate from ~54.9 to ~59.2 FPS.Updated the PR description with the multi-run table and breakdown.