perf(agc): take a draw snapshot from a kept snapshot that contains it #8756
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8756"
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 milescoviello on 2026-10-20T23:48:02Z.
What
PrepareDrawBindingscopies a guest storage read larger than the upload limit into a draw snapshot buffer.ReusableDrawSnapshotreuses a kept snapshot only when its address and size both match exactly.Some titles bind a buffer from a moving base to a fixed end, for example a ring of per-draw data read from each draw's base to the end of the ring. Such a title asks for a different range on every draw. CoD BO2 (PPSA34502) does this on its war-room menu:
0x403b00a6f0+2085412,0x403b00a7d0+2085188and0x403b00ea50+2068164all end at0x403b207914. Every one of those draws misses:A temporary counter in that path, on #5499's rebased branch (which BO2 needs to get this far), showed about 1,060 new snapshot buffers a second, 2.7 GiB/s, over about 1,000 ranges in 3 s. Almost none were refresh failures; the ranges were simply not in the cache. In a profile of the draw thread,
PrepareDrawBindingswas 89 % of the thread's samples: freeing buffers (BufferPool::destroy) 35 %, allocating them (Buffer::Buffer) 25 %, and the copy 29 %.Now, on an exact miss, a storage lookup that passes an offset looks back at up to 16 kept storage snapshots that start at or before the range. It takes the first one that:
minStorageBufferOffsetAlignment(at least 4) before it;UnchangedSinceon the requested range only).The draw binds that buffer at the offset instead of copying. An exact match still comes first. The vertex and index lookups in
Draw.cpppass no offset, so they still take exact matches only.The snapshot's bytes in that range equal the guest bytes at the time it was taken.
UnchangedSinceover the requested range shows that nothing tracked has written them since. That is the same proof an exact hit uses, applied to a sub-range.Tested
main524398151f, with no conflicts, as head9b93d38464. The 12 snapshot and kept-bytes tests listed under Suites pass 3 of 3 on Linux (RTX 4070 Ti, 615.71.09, Ubuntu 26.04.1), and conventions are clean. The alternating BO2 runs below usedmainab347d144d+2bdd2d3b9emerged, the same change on a slightly oldermain.Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02, on
maineea640a5bf.Test.
containingSnapshotTests(in--draw-snapshot-cap-only, ctestagc_draw_snapshot_cap, and in the full recorder run) keeps a snapshot over two 64 KiB blocks and checks that:With
ReusableDrawSnapshotreturning nothing instead of callingcontainingDrawSnapshot, it fails 3 of 3 at "an unchanged range inside a kept snapshot was not taken from it at its offset". With the change it passes 3 of 3.Suites.
ctest -R '^agc_': 843 of 844 pass. The failure isagc_driver_lookup_log_fits_build, which fails under load onmaintoo (#8601).mainand this branch withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), the 12 snapshot and kept-bytes tests (agc_draw_snapshot_cap,agc_draw_snapshot_epoch,agc_draw_inputs_copied,agc_draw_inputs_in_place,agc_draw_inputs_in_place_driver,agc_driver_large_tracked_snapshot,agc_pending_write_snapshot,agc_shader_table_snapshot_reuse,agc_storage_kept_unit_settle,agc_recorder_kept_bytes,agc_copy_input_kept_bytes,agc_depth_copy_kept_bytes) pass 12 of 12 on both, with no VUID on either.CoD BO2 (PPSA34502), war-room menu, alternating runs on current code (2026-10-21).
mainab347d144dagainstmain+ this head2bdd2d3b9e(merged as 5a49111422), interleaved main, PR, main, PR, main, PR in one session. RTX 4070 Ti, NVIDIA 615.71.09, Ubuntu 26.04.1, 1920x1080, release libraries, warm cache. Both builds carry the same localsceVoiceGetPortAttrpatch (the attribute answered 0, as before #9137), so the title passes #9601. Presents per 10 s over the last eight intervals in the menu:The two sides don't overlap in any interval. The queue-0 worker is about 98% busy on
mainand about 69% with the PR, and GPU busy per present goes from 107 to 79 ms. Summaries (no traces in these runs).The earlier BO2 and SMB3D results follow.
CoD BO2 (PPSA34502), war-room menu.
mainalone stops at 15 s on theDB_RENDER_CONTROLdepth copy (0x84), so the base here is #5499 rebased onmaineea640a5bf(milescoviello:rebase/5499-db-depth-copy, 95ca794b31). The other build adds this PR (merge 76c494418f).APS5_TRACE_SUMMARY_EVERY=10).APS5_TRACE_SECONDS=175:30), inside the menu.Per 10 s interval in the menu, both runs:
Graphics.Drawper frameTrace windows, from
tools/trace_digest.py:Both traces dropped some events (the digests say
dropped: yes). Files:The two window summary lines:
Before the menu, both builds hold 60 FPS, with p99 frame times of 18 to 20 ms. The window title's frame counter agrees with the summaries: 49 frames in 75 s without this PR, 254 in about 90 s with it (first pair of runs).
The menu is still slow with this PR. In its trace,
Shader.ResolveAbitakes about 60 ms per frame summed over the title's five threads, and the draw committer is busy for 39 % of each frame. I haven't traced where the rest of the frame goes.Super Meat Boy 3D (PPSA31162), level 1-1, as a second title. The builds are
maineea640a5bfand this PR on it, with release libs and one shared shader cache. Runs are scripted from the game's own map-load log lines, and each measures 60 s after a 30 s settle. Six runs alternated PR,main, three times, plus two earlier runs of each:mainmainmainmainThe per-draw figures are from the
[draw] pipelinedlines; the CPU column istop's total for the other processes just before each run.Both builds land in the same three groups, about 32, 85 and 200 to 280 us per draw. The fastest run was a PR run and the slowest a
mainrun. So this level's cost changes from run to run with something other than this PR, and these runs show no slowdown from it. I haven't found what picks the slow group.Windows 11 Enterprise 26300, NVIDIA GeForce GT 1030 (driver 582.78), WinLibs GCC 15.2.0 r7 (UCRT), Release: the 8 draw snapshot, draw descriptor and draw cache tests pass 3 of 3 on
mainand 3 of 3 with this change.AMD, Windows: @savvaniss ran the 12 snapshot and kept-bytes tests on an RX 9070 XT (driver 32.0.31041.1004, Windows 11, WinLibs GCC 15.2.0) under the 1.4.363 layer, 3 times each, with head
9b93d38464merged intomain0cece6ebbcagainst thatmain. They pass 12 of 12 on both with noVUID-line, and the containing-snapshot cases ran. WithReusableDrawSnapshotnot callingcontainingDrawSnapshot,agc_draw_snapshot_capfails 3 of 3 (an unchanged range inside a kept snapshot was not taken from it at its offset).Not tested: Intel (a 64-byte storage offset alignment would reject some of these offsets), titles other than these two.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T23:48:17Z.
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 MarcZX10 on 2026-10-20T23:50:30Z.
The containing-range lookup and its tests look internally consistent: exact hits remain first, only storage descriptors receive offsets, alignment and allocation-generation checks are preserved, and write tracking is checked on the requested subrange. Before approval, please add the required performance artifacts: attach both trace files, paste the matching
aps5-summary.jsonlsummary lines, and includetools/trace_digest.pyoutput. The current before/after table does not include those reviewable artifacts, and the automated performance gate is requesting them.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T00:00:21Z.
@MarcZX10 thanks for the review. The description now has the captures:
aps5-summary.jsonlwindow lines;tools/trace_digest.pyoutput for each;The base is #5499 rebased on
maineea640a5bf, sincemainalone stops at 15 s before the menu. In the window, presents go from 21 to 88 in 30 s, and the frame p50 from 1454.4 to 334.5 ms. The draw committer goes from 1290.8 ms busy per frame (86 %) to 134.3 ms (39 %). A second pair of runs shows the same per-interval figures.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T00:03:29Z.
Review: APPROVED
Reviewed the changed storage snapshot path and containing-range tests. I downloaded both trace assets from the linked release and reran tools/trace_digest.py with the supplied summary files; the window headlines and embedded JSON summaries match the values in the PR description (including the reported dropped-event flags). The trace loss limits interpretation of per-event attribution, but the 10-second summaries and the disclosed scope support the performance comparison. The exact lookup remains first, containment is storage-only and alignment-checked, and the requested subrange is checked against write tracking.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T00:31:16Z.
@MarcZX10 I've moved this back to draft: it slows a second title down. Super Meat Boy 3D (PPSA31162), level 1-1, same machine. The runs went
maineea640a5bf, then this PR, thenmainagain, with one shared shader cache, scripted from the game's own map-load log lines, measuring 60 s after a 30 s settle:main, cold cachemain, warmThe per-draw figures are from the
[draw] pipelinedline. I'm profiling both builds in that level now and will post the cause and a fix. It shouldn't be merged before then.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T00:40:29Z.
@MarcZX10 a correction to my last comment: one pair of runs wasn't enough. I ran the same level twice more, the PR and then
main, with a 15 s profile before each measured minute:main, warm (earlier)mainSo
mainitself ranges from 76 to 275 us per draw on this level, which is wider than the gap I reported. Other services on this host were using about six cores while these ran, and that load changes over time. I can't yet say whether this PR slows this title. I'll run the two builds alternately, several times each, and post the spread. It stays in draft until then.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T00:42:10Z.
Review: DISMISSED
Withdrew my earlier approval because of the new cross-title performance data. I agree this should remain draft until the suspected regression is explained or the repeated comparison establishes the effect. The wider
mainvariance in the latest runs means the current data is inconclusive; please update the traces and summary once the alternating runs are complete.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T01:18:00Z.
@MarcZX10 the alternating runs are done, and they don't show a slowdown from this PR in Super Meat Boy 3D. Same level, same machine, PR and
mainalternated three times, plus the earlier runs:mainBoth builds land in the same three groups, about 32, 85 and 200 to 280 us per draw. The fastest run of the eight was a PR run, and the slowest a
mainrun. My first report compared a PR run in the slow group with amainrun in the middle one. The full table, with presents and the other processes' CPU before each run, is now in the description.I haven't found what puts a run in one group or another. It isn't simply the host's other load: that was 507 to 817 % across the runs and doesn't follow the groups.
I've marked the PR ready again. Could you re-review when convenient? The BO2 captures and traces are unchanged.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T07:17:54Z.
@milescoviello thanks, the change reads correct to us on
2bdd2d3b9e. @MarcZX10, your changes request from 00:42 asked for the suspected regression to be explained or ruled out by repeated runs, and the author has posted alternating runs since. Could you take another look and say whether that settles it for you? On our side, a no-harm gate follows once that's resolved.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:58:58Z.
@MarcZX10 one more data point on the Super Meat Boy 3D question, from #8840 / #9026 since then. On a single build, level 1-1 lands in one of three speed modes, chosen per run by where the title places a depth plane:
Plain
mainhas come up in all three. In #8840's twelve runs it took both the slow and the fast mode, and in today's seven base runs it took the slow mode twice and the middle one five times. So one slow run on either side of an A/B says nothing about this PR, which is what the alternating runs above found too. #9026 removes the slowest mode. Could you take another look when you have a moment?AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-22T04:53:37Z.
@MarcZX10 the alternating runs are done, on current code: Call of Duty: Black Ops II's war-room menu, interleaved main, PR, main, PR, main, PR, one session.
Setup: RTX 4070 Ti, NVIDIA 615.71.09, Ubuntu 26.04.1, 1920x1080, release libraries, warm cache.
mainisab347d144d. The PR side ismain+ this head2bdd2d3b9e, merged as 5a49111422.Since #9137, BO2 stops at
sceVoiceGetPortAttr(#9601). So both builds carry the same local patch that answers that attribute with 0, as before. Nothing else differs between them.Each run: 120 s after the window, Cross, Options, then 90 s in the menu with 10 s trace summaries. Below are the presents in the last eight 10 s intervals (the menu):
mainstays at 9 to 11 presents per 10 s, and the PR at 36 to 39. That's about 3.8 times as many presents, with no overlap between the two sides in any interval. The queue-0 worker is about 98% busy onmainand about 69% with the PR. GPU busy per present drops from 107 ms to 79 ms.The summaries are attached to https://github.com/milescoviello/AnyPS5/releases/tag/perf-bo2-8756-ab-2026-10-21. These runs took no traces. I'll update the description's summary with these numbers.
AI-assisted: yes (Claude Code)