perf(agc): take guest memory caller samples only under APS5_PROFILE_DRAW #27117
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27117"
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 oneandonlydean on 2026-11-25T04:42:41Z.
What
GuestMemory::Read,ReadCommittedand the write path sample their caller on every 256th read and every 16th write: the sample resolves the return address withdladdrand takes a mutex on the calling thread. The samples are read in one place, the[guestmem]line, which is printed only underAPS5_PROFILE_DRAW.CountReadCallerandCountWriteCallernow return at once without that switch. With the switch set the line is unchanged.Why: at the PPSA21564 hub, CPU samples of the queue 0 worker (perf, 2999 Hz, 20 s, two arms, on another build of this week with a 49.8 ms frame) put 1.4 to 1.5 ms of its 43.5 ms of CPU per frame in this counter, most of it under the vertex stage decode. Every thread that reads guest memory pays the same way.
Tested
The 13 guest memory tests pass on Linux:
guest_memory,guest_memory_lifetime,guest_memory_resource,guest_memory_pool_stats,guest_icu_copy_guest_memory,agc_driver_depth_bits_guest_memoryand the sevenagc_driver_guest_memory_lifetime*tests.Linux, RTX 4090 (24 GB), i9-14900KF, 3840x2160, one exclusive window with nothing else on the machine.
PPSA21564 01.007.000,
-lvl hub_crashsitefrom a save, no input, no profile.main(9ca3cec822) againstcc25449add, 240 s arms, ordermain, PR, PR,mainafter a warm-up arm. Mean frame p50 of the last five 10 s rows of each arm; the floor of this scene is 1.0 ms.Driver.Drawper presentmain(warm-up)mainmainmain57.76 ms, this PR 57.20 ms: 0.56 ms less (1.0 %), which is below the floor, so at the frame this is neutral. Both PR arms are faster than all threemainarms, the warm-up included, and the worker's draw stage is 34.7 and 35.0 ms per present against 35.3 to 37.7 ms. Themainarms differ from each other by 2.4 ms on that stage, so this round gives the direction and not the size; the CPU samples above are the better estimate of the size. The dumped frames show the hub in all five arms.aps5-summary.jsonl, main
9ca3cec822(last row of the first main arm)aps5-summary.jsonl,
cc25449add(last row of the first PR arm)The
titlename field is left out of both lines.The numbers and the tests are of
cc25449add, the first commit here. The head differs from it by removed code comments only.Not tested here: Windows, AMD and Intel GPUs.
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 MarcZX10 on 2026-11-25T05:00:14Z.
Review: APPROVED
Reviewed — looks good
The change gates caller stack sampling on the same cached
APS5_PROFILE_DRAWsetting used by guest memory profiling, and the added code is consistent with that behavior.What I ran
5c42b37d968aff7f7945bc83dc0f75be6e3bb0a7; base ismain.GuestMemory.cpp, plus the touched sampling helper and its read/write call sites.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp.To get this to a good state
Nothing is required.