Skip to content

feat(agc): time the queue worker's waits for the draw finisher - #21208

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
talha-devp:feat/finisher-drain-timing
Nov 26, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
talha-devp:feat/finisher-drain-timing

Conversation

@talha-devp

@talha-devp talha-devp commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

With APS5_DRAW_PIPELINE set, the queue worker waits for the draw finisher to drain in two places:

  • at the packet gate, before a packet that cannot run beside the finisher;
  • at the end of every queue-0 submission.

Both waits sit outside the Driver.Packet and Driver.EndSubmission scopes. So neither worker_busy_pct nor the phase totals showed them, and a trace could not tell a worker that waits for the finisher from one that is idle.

Both waits are now timed as Driver.FinisherDrain. The trace summary lists it with the other phases, and worker_busy_pct (also the overlay's BUSY %) and the frame timing's worker_accounted_ms count it with the other worker scopes; BUILD.md and USAGE.md list it. Nothing else changes: the drains run as before.

Tested

Windows 10 22H2 (19045), RTX 4060 (NVIDIA 621.14), Ryzen 5 5600, MSYS2 UCRT64 GCC 16.2.0, Release.

Tested as 918d91426a, this change on main df18ede1f2. The branch is the same commit rebased onto a newer main.

  • GPU tests, on main and on this change, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer (layer 1.4.363). They cover the 15 tests of nine executables:

    • agc_driver_gated_dispatch_capture_tests
    • agc_driver_pipelined_dispatch_tests
    • agc_driver_pipelined_sample_dump_tests
    • agc_driver_draw_recapture_on_change_tests
    • agc_driver_copied_writer_label_order_tests
    • agc_driver_batch_cap_tests
    • agc_driver_dword_pattern_fill_tests
    • agc_driver_linear_target_completion_points_tests
    • agc_driver_write_data_written_ahead_tests

    Both builds: 15 of 15 pass, the loader inserts the layer, and there are 0 VUID- lines.

  • Busy accounting, c035f8be5c: agc_performance_trace now checks that 4 ms of Driver.FinisherDrain raises a worker's busy share from 35 to 45 % of a 40 ms window. agc_performance_trace, agc_performance_overlay_statistics, agc_performance_overlay (3 tests) and agc_driver_pm4_rewind_trace pass, 6 of 6, with the validation layer inserted and 0 VUID- lines.

  • Hades II (PPSA36082): one replay of a recorded controller session with APS5_DRAW_PIPELINE=1 APS5_PIPELINE_DISPATCH=1, so the draw finisher is on.

  • tools/check_conventions.py --base origin/main passes.

  • tools/pr_overlap.py --branch fails closed: 7 open pull requests that conflict with main also change PacketExecution.cpp. I checked their diffs, and none of them changes these finisher drains or Driver.EndSubmission.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 4060, driver 621.14, Windows 10 22H2
  • AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the drain timers are scoped around both waits and appear in the trace phase totals. The new scope is not included in worker busy percentage or frame worker-accounted time.

What I ran

  • Reviewed head 8aa6fac586fe391eaaa3bf5cd2485f6b76c66d5f; no tests or build commands were run.
  • Read description.md, commits.md, manifest.json, diff.patch, the changed PacketExecution.cpp ranges, and relevant PerformanceTimer.hpp and PerformanceTrace.hpp ranges. No changed files were excluded by the manifest.

Results

Check Result Note
Diff and targeted source review passed Both drains are timed
Build and tests not run Author-reported checks were not rerun

Findings

Blocking

None.

Non-blocking

  • The description says the change makes worker waits distinguishable from idle time, but Driver.FinisherDrain is not included in TraceFormat::WorkerBusyScopes or the FrameTiming::Capture worker-accounted scope list. As a result, the new metric appears in phase totals but the corresponding time still contributes to idle/unattributed worker time and is excluded from worker_busy_pct. Consider adding the scope to those lists if the intent is to account for these waits as worker busy time.

Not verified

  • Build, tests, GPU behavior, and author-reported results were not independently verified.

To get this to a good state

Nothing is required. Optional: include Driver.FinisherDrain in worker busy and accounted time if those metrics should include the drains.

@NathanFahey23

NathanFahey23 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head 8aa6fac586, merged onto main 3251ad6944 (497d0dab35, clean merge). This adds an RTX 4080 and the whole GPU set to the RTX 4060 run in the description. I didn't capture a trace, so Driver.FinisherDrain itself is not checked.

Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (10de:2704, driver 32.0.16.2101), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer loaded. GPU set: ctest -R '^(agc_\|shader\|video_out\|guest_video)' --parallel 4, one run per side.

main 3251ad6944 merge 497d0dab35
GPU set 1955 pass, 20 skipped, 0 failed 1955 pass, 20 skipped, 0 failed
VUID- lines 0 0
the 26 tests of the nine executables listed in the PR's Tested section 26 Passed 26 Passed
homebrew, 30 s each (tools/title_run.py, cold shader cache) Jelly5 rendering 116.9, VLC rendering 119.4, DriftCheck rendering 54.2, PS5SX2 rendering 59.6, DOOM rendering 36.4 Jelly5 rendering 86.1, VLC rendering 117.8, DriftCheck rendering 32.0, PS5SX2 rendering 59.7, DOOM rendering 36.4

The one test not run on both sides is agc_driver_upload_cache_read_only_flush: its executable does not build on Windows on this main (setenv, fixed by #19899). The homebrew titles are Jelly5, VLC, DriftCheck, PS5SX2 and DOOM; fps is one run each, for whether they still render, not a performance comparison. Jelly5 dropped from about 116 to about 86 fps on every merge I ran after 15:00 local today, including PRs with unrelated changes, so that drop comes from this machine, not from this PR.

Not checked: AMD, Linux, macOS, any commercial title.

AI-assisted: yes

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

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 18029 core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp L385
PR 22697 core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp L385
PR 26608 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp L635-636

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 1835 docs/dev/BUILD.md
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 4847 docs/user/USAGE.md
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
docs/user/USAGE.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6924 docs/user/USAGE.md
PR 7642 docs/user/USAGE.md
PR 9345 docs/user/USAGE.md
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
docs/user/USAGE.md
PR 10193 docs/user/USAGE.md
PR 10861 docs/user/USAGE.md
PR 11435 docs/dev/BUILD.md
PR 11436 docs/dev/BUILD.md
PR 12678 docs/user/USAGE.md
PR 12746 docs/user/USAGE.md
PR 12828 core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp
PR 13809 core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp
core/libs/prx/libSceAgcDriver/tests/PerformanceTrace.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 13928 docs/user/USAGE.md
PR 13929 docs/user/USAGE.md
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
docs/dev/BUILD.md
PR 15245 docs/user/USAGE.md
PR 15456 docs/dev/BUILD.md
docs/user/USAGE.md
PR 15973 docs/user/USAGE.md
PR 16571 docs/user/USAGE.md
PR 16793 docs/dev/BUILD.md
PR 17557 docs/user/USAGE.md
PR 18082 docs/user/USAGE.md
PR 18208 docs/dev/BUILD.md
PR 18210 docs/dev/BUILD.md
PR 19557 docs/dev/BUILD.md
PR 19610 docs/dev/BUILD.md
PR 19670 docs/dev/BUILD.md
PR 20315 docs/dev/BUILD.md
docs/user/USAGE.md
PR 21211 docs/user/USAGE.md
PR 21222 docs/dev/BUILD.md
PR 21420 docs/user/USAGE.md
PR 21939 docs/dev/BUILD.md
PR 22004 docs/dev/BUILD.md
PR 22434 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
docs/dev/BUILD.md
docs/user/USAGE.md
PR 22594 docs/dev/BUILD.md
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
docs/dev/BUILD.md
docs/user/USAGE.md
PR 23188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 23636 docs/user/USAGE.md
PR 23842 docs/user/USAGE.md
PR 23975 docs/user/USAGE.md
PR 24402 docs/dev/BUILD.md
PR 26131 docs/dev/BUILD.md
PR 26340 core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTimer.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 26613 docs/dev/BUILD.md
PR 26615 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
docs/dev/BUILD.md
PR 27133 docs/dev/BUILD.md
docs/user/USAGE.md

@talha-devp

Copy link
Copy Markdown
Contributor Author

Thanks, done in c035f8b: Driver.FinisherDrain now counts in worker_busy_pct (and the overlay's BUSY %) and in the frame timing's worker_accounted_ms. agc_performance_trace checks it, and BUILD.md and USAGE.md list the scope.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the new finisher drain scope is included in the trace summary and frame accounting as described.

What I ran

Reviewed head c035f8be5c517442997bf2a3da8a88cfdecc2b60. No commands or tests were run. Read all six changed files listed in the manifest: PerformanceTimer.hpp, PerformanceTrace.hpp, PacketExecution.cpp, PerformanceTrace.cpp, BUILD.md, and USAGE.md.

Results

Check Result Note
Changed code review passed Scope placement and accounting are consistent
Tests not run Author reports test results; not independently verified
Hardware and replay claims not run Not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported GPU tests, Hades II replay, conventions check, and pull request overlap check were not run or independently verified. No files were excluded from the changed-file review.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot added the docs label Nov 16, 2026
@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Validation-layer run of this PR on an NVIDIA GPU under Linux, since CI covers only lavapipe.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, -DBUILD_TESTING=ON; NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684), proprietary driver 620.70.06, Vulkan 1.4.357 (loader 1.4.363), Khronos validation layer 1.4.363.1. Head c035f8be5c merged onto main e4caa07950 (clean merge); main is the same commit built separately. Every test log reports Selected GPU name=NVIDIA GeForce RTX 4090.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
  ctest --test-dir build -R '^agc_(driver_(batch_cap|copied_writer_label_order|draw_recapture_on_change|dword_pattern_fill|gated_dispatch_capture|linear_target_completion_points|pipelined_dispatch|pipelined_sample_dump|write_data_written_ahead)(_.*)?|driver_pm4_rewind_trace|performance_trace|performance_overlay|performance_overlay_statistics)$' -V
main e4caa07950 this PR
Result 32/32 pass 32/32 pass
Insert instance layer "VK_LAYER_KHRONOS_validation" 55 55
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

The pattern covers the nine executables from the Tested section with all their ctest variants, plus agc_performance_trace (the changed test), agc_performance_overlay, agc_performance_overlay_statistics and agc_driver_pm4_rewind_trace.

No new VUID- errors; all 32 focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head c035f8be5c, applied with git apply on main fd4aeed483 together with the other 29 PRs of one batch (#18156, #22013, #22795, #23226, #23385, #24324, #24533, #24582, #24690, #24693, #17553, #19619, #20085, #21081, #19682, #22123, #22529, #22572, #22662, #23479, #23787, #24568, #15330, #21249, #21630, #21713, #22040, #23490, #24394). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
agc_performance_trace (1 test, matched by name to the test file this PR changes) all pass all pass

Whole batch: the full ctest -j 12 (6540 tests) on the RTX 3080 has 5 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #17553 (guest_memory); none is in this PR's area. The 2143 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

talha-devp and others added 2 commits November 22, 2026 07:28
The queue worker drains the draw finisher at the packet gate, before a packet that cannot run
beside it, and at the end of every queue-0 submission. Both waits sit outside Driver.Packet and
Driver.EndSubmission, so worker_busy_pct and the phase totals did not show them. They are now timed
as Driver.FinisherDrain, which the trace summary lists with the other phases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtFtGr39oKL1zCtAwH7vGx
Driver.FinisherDrain was listed with the phases, but worker_busy_pct and the
frame timing's worker_accounted_ms left it out, so a worker blocked on the
draw finisher still looked idle. It now counts with the other worker scopes,
and BUILD.md and USAGE.md list it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtFtGr39oKL1zCtAwH7vGx
@talha-devp
talha-devp force-pushed the feat/finisher-drain-timing branch from c035f8b to 937ac09 Compare November 22, 2026 04:29
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 22, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the reviewed accounting and instrumentation changes are consistent with the stated goal.

What I ran

Reviewed head 937ac0945308b0c5fbfa1de3f815b3d0cb506a2c using repo_read.py to inspect the prepared diff and changed files. No build or tests were run; test results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed Six changed files read
Tests and build not run PR description reports runs
Repository prechecks not run Not executed in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

No runtime, build, or test behavior was independently verified. The PR description's reported GPU, accounting, replay, and convention checks were not rerun. No files were excluded: all six changed files listed in the manifest were read.

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit c136f2d into boykopovar:main Nov 26, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants