feat(agc): sample the draw committer with APS5_SAMPLE_COMMITTER #8075

Merged
johandavidcm merged 1 commit from upstream-pr/8075 into main 2026-10-21 01:12:37 +00:00
johandavidcm commented 2026-10-19 19:53:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-19T19:53:32Z.


What

APS5_SAMPLE_COMMITTER=<file> samples queue 0's draw committer with the worker's sampler and writes the same two files as APS5_SAMPLE_WORKER: <file> (module offset self inclusive) and <file stem>.collapsed.txt (whole stacks for speedscope.app or flamegraph.pl).

The committer records the draws the packet worker hands over (APS5_PIPELINED_DRAWS). When the worker's stacks wait in DrawPipeline::Enqueue, the committer is the thread that bounds the frame, and only APS5_SAMPLE_THREADS reaches it: its 40 hottest addresses, 12 frames deep, with no whole stacks. Sampling the committer is what showed, in #8068, that 12 % of its samples in PPSA31327's gameplay rescan the DCC keys of sampled textures in cachedTexture, a path the worker's stacks and the trace phases do not name.

  • DrawPipeline::run starts the sampler when the committer thread starts, after it binds to the trace. The committer starts with the first pipelined draw, so with APS5_PIPELINED_DRAWS=0 nothing is sampled.
  • The worker and committer samplers share one start function (the old body of StartWorkerSampler, taking the output path and the thread slot). StopWorkerSampler stops both. Without the variable nothing starts, as for the worker.
  • BUILD.md (Worker sampler) and ENVIRONMENT.md describe the variable. Windows only, like the other two samplers.

