perf(agc): skip the owned draw input lookup while none is kept #17889
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17889"
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 chitters2004 on 2026-11-09T20:50:01Z.
What
CopyDrawInputprobed the draw snapshot map for an owned entry (#13793) on every call, including when no owned entry is kept, which is every call on a scene whose draw inputs are all write-tracked.Recorderkeeps an exact count of kept owned entries: raised inKeepOwnedDrawInput, lowered ineraseDrawSnapshot, the only place an entry leaves the map (invalidation, replacement, eviction).CopyDrawInputprobes for an owned entry only while the count is not 0.Counts (rk4 replay, 7,745 draws per pass, kit tree with #13793): 1.816
CopyDrawInputcalls per draw, 0 owned entries kept, so all 14,064 owned lookups per pass are skipped. A local timer build measured the lookup at 0.25 us per call, 0.45 us per draw (two runs, 0.449 and 0.458). No frame-time claim: neither the replay A/B nor the live GTA V pair below resolves it.Head
e95ea79435, base364ceeba2f. It merges cleanly withmain39a172839a(git merge-tree);eraseDrawSnapshotis still the only place an entry leaves the snapshot map there, so the count stays exact.Tested
Windows 11 10.0.26320, NVIDIA GeForce RTX 3080 (driver 621.14),
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -V -R '^(agc_owned_draw_inputs|agc_driver_recorder|agc_driver_frame_replay)'(39 tests), main and the change from the same machine, plain and withAPS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1.VUID-in ctest logVUID-in subprocess logswas not found but was requested by env var VK_INSTANCE_LAYERSTests (
ownedDrawInputTests, Windows; Linux runs the same file with no owned reuse, untested here):Mutants (one build,
OI_MUT=n, each run ofagc_owned_draw_inputs):Rerun on the head
e95ea79435: the unmutated run passes, the five killed mutants above and one more (count each keep twice) fail the test, and "lookup gate always open" passes as expected.rk4 replay A/B (
agc_frame_replay, capture of the standing scene, 7,745 draws per pass,--repeat 5 --no-pace, the 3 pipeline variables, A B B A x5, pass 1 discarded, passes 2-5 averaged per run; A = the replay kit tree (local/replay-kit2, basec3112f0c0f, contains #13793), B = A + this commit):commit_us_per_drawmeanB minus A: -0.91 us/draw, 95% CI +-3.50 (the CI is wider than any expected saving; medians 34.80 and 34.87, so no difference is resolved).
pixels_identical1.000000 andmax_channel_diff0 in all 20 runs, 5 passes each, 0 VUID. A first run of the same A/B on the earlier revision gave +0.53 +-3.76. No claim is made on frame time.Live GTA V pair (PPSA04263, save
play1-first-autosave, 3840x2160, standing window anchored onstood_still,APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1,APS5_TRACE_SECONDS=235:30, Ryzen 7 5800X, RTX 3080, driver 621.14): A = base364ceeba2f, B =e95ea79435, bothdirty: false, one discarded warm-up per side, then A B B A.B minus A per pair: +3.54 ms and -5.00 ms (mean -0.73). The runs drift about 3 ms per boot in order on both sides and the signs differ, so no frame-time change is resolved; the expected saving (about 0.45 us per draw, about 0.7 ms per frame at about 1,500 draws) is below that spread. CPU bound on both sides. The claim stays the count above. Traces,
trace_digest.pysummaries, everyaps5-summary.jsonlline,performance_compare.pyoutput for both pairs, logs and scripts: https://github.com/chitters2004/AnyPS5/releases/tag/pr-owned-input-t8aps5-summary.jsonllines of the traced window, a1 (base) and b1 (change):Head
44644e0f8fise95ea79435merged withmaine7c3bfd130(no conflicts); the results here are frome95ea79435and are not rerun on the merge.Gate logs, the A/B runs, the mutant runs and the scripts: https://github.com/chitters2004/AnyPS5/releases/tag/pr-owned-input (
pr-owned-input-evidence.tar.gz).Not tested: Linux, AMD.
Checklist
main; no other open PR implements the same functionsNotImplemented_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)ctestgate and the rk4 replay); AGC change, no other GPU🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T21:30:13Z.
Review: APPROVED
Read at
e95ea79435. The count stays exact, as far as I can see:eraseDrawSnapshot(Recorder.cpp:3270) is the onlydrawSnapshots.erasein the file at this head, and there is noclearor reassignment of the map. So the decrement covers invalidation, replacement and eviction.eraseDrawSnapshot(decrement) beforeKeepOwnedDrawInput's increment. The new "kept twice" check pins that.ReusableOwnedDrawInputasserts it on entry), andCopyDrawInputreads the count right before calling it. So the plainstd::size_tis read and written under the same lock and needs no atomic.ArmOwnedDrawInput.One note on the validation table: in AnyPS5's test programs the "was not found but was requested" line doesn't appear even when the layer is missing, because nothing registers a debug messenger. So that column can't show the layer ran. With
VK_LOADER_DEBUG=layerthe loader printsInsert instance layer "VK_LAYER_KHRONOS_validation"when it does (measurement in #17896).AI-assisted: yes (Claude Code)