perf(agc): learn a draw's relocation when its entry is inserted #18757
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18757"
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 virgit-1 on 2026-11-12T05:15:28Z.
What
With the draw finisher (
APS5_DRAW_PIPELINE, #6946), a title whose draws move their user-data pointers every frame finishes almost every draw on the worker anyway, and runs slower than without the finisher.The relocation of #4943 learns which user words of a shader set are relocatable from the entry a missed draw inserts. A miss left one pending relocation (
drawRelocationPending), and the next draw's lookup learned it from the inserted entry. With the finisher, the insert happens on the finisher thread, so the worker drained the finisher before every lookup that followed such a miss (Draw.cpp,if (DrawFinisher::Busy() && drawRelocationPending.key != 0) DrawFinisher::Get().Drain();). In Expeditions: A MudRunner Game (PPSA17423), on an earlier local base, 316,470 of 350,000 draws drained the finisher there, and the queue worker spent 61% of its samples inDrawFinisher::Drain.drawRelocationsPending, bounded at 1024 entries and cleared past that).insertDrawEntrylearns the pending relocation of the key it inserts, under the draw cache mutex, on whichever thread inserts.admitDrawKeyreads the pending relocation of its own key instead of the single slot, which another miss could have overwritten in the meantime.Without the finisher nothing changes in what is learned. The learning only moves from the next draw's lookup to the insert itself, which happens earlier.
agc_driver_draw_cache_relocation_finisherteaches a relocation with four draws, then submits one packet: a draw whose data differs, so it misses and leaves a pending relocation, followed by two draws whose data moved. A capture-check hook holds the finisher on the first draw until the worker has looked up the next one, for at most 2 s. Onmain, the worker drains the finisher first and the test fails with "the worker waited for the draw finisher to finish a missed draw before it looked up the next draw of the packet". With this change, both moved draws are looked up behind the held draw and hit the cache through the relocation.Related
learnPendingRelocation) is unchanged; only its trigger moves.Draw.cpp, on different lines (finish job, recapture).admitDrawKey. It is not proposed for merge; if it is split into PRs, that part and this PR implement the same thing.tools/pr_overlap.pyreports one shared line,Draw.cppL41, where both add a declaration at the top of the anonymous namespace. No shared function.tools/pr_overlap.pycould not compare #5609, #5925, #6188, #6804, #7508, #7642, #9387, #10193, #10359, #11435, #11436, #13928, #13929, #15136 because they conflict withmain. Their diffs were read by hand: #5609 and #6188 touchdrawRelocationPendingas it is on their old base (the code #4943 merged since); none of the others touches the pending relocation or the drain.Tested
Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs), Release, NVIDIA GeForce RTX 2080 SUPER, driver 621.14, Intel i7-9700K.
Tests, on
mainc85dcfd005and on this branch, same machine and GPU, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V -R agc_driver_draw_cache_relocation:was not found but was requestedVUID-main_finisher)The new test fails without the source change, with the message quoted above.
tools/check_conventions.pyreports no finding on the branch.Performance: PPSA17423 01.026.000, title screen, 3840x2160,
APS5_DRAW_PIPELINE=1,ANYPS5_PRESENT_MODE=mailbox,APS5_TRACE_SECONDS=150:30. Each set was run in the ordermain, PR, PR,main, with one discarded 80 s launch before each change of build.Set 1, the head of this PR (707a76b12028) against its base (
mainc85dcfd005):main, first runmain, second runtools/performance_compare.pyon the first pair:Driver.Packet.draw289.4 to 125.0 ms per frame;Driver.Draw.prepareis 227.1 ms per frame onmainand is not among the reported phases with the change.Summary lines of set 1:
`tools/trace_digest.py`: `main`
c85dcfd005, first runseconds 150:30 from present 2219: 91 presents, frame p50 330.3 / p90 335.4 / p99 342.1 / max 342.1 ms, GPU busy 35.2 ms per present
NVIDIA GeForce RTX 2080 SUPER, NVIDIA 621.14, Windows 10.0.26300, 3840x2160, commit
c85dcfd005, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 302.5, Driver.Packet.draw 288.0, Driver.Draw 285.1, Driver.Draw.prepare 225.7, Graphics.Draw 211.4, Driver.DrawFinish 159.7, Graphics.Draw.draw_and_resource_release 129.7, Driver.DrawFinish.shader_compile_and_link 103.4, batch 35.1, Shader.DrawStage 18.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
`tools/trace_digest.py`: this PR 707a76b12028, first run
seconds 150:30 from present 2480: 151 presents, frame p50 198.3 / p90 203.3 / p99 221.1 / max 231.4 ms, GPU busy 35.2 ms per present
NVIDIA GeForce RTX 2080 SUPER, NVIDIA 621.14, Windows 10.0.26300, 3840x2160, commit 707a76b12028, dropped: no
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 143.8, Graphics.Draw 141.0, Driver.DrawFinish 138.0, Graphics.Draw.draw_and_resource_release 112.1, Driver.Packet.draw 97.8, Driver.Draw 95.7, Driver.Draw.draw_handed_off 74.2, Driver.DrawFinish.shader_compile_and_link 64.4, Driver.DrawFinish.draw_enqueued 44.8, Driver.Packet.execute 37.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
`tools/trace_digest.py`: this PR 707a76b12028, second run
seconds 150:30 from present 2392: 143 presents, frame p50 210.4 / p90 216.9 / p99 225.1 / max 226.7 ms, GPU busy 58.7 ms per present
NVIDIA GeForce RTX 2080 SUPER, NVIDIA 621.14, Windows 10.0.26300, 3840x2160, commit 707a76b12028, dropped: no
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 155.8, Graphics.Draw 152.2, Driver.DrawFinish 149.6, Graphics.Draw.draw_and_resource_release 123.0, Driver.Packet.draw 106.4, Driver.Draw 104.3, Driver.Draw.draw_handed_off 82.6, Driver.DrawFinish.shader_compile_and_link 65.1, batch 58.6, Driver.DrawFinish.draw_enqueued 57.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
`tools/trace_digest.py`: `main`
c85dcfd005, second runseconds 150:30 from present 2279: 92 presents, frame p50 328.6 / p90 333.6 / p99 376.2 / max 376.2 ms, GPU busy 35.2 ms per present
NVIDIA GeForce RTX 2080 SUPER, NVIDIA 621.14, Windows 10.0.26300, 3840x2160, commit
c85dcfd005, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 300.4, Driver.Packet.draw 286.0, Driver.Draw 283.0, Driver.Draw.prepare 224.2, Graphics.Draw 210.8, Driver.DrawFinish 158.8, Graphics.Draw.draw_and_resource_release 129.0, Driver.DrawFinish.shader_compile_and_link 101.4, batch 35.2, Shader.DrawStage 17.8
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Set 2, taken a day earlier on
main7a245b32c7. Commit 7d9a9d042264 is this same commit on that base:git range-diff 7a245b32c7b0..7d9a9d042264 c85dcfd0056e..707a76b12028reports the patch as unchanged, apart from the commit message trailer.main, first runmain, second runSummary lines of set 2:
The digests of set 2 are in the reply to the review below.
After this change the queue worker and the committer limit this title, not the finisher drain.
Checklist
main; no other open PR implements the same functions (see #18515 under Related, a draft not proposed for merge)NotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T05:25:20Z.
Review: DISMISSED
Reviewed — changes requested
The source change appears internally consistent, but this
perfpull request is missing required, inspectable trace evidence for its performance claim.What I ran
Reviewed head
707a76b12028a7d9f697568ea759e64cc2696a8cagainst currentmaintip145e689adab572c44a99369516565d28e85f6c12; the no-build precheck reported the head and base unchanged and its mergeability check passed. Environment: Linux 6.1, Python 3.11.2, GCC C++ 12.2.0. I did not compile or run Vulkan tests.I also read the complete diff and relevant draw-cache, relocation, capture, test-registration, and performance-report context. The PR description's test and performance measurements are author-reported; I did not reproduce them.
Results
trace_digest.pyoutput are not available on the PR.Complete no-build precheck table and relevant raw output
git diff --check 145e689adab572c44a99369516565d28e85f6c12...707a76b12028a7d9f697568ea759e64cc2696a8c/usr/bin/python3 tools/check_conventions.py --base 145e689adab572c44a99369516565d28e85f6c12 --head 707a76b12028a7d9f697568ea759e64cc2696a8c --title perf(agc): learn a draw's relocation when its entry is inserted --body /tmp/pr18757-precheck/pr-body.md/usr/bin/python3 /marc/AnyPS5/tools/pr_abi_audit.py --base 145e689adab572c44a99369516565d28e85f6c12 --head 707a76b12028a7d9f697568ea759e64cc2696a8c --json/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 18757 --repo boykopovar/AnyPS5 --output-dir /tmp/pr18757-precheck/stack/usr/bin/python3 /marc/AnyPS5/tools/pr_test_quality.py --root /tmp/pr18757-precheck/head-707a76b12028-696370ac --json core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawRelocate.cpp core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_draw_cache_relocation_tests.cmake core/libs/prx/libSceAgcDriver/tests/execution/DrawCacheRelocation.cppUnedited output from the convention check:
Unedited output from the stack check:
Unedited output from the test-quality heuristic:
The test-quality warning was manually checked against the changed CMake fragment, which registers this test.
Negative control
Not run: the new Vulkan test requires an exact-head build and Vulkan runtime. The PR description reports that the test fails on
main; I did not reproduce that result.Findings
Blocking
The PR body includes summary JSON lines and says four trace files are attached in a comment, but the PR has no issue comments or trace attachments. It also does not include the required
tools/trace_digest.pyoutput for the captures. The measured change line names commit7d9a9d042264, while the reviewed head is707a76b12028; the description says it was rebased, but the available evidence does not let a reviewer inspect the captures or verify that the measured tree corresponds to this change. Please attach the baseline and change traces, include each digest output, and identify the measured change tree relative to this head (or provide matched captures for the current head).Non-blocking
No additional blocking source issue was identified in the reviewed diff. This does not verify the reported performance improvement or GPU behavior.
Sources
main/PR summaries and attached traces.tools/trace_digest.pysummaries for speed claims.Not verified
To get this to a good state
Attach the four captures and their
trace_digest.pyoutputs, and establish that the measured change matches the reviewed change. I will refresh the head and base, then reassess the performance evidence and any newly completed hosted checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T08:45:20Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Head
dcf7e04c7eca0c9fd3bb8f5b76f49e0f61c1a9af, basemain. Read the prepared diff for all six changed files, then checked the head with the repository reader:Nothing was built or run here. The author's Windows test results are in the description and are not reproduced.
Results
drawRelocationPendinghas no uses at headagc_driver_draw_cache_relocationtests_finishertest fails onmainFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/execution/DrawCacheRelocation.cpp:135adds#include <thread>above#include <string>. The list is alphabetical, so<thread>belongs after<string>.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp:474removes the drain. A second draw with the same key that looks up before the first insert commits now misses and captures again, where the worker used to drain and hit. The description's numbers are for moved-pointer draws; this case is not measured.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp:475keeps a pending entry per key until that key is inserted, a later miss on the key replaces it, or the map reaches 1024 entries and is cleared. The old single slot was consumed on the next lookup. I found no path that learns a stale entry, but I did not check every caller of the miss path.Sources
Commit
dcf7e04c7eca0c9fd3bb8f5b76f49e0f61c1a9af:Not verified
_finishertest and its negative control. Not run here.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T03:51:53Z.
Review: APPROVED
Reviewed — looks good
The change moves relocation learning to the matching cache insertion and removes a finisher drain; the inspected implementation and added regression test support the stated behavior.
What I ran
Reviewed head
88ad6f983d3e05c6de7bb4d000e21ee0f61e37cfagainstmain. No tests or builds were run; the test and performance results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read all six files listed in
review/manifest.json; none were excluded. I did not run the regression tests, build, convention checks, or performance measurements, and did not independently verify the author-reported results or console behavior.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:17:22Z.
Review: COMMENTED
The trial merge onto
a1b75b0947was clean. I checked that admission and entry insertion read the same per-key pending relocation map under the draw-cache mutex. The held-finisher case gives a distinct control for the removed worker drain. Keep it with the recipe-verify draw-pipeline case so the test still catches a stall as well as a bad relocated cache hit. Paired validation is pending.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.