Skip to content

fix(agc): end a pipelined submission's EndSubmission time before its REWIND tail runs - #8108

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/rewind-tail-end-timer
Oct 21, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/rewind-tail-end-timer

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What

On the pipelined path, Driver::execute keeps its Driver.EndSubmission timer open while it runs a released REWIND tail (PacketExecution.cpp, the executeRewindTail call inside pipelined && orderedCompletion). The tail's submission ends by opening the next Driver.EndSubmission inside the first, so a chain of n tails is counted up to n times in that scope's total. worker_busy_pct and top_phases_ms_per_frame add those totals, so they overstate the queue worker's time; #8092's GTA V capture shows queue worker 0x0 at 3,740% busy. The non-pipelined path already finishes the timer before it runs the tail. The pipelined branch now does the same.

Tested

Ubuntu 24.04, GCC 13.3, Release, NVIDIA RTX 4070 Ti (595.99.02).

  • New agc_driver_pm4_rewind_trace (agc_driver_pm4_tests rewind-trace with APS5_TRACE_FRAMES=0:1 and APS5_PIPELINED_DRAWS=8). One trace window covers a submission of 12 REWIND tails that are released before it runs; each tail waits about 3 ms on a word the test sets. The test then reads queue worker 0x0's share in the window's worker_busy_pct and requires at most 150%.
    • Without the fix (b87501d550 drops the new line): 703.9%, 676.5% and 702.8%, so it fails 3 of 3.
    • With it: 90.7%, 94.0% and 94.1%, so it passes 3 of 3.
  • ctest -R '^agc_driver_pm4': 16 of 16 pass.
  • @simonbbby audited it independently on a Ryzen 9 9950X (Ubuntu 24.04, GCC 13.3, Release), nine fresh processes each. With only the added line reverted, the fixture fails 9 of 9 at 714.1–719.1%, with Driver.EndSubmission totalling 236.8–239.5 ms in a 38 ms window: 12 slices nested 12 deep, whose union is 36.9 ms. With the PR it passes 9 of 9 at 94.9–96.0%, and Driver.EndSubmission totals 0.009–0.018 ms. ^agc_driver_pm4 passes 16 of 16.
  • Khronos validation layer (LunarG SDK 1.4.363): VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_driver_pm4' -V on main a700809 (15 tests) and on this PR (16 tests). All pass, neither log reports the layer missing, and neither has a VUID- error.
  • tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py finds no overlap among the pull requests it could compare. It lists PRs that conflict with main and touch PacketExecution.cpp (fix(agc): raise no end-of-pipe event from flips and carry the release's interrupt context #7978, feat(agc): look up table images at run time through a device image table on the GPU heap (APS5_GPU_PATH) #7642 and others), Pm4.cpp or the driver's CMakeLists.txt.

Not run: Windows and macOS. The test is registered on every platform, with the PATH setting the other Windows PM4 tests use.

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: trace: Driver.EndSubmission nests through the rewind tail, so worker_busy_pct counts time many times #8092
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

…REWIND tail runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5115 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6146 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6185 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 6187 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6209 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6292 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6615 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6682 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6683 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6718 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6820 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6868 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7446 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7505 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7514 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 7644 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7677 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7800 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8134 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8206 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 8295 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8484 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8489 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8564 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8592 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8658 core/libs/prx/libSceAgcDriver/CMakeLists.txt

@simonbbby

Copy link
Copy Markdown
Contributor

Independent CPU trace audit of exact head 871b2076d571387474c251192356ca0df2a89027, using the new rewind-trace fixture. Ubuntu 24.04, Ryzen 9 9950X, GCC 13.3, Release.

I reverted only the added endTiming.Finish() to reproduce the main-parent production behavior (a700809679b1fef3d49cae4c00383ee85b9930be), kept the new test, rebuilt, then restored the exact source and rebuilt again. Nine fresh processes per condition:

One-line reversion Restored PR
Fixture result 9/9 fail at busy-share assertion 9/9 pass
Queue worker 0x0 busy 714.1–719.1% 94.9–96.0%
Driver.EndSubmission summary total per window 236.8–239.5 ms 0.009–0.018 ms
Trace window 38.2–38.6 ms 38.2–38.8 ms

The saved raw X events explain the difference directly. Every reverted run has 12 Driver.EndSubmission slices on the same queue-worker trace thread, nested 12 deep. For one run they sum to 239.507 ms but their union is only 36.928 ms. Adding the other serialized top-level worker-busy scopes gives 276.365 ms of slices over that same 36.928 ms union.

After restoration, the serialized worker-busy slices sum to their union in all nine runs (about 36.6–36.8 ms), with no overlap among them in this fixture. No long Driver.EndSubmission slice remains. The summary still accounts for its short 9–18 µs total: the trace intentionally folds individual slices below 20 µs, so absence from the raw events does not mean the timer disappeared. All 18 summaries report trace_dropped: false.

This supports the full chain: the unfinished inclusive parent timer survives executeRewindTail's recursive execute(tail), and TraceThread::account adds every inclusive duration to the summary. The windows remain about 38 ms and the events use one worker thread, so neither a shrinking denominator nor multiple workers explains the overcount. The fixture reaches its done assertion before the failing busy-share check in the reverted runs and still checks it after restoration, so the correction is not explained by tails ceasing to run.

The restored ^agc_driver_pm4 CTest scope passes 16/16. The checkout is clean at the stated head, and no experimental edits remain.

Scope: this fixture does not initialize a Vulkan device (the summary GPU/driver fields are empty). The runs used three ICD environments, but they are repetitions of the same CPU test, not three-GPU validation. No title, FPS, GPU timing, validation-layer or Windows/macOS result is claimed, and the no-overlap observation is limited to this fixture's serialized busy scopes. Raw traces, summaries and the interval-audit script are retained.

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @simonbbby. Nine runs each way with only the line reverted, plus the raw slices, is stronger evidence than my three, and the nesting depth of 12 for 12 tails shows the mechanism directly. Added to the description.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added fix error Closes an issue (Fixes #N) build agc libSceAgc* labels Oct 19, 2026
@oneandonlydean
oneandonlydean merged commit a4fc462 into boykopovar:main Oct 21, 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* build fix error Closes an issue (Fixes #N)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trace: Driver.EndSubmission nests through the rewind tail, so worker_busy_pct counts time many times

3 participants