feat(libSceAgcDriver): pin draw committer thread on hybrid architectures #7246

Closed
al3w0f205 wants to merge 1 commit from upstream-pr/7246 into main
al3w0f205 commented 2026-10-17 19:11:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by al3w0f205 on 2026-10-17T19:11:50Z.


What

Pins the background draw committer thread to worker affinity via PinWorkerThread("draw_committer") at worker start in DrawPipeline.cpp. This aligns the draw committer with hybrid CPU performance scheduling (when APS5_WORKER_AFFINITY is active) and avoids thread migration latency spikes during draw queue processing.

The flip completion latency changes in Presentation.cpp have been reverted to preserve GPU completion guarantees and keep video_out_flip_tests aftergpu passing.

Tested

tools/check_conventions.py --base origin/main passes. agc_driver_pm4_tests.exe and agc_driver_graphics_tests.exe pass on Windows.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 572.16, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4903117866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246). Originally posted by [al3w0f205](https://github.com/al3w0f205) on 2026-10-17T19:11:50Z. --- ### What Pins the background draw committer thread to worker affinity via `PinWorkerThread("draw_committer")` at worker start in `DrawPipeline.cpp`. This aligns the draw committer with hybrid CPU performance scheduling (when `APS5_WORKER_AFFINITY` is active) and avoids thread migration latency spikes during draw queue processing. The flip completion latency changes in `Presentation.cpp` have been reverted to preserve GPU completion guarantees and keep `video_out_flip_tests aftergpu` passing. ### Tested `tools/check_conventions.py --base origin/main` passes. `agc_driver_pm4_tests.exe` and `agc_driver_graphics_tests.exe` pass on Windows. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 572.16, Windows 11 - [x] AI-assisted: yes
oneandonlydean commented 2026-10-17 19:46:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T19:46:51Z.


Thanks for looking at flip latency. The Presentation.cpp change can't go in: the trailing FinishPresent() is the fix from d9632d552 ("complete a flip only once the frame's GPU work has finished"). Without it the flip completes as soon as the blit is queued, titles reuse the frame's memory while the GPU still reads it, and PPSA21564 produced runaway shader loops and wrong matrices that way. The wait already happens outside the GPU mutex, after QueuePresent. If flip latency is the target, please open an issue with frame-time captures (APS5_PROFILE_DRAW) and a title, and any change to when the flip completes needs to keep video_out_flip_tests aftergpu passing on a real GPU. The draw-committer pin is reasonable on its own; please submit it as a separate PR with a measurement on a hybrid CPU, where the pin actually applies (it is a no-op on Windows without APS5_WORKER_AFFINITY).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6239883174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6239883174). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T19:46:51Z. --- Thanks for looking at flip latency. The Presentation.cpp change can't go in: the `trailing` `FinishPresent()` is the fix from d9632d552 ("complete a flip only once the frame's GPU work has finished"). Without it the flip completes as soon as the blit is queued, titles reuse the frame's memory while the GPU still reads it, and PPSA21564 produced runaway shader loops and wrong matrices that way. The wait already happens outside the GPU mutex, after QueuePresent. If flip latency is the target, please open an issue with frame-time captures (APS5_PROFILE_DRAW) and a title, and any change to when the flip completes needs to keep `video_out_flip_tests aftergpu` passing on a real GPU. The draw-committer pin is reasonable on its own; please submit it as a separate PR with a measurement on a hybrid CPU, where the pin actually applies (it is a no-op on Windows without APS5_WORKER_AFFINITY).
cadenasynyster commented 2026-10-17 20:00:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-17T20:00:03Z.


Ran the VideoOut flip tests with a real window, which CI skips (offscreen SDL has no Vulkan surface): with this PR, flips complete before the GPU work submitted ahead of them.

Windows 11 10.0.26200.9711, RTX 5070 Ti (NVIDIA 617.42), WinLibs GCC 15.2.0 r7, Release. Head 700b4bcd7 merged onto main f3263dfbf (clean merge, no new build errors). All 20 video_out_flip_tests cases, run directly from build\core\libs\prx\libSceVideoOut, main vs this PR, one run each:

case main PR
pacing pass fail (exit 1)
aftergpu pass fail (exit 1)
other 14 non-EOP cases pass pass
eop, eop_main, eop_aftergpu, unavailable fail fail (same as main; EOP is #6616, unavailable expects no display)

aftergpu timing line:

main: GPU work landed at 171.2 ms, flip completed at 171.5 ms
PR:   GPU work landed at 171.9 ms, flip completed at 16.0 ms

So the flip is reported complete ~155 ms before the dispatch queued ahead of it finishes, which is what aftergpu's flipped + 20000 >= landed check guards against.

This looks like the removed trailing block in Driver::Present: with inFlight != 0, the frame is queued with QueuePresent() and gpuReady(context) is then called without the trailing FinishPresent(), so VideoOut counts the flip (flipStatus.count, flipPendingNum) before the frame's GPU work is done. I haven't tested the PinWorkerThread("draw_committer") part on its own.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6240057341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6240057341). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-17T20:00:03Z. --- Ran the VideoOut flip tests with a real window, which CI skips (offscreen SDL has no Vulkan surface): with this PR, flips complete before the GPU work submitted ahead of them. Windows 11 10.0.26200.9711, RTX 5070 Ti (NVIDIA 617.42), WinLibs GCC 15.2.0 r7, Release. Head 700b4bcd7 merged onto main f3263dfbf (clean merge, no new build errors). All 20 `video_out_flip_tests` cases, run directly from `build\core\libs\prx\libSceVideoOut`, main vs this PR, one run each: | case | main | PR | |---|---|---| | `pacing` | pass | **fail (exit 1)** | | `aftergpu` | pass | **fail (exit 1)** | | other 14 non-EOP cases | pass | pass | | `eop`, `eop_main`, `eop_aftergpu`, `unavailable` | fail | fail (same as main; EOP is #6616, `unavailable` expects no display) | `aftergpu` timing line: ``` main: GPU work landed at 171.2 ms, flip completed at 171.5 ms PR: GPU work landed at 171.9 ms, flip completed at 16.0 ms ``` So the flip is reported complete ~155 ms before the dispatch queued ahead of it finishes, which is what `aftergpu`'s `flipped + 20000 >= landed` check guards against. This looks like the removed `trailing` block in `Driver::Present`: with `inFlight != 0`, the frame is queued with `QueuePresent()` and `gpuReady(context)` is then called without the trailing `FinishPresent()`, so VideoOut counts the flip (`flipStatus.count`, `flipPendingNum`) before the frame's GPU work is done. I haven't tested the `PinWorkerThread("draw_committer")` part on its own. AI-assisted: yes
al3w0f205 commented 2026-10-17 23:30:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by al3w0f205 on 2026-10-17T23:30:55Z.


Thanks for the detailed verification and testing. I have reverted the Presentation.cpp changes to preserve the trailing FinishPresent() GPU completion guarantee and keep video_out_flip_tests (aftergpu and pacing) passing. This PR is now focused strictly on pinning the draw committer thread on hybrid CPU topologies.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243096559 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6243096559). Originally posted by [al3w0f205](https://github.com/al3w0f205) on 2026-10-17T23:30:55Z. --- Thanks for the detailed verification and testing. I have reverted the Presentation.cpp changes to preserve the trailing FinishPresent() GPU completion guarantee and keep video_out_flip_tests (aftergpu and pacing) passing. This PR is now focused strictly on pinning the draw committer thread on hybrid CPU topologies.
cadenasynyster commented 2026-10-18 15:13:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-18T15:13:46Z.


Rechecked 8dbd8de with a real window, same setup as my earlier comment (Windows 11 26200, RTX 5070 Ti, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release), merged onto main 9f25d0b:

  • aftergpu passes: GPU work landed at 176.6 ms, flip completed at 177.0 ms. The early flip completion I reported is gone.
  • pacing fails (the next flip is not paced from the vblank this flip was released at), but it fails the same way on main 9f25d0b without this PR, 3 of 3 runs each. It passed on main f3263df in my earlier run, so it comes from main, not from this PR. I'm looking into that separately.

Not tested: the draw-committer pin itself. This machine is a Ryzen 7 9800X3D (no hybrid cores), and APS5_WORKER_AFFINITY was unset.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251535611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6251535611). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-18T15:13:46Z. --- Rechecked 8dbd8de with a real window, same setup as my earlier comment (Windows 11 26200, RTX 5070 Ti, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release), merged onto main 9f25d0b: - `aftergpu` passes: `GPU work landed at 176.6 ms, flip completed at 177.0 ms`. The early flip completion I reported is gone. - `pacing` fails (`the next flip is not paced from the vblank this flip was released at`), but it fails the same way on main 9f25d0b without this PR, 3 of 3 runs each. It passed on main f3263df in my earlier run, so it comes from main, not from this PR. I'm looking into that separately. Not tested: the draw-committer pin itself. This machine is a Ryzen 7 9800X3D (no hybrid cores), and `APS5_WORKER_AFFINITY` was unset. AI-assisted: yes
MarcZX10 commented 2026-10-18 15:41:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T15:41:25Z.


Coordination note from new issue #7581: the pacing case now fails 3/3 on main as well as on the PR's tested base. I inspected current testReleaseVblank and VideoOutDriver::processFlip: the test submits only one flip, while processFlip waits for the configured interval before release and updates lastFlipVblank immediately before presentation. The test then expects another three vblanks before that same flip's completion, although the configured interval is used to pace a subsequent flip. I posted the source-based reasoning and a possible second-flip regression shape on #7581. This may explain the baseline test failure independently of the pinning change; I have not run the RTX setup.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251816237 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6251816237). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T15:41:25Z. --- Coordination note from new issue #7581: the `pacing` case now fails 3/3 on main as well as on the PR's tested base. I inspected current `testReleaseVblank` and `VideoOutDriver::processFlip`: the test submits only one flip, while `processFlip` waits for the configured interval before release and updates `lastFlipVblank` immediately before presentation. The test then expects another three vblanks before that same flip's completion, although the configured interval is used to pace a subsequent flip. I posted the source-based reasoning and a possible second-flip regression shape on #7581. This may explain the baseline test failure independently of the pinning change; I have not run the RTX setup.
cadenasynyster commented 2026-10-18 15:59:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-18T15:59:34Z.


Rechecked 8dbd8de with a real window, same setup as my earlier comment (Windows 11 26200, RTX 5070 Ti, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release), merged onto main 9f25d0b:

  • aftergpu passes: GPU work landed at 176.6 ms, flip completed at 177.0 ms. The early flip completion I reported is gone.
  • pacing fails (the next flip is not paced from the vblank this flip was released at), but it fails the same way on main 9f25d0b without this PR, 3 of 3 runs each, so it is not from this PR. It is tracked in #7581, and #7583 changes the test's assertion.

Correction to my earlier comment: I listed pacing as passing on main f3263df. That run used a test binary left over from the older output folder; rebuilt from f3263df it fails too.

Not tested: the draw-committer pin itself. This machine is a Ryzen 7 9800X3D (no hybrid cores), and APS5_WORKER_AFFINITY was unset.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251999550 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6251999550). Originally posted by [cadenasynyster](https://github.com/cadenasynyster) on 2026-10-18T15:59:34Z. --- Rechecked 8dbd8de with a real window, same setup as my earlier comment (Windows 11 26200, RTX 5070 Ti, NVIDIA 617.42, WinLibs GCC 15.2.0 r7, Release), merged onto main 9f25d0b: - `aftergpu` passes: `GPU work landed at 176.6 ms, flip completed at 177.0 ms`. The early flip completion I reported is gone. - `pacing` fails (`the next flip is not paced from the vblank this flip was released at`), but it fails the same way on main 9f25d0b without this PR, 3 of 3 runs each, so it is not from this PR. It is tracked in #7581, and #7583 changes the test's assertion. Correction to my earlier comment: I listed `pacing` as passing on main f3263df. That run used a test binary left over from the older output folder; rebuilt from f3263df it fails too. Not tested: the draw-committer pin itself. This machine is a Ryzen 7 9800X3D (no hybrid cores), and `APS5_WORKER_AFFINITY` was unset. AI-assisted: yes
al3w0f205 commented 2026-10-18 16:01:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by al3w0f205 on 2026-10-18T16:01:35Z.


Thanks for verifying the aftergpu pass with the real window and for tracking down the pacing baseline failure on main via #7581 and #7583.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252020022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6252020022). Originally posted by [al3w0f205](https://github.com/al3w0f205) on 2026-10-18T16:01:35Z. --- Thanks for verifying the `aftergpu` pass with the real window and for tracking down the `pacing` baseline failure on main via #7581 and #7583.
adriadam10 commented 2026-10-19 13:20:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T13:20:14Z.

Review: CHANGES_REQUESTED


Thanks for reverting the Presentation.cpp part. Two things left:

  • This is a perf PR but has no before/after numbers. Please post them from a hybrid CPU with APS5_WORKER_AFFINITY=1 vs unset (e.g. APS5_PROFILE_DRAW frame times or draw committer stall counters, several runs, title/PPSA named). Pinning is off by default, so without data it is unclear what it improves.
  • The PR now conflicts with main: DrawPipeline::run() begins with PerformanceTrace::BindThread("draw committer"); and there is a new PerformanceTrace.hpp include. Rebase and keep both (PinWorkerThread("draw_committer") after the BindThread line, the WorkerAffinity.hpp include alongside).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5572147650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#pullrequestreview-5572147650). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T13:20:14Z. **Review:** CHANGES_REQUESTED --- Thanks for reverting the Presentation.cpp part. Two things left: - This is a `perf` PR but has no before/after numbers. Please post them from a hybrid CPU with `APS5_WORKER_AFFINITY=1` vs unset (e.g. `APS5_PROFILE_DRAW` frame times or draw committer stall counters, several runs, title/PPSA named). Pinning is off by default, so without data it is unclear what it improves. - The PR now conflicts with `main`: `DrawPipeline::run()` begins with `PerformanceTrace::BindThread("draw committer");` and there is a new `PerformanceTrace.hpp` include. Rebase and keep both (`PinWorkerThread("draw_committer")` after the `BindThread` line, the `WorkerAffinity.hpp` include alongside).
github-actions[bot] commented 2026-10-19 17:30:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T17:30:30Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6273204292 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#issuecomment-6273204292). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T17:30:30Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
adriadam10 commented 2026-10-24 01:58:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T01:58:51Z.

Review: CHANGES_REQUESTED


Thanks for reverting the Presentation.cpp part; the rebase onto main is clean now. One point is left, and only you can provide it:

  • This is a perf PR but has no measurements. Please post the aps5-summary.jsonl line of a capture on main and one with the change (APS5_WORKER_AFFINITY=1 vs unset), from the same title (PPSA named), scene and hybrid-CPU machine, several runs, the two traces and the tools/trace_digest.py output, as the pr-labels-perf bot asks. Pinning is off by default, so without numbers it is unclear what this improves.

We can't produce this ourselves (no hybrid CPU or title here). Without data we'll close this as stale later; feel free to reopen with it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5636307010 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7246#pullrequestreview-5636307010). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-24T01:58:51Z. **Review:** CHANGES_REQUESTED --- Thanks for reverting the Presentation.cpp part; the rebase onto `main` is clean now. One point is left, and only you can provide it: - This is a `perf` PR but has no measurements. Please post the `aps5-summary.jsonl` line of a capture on `main` and one with the change (`APS5_WORKER_AFFINITY=1` vs unset), from the same title (PPSA named), scene and hybrid-CPU machine, several runs, the two traces and the `tools/trace_digest.py` output, as the `pr-labels-perf` bot asks. Pinning is off by default, so without numbers it is unclear what this improves. We can't produce this ourselves (no hybrid CPU or title here). Without data we'll close this as stale later; feel free to reopen with it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7246
No description provided.