perf(agc): take captureValidation's records in one pass over the lookup log #8608
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8608"
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 SleglJan on 2026-10-20T18:15:40Z.
What
captureValidationgives each texture of aShaderResourcesbuild the index of its last record in the thread's lookup log. It foundthat index by scanning the log backwards once per texture. A build keeps all of its own records in the log, so for a build over a large
image table each texture read on average about half of a log at least as long as the table: about 1.1 million record reads per capture
for a 1,500-texture table.
LastRecordIndices(ShaderResources.hpp/.cpp):tests/LastRecordIndices.cpp(run byagc_driver_graphics) comparesLastRecordIndiceswith the backward scan over:Tested
agc_driver_graphics(mock Vulkan) on lavapipe (Mesa 26.2.4, LLVM 23.1.1), in an Arch Linux container on a second machine, on6bef96df7c:log reads. It fails with "last record indices, repeated records and objects: 16 log entries read for a log of 4".
1,024 records.
tests the 1,500-texture cases above and random logs of 1,500 and 2,048 records.
-j 16:agc_driver_lookup_log_fits_buildfailed after 57.6 s; its output was not kept. That fits #8601 (open): the test fails when its template audit falls due on a busy machine.captureValidation. Run alone it passes twice on this commit and twice on main6bef96df7c, about 1 s each.7602dde042): 1,692/1,692.agc_driver_graphicsandagc_driver_lookup_log_fits_buildwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -Von the RTX 3080, for main6bef96df7cand this commit (Vulkan-ValidationLayers 1.4.363):VUID-.-R '^agc', before the rebase: base7602dde042and the branch both fail the same 18 of 813, whichfail on lavapipe without this change.
68323bae7+ #5799 #6868 #5372 #6918 #7643 #6679 + this change + a local timing line aroundcaptureValidation. The titlealso needs a local patch for #6172.
APS5_PROFILE_DRAW=1, and a 60 sperf recordof the title (cycles:u, 499 Hz) inside eacharm's window.
captureValidationtook 0.612 µs in A and 0.089 µs in B (−85.5%). Per present, 88.2 ms less (−86%). At A's time per texture, B's 158,730 textures would take 97.1 ms, 83.1 ms more than B's 14.05.0.56 FPS.
commitbecause both arms ran onebinary built from the local tree above; A sets the local switch
APS5_LOCAL_OLD_CAPTURE_SCAN.Matched captures,
mainside against this change, as the Performance report form asks. The title's two feedback-wait limits are widened in its executable as described in #6172 (local only), and the input is scripted.main68323bae7with #5799, #6868, #5372, #6918, #7643 and #6679, without this change and without the timing line.APS5_TRACE_FRAMES=1460:30, with noAPS5_PROFILE_*.APS5_TRACE_EVENTS=2097152only sizes the per-thread trace buffer. Queue 0's worker records 238,000–249,000 events in these windows, close to the default of 262,144, so the larger buffer keeps a slower stretch from dropping events. No run dropped events.tools/trace_digest.pyoutput for each run are in this release.Driver.Packet.memory_waitfor 21.5–22.6 s. It inflates A1's p99 and its draw scope.captureValidation(no scope contains it alone), ms per present over all threads, from the traces' scope totals:Resources.Complete(builds)Vulkan.Dispatch(contains most of the builds)Graphics.Draw/draw_and_resource_release(contains the rest of the builds)These scopes nest: about 90% of
Vulkan.DispatchisResources.Complete(89–92% in the two runs checked), and the rest ofResources.Completesits inside the draw scope. So theVulkan.Dispatchdrop mostly counts the same time again. InResources.Completethe A and B ranges don't overlap. It contains other work as well, so the timing line above stays the direct measure of this change.trace_digest.py's first line per run:Overlap
captureValidationor thelookup log:
CMakeLists.txt,tests/Graphics.cppandGraphicsTests.hpp;captureValidation's texture loop, which this change rewrites, so the second to merge needs a rebase. It does not change the scan.Checklist
main(6bef96df7c; merges cleanly with892a4f1328andeae6e0162f); no other open PR implements the same functions.mdfiles or images added to the repositoryLinux container, for the mock-Vulkan and
^agcruns🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T18:15:57Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T18:19:18Z.
The change looks right to me. I built
LastRecordIndiceswith your test outside the tree, and it passes. Two mutants fail it: one drops the "first hit wins" guard, and the other sets only one of several duplicate objects. So the differential test pins the last-record rule. It also composes cleanly with #8601.What's left is the
perf numbers missinglabel: aperfPR needs the two summary lines and thetools/trace_digest.pyoutput for a matched pair (main vs this head, same scene, warm caches), preferably with a few runs per side so the spread is visible. A scene that builds large image tables, wherecaptureValidationshows up in the trace, would show the effect best.Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-20T18:43:56Z.
@oneandonlydean thanks. The matched runs are queued on the desktop tonight, so the summary lines, the
trace_digest.pyoutput and the traces should be here in the morning (CEST).The runs: 3 per side, alternating, on 007 First Light's gameplay (PPSA11386), with warm caches from one seed, the same window, and the Performance report form's switches.
Some caveats up front:
mainside.68323bae7lacks #6679, which this title needs. The "main" side adds #5799 and #6679 (merged since) and the open #6868, #5372, #6918 and #7643. The other side adds only this commit to that.captureValidationalone. It runs insideResources.Complete(builds), the draw's resource stage andVulkan.Dispatch(revalidations), so the digest shows it mixed with their other work. I'll giveResources.Completeper side, but it varied by much more than 88 ms between the description's arms.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-21T00:27:50Z.
@oneandonlydean the matched captures are in the description now, and the traces are in the release. There are 3 runs per side, alternating, with the six summary lines and each run's
trace_digest.pyoutput. The setup is the same local stack, patched title (#6172), scripted input and log file as in the description.Resources.Complete, the build scope that containscaptureValidation, drops from 567 to 499 ms per present (−12%), with no overlap between the sides.Vulkan.Dispatchdrops too, but it mostly nests the same build time.AI-assisted: yes (Claude Code)