Overlap: #7622 changes the same workerSamplerThread = std::jthread(...) line to Libc::StartHostJThread, which is slot = std::jthread(...) here; #7246 adds PinWorkerThread("draw_committer") beside the line this adds to DrawPipeline::run. Both are one-line merges; I will rebase if either lands first.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 (ucrt, posix, seh, r7), Release, NVIDIA GeForce RTX 4070 (driver 617.42), Ryzen 7 7800X3D.

  • libSceAgcDriver builds on main b7fc3d324, with no warning in the touched files.
  • PPSA31327, on my bring-up tree (main 40393b0f9 with #6572 and #7381) with the same WorkerSampler.cpp and the same two lines in DrawPipeline.cpp: a 50 s run with APS5_SAMPLE_COMMITTER and APS5_SAMPLE_WORKER writes both pairs of files every 20 s, 2,562 samples each, and every committer stack not marked [truncated] (4 are) is rooted at DrawPipeline::run. An earlier version of this change, which passed the variable name instead of the path, sampled about 200 s of gameplay for #8068 (12,810 samples; the committer file is attached there).
  • tools/check_conventions.py --base origin/main passes. tools/env_reference.py --check finds the new row; its only error is APS5_CPU_FLIP_IN_ORDER, which has no row on main either.
  • Linux was not built; the non-Windows branch adds an empty StartCommitterSampler beside the other two.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 617.42, Windows 11 Pro 26200 (the PPSA31327 run; no GPU test covers the sampler)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4926553002 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8075). Originally posted by [johandavidcm](https://github.com/johandavidcm) on 2026-10-19T19:53:32Z. --- ### What `APS5_SAMPLE_COMMITTER=<file>` samples queue 0's draw committer with the worker's sampler and writes the same two files as `APS5_SAMPLE_WORKER`: `<file>` (`module offset self inclusive`) and `<file stem>.collapsed.txt` (whole stacks for speedscope.app or flamegraph.pl). The committer records the draws the packet worker hands over (`APS5_PIPELINED_DRAWS`). When the worker's stacks wait in `DrawPipeline::Enqueue`, the committer is the thread that bounds the frame, and only `APS5_SAMPLE_THREADS` reaches it: its 40 hottest addresses, 12 frames deep, with no whole stacks. Sampling the committer is what showed, in #8068, that 12 % of its samples in PPSA31327's gameplay rescan the DCC keys of sampled textures in `cachedTexture`, a path the worker's stacks and the trace phases do not name. - `DrawPipeline::run` starts the sampler when the committer thread starts, after it binds to the trace. The committer starts with the first pipelined draw, so with `APS5_PIPELINED_DRAWS=0` nothing is sampled. - The worker and committer samplers share one start function (the old body of `StartWorkerSampler`, taking the output path and the thread slot). `StopWorkerSampler` stops both. Without the variable nothing starts, as for the worker. - BUILD.md (Worker sampler) and ENVIRONMENT.md describe the variable. Windows only, like the other two samplers. Overlap: #7622 changes the same `workerSamplerThread = std::jthread(...)` line to `Libc::StartHostJThread`, which is `slot = std::jthread(...)` here; #7246 adds `PinWorkerThread("draw_committer")` beside the line this adds to `DrawPipeline::run`. Both are one-line merges; I will rebase if either lands first. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0 (ucrt, posix, seh, r7), Release, NVIDIA GeForce RTX 4070 (driver 617.42), Ryzen 7 7800X3D. - `libSceAgcDriver` builds on `main` b7fc3d324, with no warning in the touched files. - PPSA31327, on my bring-up tree (`main` 40393b0f9 with #6572 and #7381) with the same `WorkerSampler.cpp` and the same two lines in `DrawPipeline.cpp`: a 50 s run with `APS5_SAMPLE_COMMITTER` and `APS5_SAMPLE_WORKER` writes both pairs of files every 20 s, 2,562 samples each, and every committer stack not marked `[truncated]` (4 are) is rooted at `DrawPipeline::run`. An earlier version of this change, which passed the variable name instead of the path, sampled about 200 s of gameplay for #8068 (12,810 samples; the committer file is attached there). - `tools/check_conventions.py --base origin/main` passes. `tools/env_reference.py --check` finds the new row; its only error is `APS5_CPU_FLIP_IN_ORDER`, which has no row on `main` either. - Linux was not built; the non-Windows branch adds an empty `StartCommitterSampler` beside the other two. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070, driver 617.42, Windows 11 Pro 26200 (the PPSA31327 run; no GPU test covers the sampler) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 19:59:33 +00:00 (Migrated from github.com)

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


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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7246 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp L144
PR 7622 core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp L305

Some 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.

Pull request Shared files not compared
PR 674 docs/dev/BUILD.md
PR 1835 docs/dev/BUILD.md
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
PR 5021 docs/dev/BUILD.md
PR 5431 docs/dev/ENVIRONMENT.md
PR 6185 docs/dev/ENVIRONMENT.md
PR 6186 docs/dev/ENVIRONMENT.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp
PR 6636 docs/dev/ENVIRONMENT.md
PR 6879 docs/dev/BUILD.md
docs/dev/ENVIRONMENT.md
PR 6924 docs/dev/ENVIRONMENT.md
PR 6946 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
docs/dev/ENVIRONMENT.md
PR 6947 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
docs/dev/ENVIRONMENT.md
PR 7484 docs/dev/ENVIRONMENT.md
PR 7604 docs/dev/ENVIRONMENT.md
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp
docs/dev/ENVIRONMENT.md
PR 8077 docs/dev/ENVIRONMENT.md
PR 8206 docs/dev/ENVIRONMENT.md
PR 8484 docs/dev/ENVIRONMENT.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6276068074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8075#issuecomment-6276068074). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T19:59:33Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7246](https://www.github.com/boykopovar/AnyPS5/pull/7246) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp` [L144](https://github.com/boykopovar/AnyPS5/blob/7da0e44f80a9dda24f9509557013efb4c64c5c7d/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp#L144) | | | | [PR 7622](https://www.github.com/boykopovar/AnyPS5/pull/7622) | `core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp` [L305](https://github.com/boykopovar/AnyPS5/blob/7da0e44f80a9dda24f9509557013efb4c64c5c7d/core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp#L305) | | | Some 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. | Pull request | Shared files not compared | |---|---| | [PR 674](https://www.github.com/boykopovar/AnyPS5/pull/674) | `docs/dev/BUILD.md` | | [PR 1835](https://www.github.com/boykopovar/AnyPS5/pull/1835) | `docs/dev/BUILD.md` | | [PR 1896](https://www.github.com/boykopovar/AnyPS5/pull/1896) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/BUILD.md` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `docs/dev/ENVIRONMENT.md` | | [PR 6185](https://www.github.com/boykopovar/AnyPS5/pull/6185) | `docs/dev/ENVIRONMENT.md` | | [PR 6186](https://www.github.com/boykopovar/AnyPS5/pull/6186) | `docs/dev/ENVIRONMENT.md` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Execution/src/WorkerSampler.cpp` | | [PR 6636](https://www.github.com/boykopovar/AnyPS5/pull/6636) | `docs/dev/ENVIRONMENT.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `docs/dev/BUILD.md`<br>`docs/dev/ENVIRONMENT.md` | | [PR 6924](https://www.github.com/boykopovar/AnyPS5/pull/6924) | `docs/dev/ENVIRONMENT.md` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp`<br>`docs/dev/ENVIRONMENT.md` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp`<br>`docs/dev/ENVIRONMENT.md` | | [PR 7484](https://www.github.com/boykopovar/AnyPS5/pull/7484) | `docs/dev/ENVIRONMENT.md` | | [PR 7604](https://www.github.com/boykopovar/AnyPS5/pull/7604) | `docs/dev/ENVIRONMENT.md` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp`<br>`docs/dev/ENVIRONMENT.md` | | [PR 8077](https://www.github.com/boykopovar/AnyPS5/pull/8077) | `docs/dev/ENVIRONMENT.md` | | [PR 8206](https://www.github.com/boykopovar/AnyPS5/pull/8206) | `docs/dev/ENVIRONMENT.md` | | [PR 8484](https://www.github.com/boykopovar/AnyPS5/pull/8484) | `docs/dev/ENVIRONMENT.md` |
Rajkamalcode commented 2026-10-20 04:40:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Rajkamalcode on 2026-10-20T04:40:12Z.


SWAG (PPSA22102) validation of APS5_SAMPLE_COMMITTER

Measured

Windows 10.0.22635, RTX 3070, driver 610.88. Build: base b6dd2f9e3 + this PR, driver prx 77063CAD7CDA76F4. Title PPSA22102 at the tutorial spawn, low-settings diagnostic profile (the committer is the wall there), 360 s, same pad replay, APS5_PROFILE_DRAW=1, no trace. APS5_SAMPLE_COMMITTER=<file> produced both files.

  • Final window: 22,947 samples (a 12,809-sample mid-run snapshot was also taken).
  • Top inclusive: DrawPipeline::run waits 12,616 + 7,659 = 88.4% of samples; commitDraw 6,284; refreshResidentTarget 2,412; ShaderResources ctor/buildComplete/resolveImageBinding 1,151/999/958; fprintf 1,323 (5.8% of samples).
  • The collapsed file opens in speedscope; the symbolizer resolves the prx with nm; no crash or regression in the 360 s run.

On the same title at stock defaults, a baseline trace (not this PR build; this PR adds instrumentation only) shows the committer 44.2/43.3% busy and 29%/24% of that busy time in GpuMutex.wait.draw, while the worker is the wall at 97.1/97.6%. So the committer sampler is valuable when DrawPipeline::Enqueue waits make the committer the bound; the default-settings profile is worker-bound.

AI-generated analysis (separate from the measured data)

  • The PR reaches the committer as described, names the wait and the resource work in whole stacks, and the output is usable in speedscope. The fprintf share is sampler-side overhead, not title work; it is not a blocker.
  • The low-settings profile is diagnostic, not a default-settings result; at default settings the committer is not the wall.

Artifact

swag-run23-committer.collapsed.txt (22,947 samples); the 12,809-sample mid snapshot is also available. I will attach it in a follow-up drag-and-drop since gh cannot attach files.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6283526840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8075#issuecomment-6283526840). Originally posted by [Rajkamalcode](https://github.com/Rajkamalcode) on 2026-10-20T04:40:12Z. --- ## SWAG (PPSA22102) validation of `APS5_SAMPLE_COMMITTER` ### Measured Windows 10.0.22635, RTX 3070, driver 610.88. Build: base `b6dd2f9e3` + this PR, driver prx `77063CAD7CDA76F4`. Title `PPSA22102` at the tutorial spawn, low-settings diagnostic profile (the committer is the wall there), 360 s, same pad replay, `APS5_PROFILE_DRAW=1`, no trace. `APS5_SAMPLE_COMMITTER=<file>` produced both files. - Final window: **22,947 samples** (a 12,809-sample mid-run snapshot was also taken). - Top inclusive: `DrawPipeline::run` waits 12,616 + 7,659 = **88.4% of samples**; `commitDraw` 6,284; `refreshResidentTarget` 2,412; `ShaderResources` ctor/buildComplete/resolveImageBinding 1,151/999/958; `fprintf` 1,323 (5.8% of samples). - The collapsed file opens in speedscope; the symbolizer resolves the prx with nm; no crash or regression in the 360 s run. On the same title at **stock defaults**, a baseline trace (not this PR build; this PR adds instrumentation only) shows the committer 44.2/43.3% busy and 29%/24% of that busy time in `GpuMutex.wait.draw`, while the worker is the wall at 97.1/97.6%. So the committer sampler is valuable when `DrawPipeline::Enqueue` waits make the committer the bound; the default-settings profile is worker-bound. ### AI-generated analysis (separate from the measured data) - The PR reaches the committer as described, names the wait and the resource work in whole stacks, and the output is usable in speedscope. The `fprintf` share is sampler-side overhead, not title work; it is not a blocker. - The low-settings profile is diagnostic, not a default-settings result; at default settings the committer is not the wall. ### Artifact `swag-run23-committer.collapsed.txt` (22,947 samples); the 12,809-sample mid snapshot is also available. I will attach it in a follow-up drag-and-drop since `gh` cannot attach files.
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!8075
No description provided.