perf(agc): the draw committer polls briefly for the next draw before it sleeps #5867
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5867"
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 Raghav314 on 2026-10-14T14:18:33Z.
What
With pipelined draws (on by default, depth 8), the committer thread sleeps on the condition variable whenever the queue is empty. In a draw-heavy frame the worker hands over a draw every few microseconds, so the committer goes to sleep after almost every commit and the worker pays a wake for the next one.
APS5_PIPELINE_SPIN_US=<us>makes the committer poll the queue count for up to that long before it sleeps (_mm_pausebetween polls, the clock read every 64 polls, as the queue-0 memory wait does).main. On a 4-core host the poll gave no fps and a worse p99 (below), so it stays opt-in.PPSA36082
Level UI/menu standing still,
APS5_HOST_IMPORT_MIB=6784, one build with the poll switched off and on (50 us) every 15 s in one sitting, 4 windows each, MangoHud fps per window (first 2 s of each window left out):On 8 cores the poll won every pair, by about 3%.
On 4 cores (
taskset -c 0-3), same procedure: 49.4 fps off, 49.5 on; frame time p99 26.8 ms off, 31.4 ms on. So the default stays 0, and a host with cores to spare can set it.Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090, NVIDIA 615.78.08, on
mainf474fb776.build.ymlrun locally: configure with SPIRV tools on, test registration check, build, libs, ctest 1299, all pass exceptagc_driver_store_over_untracked, which fails the same way onmain.APS5_PIPELINE_SPIN_US=50, theagc_*suite passes exceptagc_driver_store_over_untracked, as 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 CnRJay on 2026-10-14T16:56:13Z.
Review: COMMENTED
Polling briefly before sleeping is a reasonable trade for a hand-off every few microseconds. Two things to check before 50 µs becomes the default:
taskset -c 0-3, or the equivalent affinity on Windows) for both builds would show whether the gain survives.draw_enqueued(2.0 → 1.5 ms) as the only signal. Two or three alternated runs per build would make the frame-time line usable as well.Since this only applies with the opt-in
APS5_PIPELINED_DRAWS, defaulting the spin to 0 until those numbers are in would keep the mode's behaviour unchanged for anyone already using it.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T03:31:31Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppL121core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppL16Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cppImported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-16T19:19:59Z.
Rebased onto
mainf474fb776(only the poll commit is left; the rest is inmain). The default is now 0, so the committer behaves as onmainunlessAPS5_PIPELINE_SPIN_USis set.Both checks, level UI/menu, one build switching the poll off and on (50 us) every 15 s, 4 windows each:
taskset -c 0-3): 49.4 off, 49.5 on, and p99 26.8 to 31.4 ms. As you expected, it does not hold on 4 cores.LLM assistance used.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T19:57:09Z.
Review: CHANGES_REQUESTED
Checked the diff, built it merged onto current
mainand ran the AgcDriver ctest scope: green exceptagc_driver_tessellation(segfault, same onmainon RADV here). With the default 0 the committer behaves exactly as onmain; the 4-core measurement you added settles the earlier question.APS5_HANDOFF_SPIN_US, window picked from the usable core count, plus aagc_handoff_spintest) and edits the same part ofDrawPipeline::run/DrawPipeline.cpp. Only one of the two can land. Please agree with its author on which approach stays (yours is opt-in and 20 lines; theirs sizes the window by core count and covers the GPU mutex too) and list the other in Depends on or drop the overlapping part.APS5_*switches of the driver are described indocs/user/USAGE.md; if this one stays, addAPS5_PIPELINE_SPIN_US(unit, default 0, 4-core caveat) there.Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-16T20:04:12Z.
Closing this in favour of #6632, which spins in the same place in
DrawPipeline::runand also before the GPU mutex and inDrawPipeline::Drain, with a window picked from the usable core count and its own test. The measurements here back that policy (8 cores: +3%, 4 cores: no gain and a worse p99), so I posted them on #6632 instead.Thanks @CnRJay and @adriadam10 for the reviews.
LLM assistance used.
Pull request closed