perf(agc): reuse a walk after the ordering point when storage results become pending #18102
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18102"
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 klosixgaming-arch on 2026-11-10T12:14:07Z.
What
StorageTexture::markLayersPendingwalked the units' guest range with an uncached collect every time results became pending. That range has usually just been walked: by the draw's target refresh on the same thread, or by another thread after the caller's ordering point (#17786). The walk only stamps CPU writes made before the units'pendingSincegeneration. A write ordered before the draw was made before the ordering point, so a memoized walk that started after that point has already stamped it. This PR uses the memoized collect there.A write that the memoized walk did not see came after the ordering point, so it is not ordered with the draw. It is stamped later and treated as a write made while the results were pending: the CPU's bytes are kept, which is the outcome
a6ba7ddd48gives a later CPU store.APS5_NO_MEMO_PENDING_COLLECTrestores the uncached walk, andAPS5_ABcan toggle it. TheCollectWritesUncachedcomment inGuestMemory.hppnow says why this decision may use a memoized walk.Tested
Summary lines of
mainand of this PR (2026-11-10, same machine and session)Cyberpunk 2077 (PPSA03974), the intro movie, 3200x1800, warm caches; Windows 11, RTX 5090 (driver 617.42), Ryzen 9 9950X3D. Each line is its own run with no switches but the capture ones (
APS5_TRACE_SECONDS=60:10,APS5_TRACE_SUMMARY_EVERY=10,APS5_TRACE_EVENTS=1048576) and, where the line shows it, an in-run A/B that starts after the trace window. Traces and all summary lines: https://github.com/klosixgaming-arch/AnyPS5/releases/tag/perf-captures-2026-11-10main3339e01f59:this PR merged with
main,a8a31c0c19(now the PR head):Steady 10 s windows 3 to 7 of the movie:
main43.6 presents, this PR 48.6. The PR side is the PR merged withmaine95cc604e2, six commits after themaincapture (libSceNpWebApi, macOS and freetype build files, oneRunReport.cppline); none of them touches the AGC driver or guest memory. Separate runs differ here by more than these changes. For example, #18078's switch makes no difference in its own in-run A/B, yet its run and #17786's run differ by 8% in the same windows.mainitself ran 43.0 and 43.6 (3339e01f59) and 47.0 (e95cc604e2, themainmerged into this PR, a run at 22:20 that is also in the release) in the same windows. So the in-run A/B on the PR's commit is the measure. Ona8a31c0c19,APS5_AB=10:APS5_NO_MEMO_PENDING_COLLECTfrom 40 s, 10 B phases inside the movie: this PR gives 2.3% more frames onmainalone in this scene (3 SE).Recorder.Syncslices per present in the trace windows:main44.0, this PR 39.9.trace_digest.py, main
3339e01f59seconds 60:10 from present 357: 43 presents, frame p50 231.4 / p90 246.0 / p99 261.8 / max 261.8 ms, GPU busy 43.0 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit
3339e01f59, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 446.7, Driver.Packet.dispatch 218.6, Driver.Packet.memory_wait 202.4, Driver.Dispatch 153.2, Vulkan.Dispatch 102.0
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py, this PR
a8a31c0c19seconds 60:10 from present 370: 49 presents, frame p50 206.6 / p90 222.0 / p99 235.7 / max 235.7 ms, GPU busy 41.2 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit
a8a31c0c19, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 398.3, Driver.Packet.dispatch 195.8, Driver.Packet.memory_wait 180.5, Driver.Dispatch 136.1, Vulkan.Dispatch 90.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Windows 11, NVIDIA GeForce RTX 5090, Ryzen 9 9950X3D. Cyberpunk 2077 (PPSA03974), the intro movie before "PRESS (O) TO CONTINUE". The game reaches it about 60 s after boot with no input, and it stays steady until the movie ends (about 160 s after the first present on the series, about 360 s on
main). Only phases inside the movie are counted.APS5_PROFILE_DRAW=1.All numbers are in-run A/B: one run flips the switch every 15 or 30 s (
APS5_AB=15:APS5_NO_MEMO_PENDING_COLLECT,APS5_AB_START=55s), andtools/ab_split.pycompares each B phase (switch set, the old behaviour) with its neighbouring A phases (this PR). Both sides use the same build, settings and scene."The series" is my Cyberpunk tree:
f5fe807353with #11485, #10443 (APS5_SETTLE_FLOOR_KIB=64), theAPS5_CAPTURE_UNPROVEN_PENDINGcapture experiment, #17786, per-block walk reuse (#17766's model), dispatch items for dispatch-cache misses (local, withAPS5_PIPELINE_DISPATCH=1), and the earlier PRs of the series. Two more experiments were compiled in and turned off.mainaborts on a storage write-back after the title without the capture experiment, so themainrun carries that one commit too.On the series, two runs:
All four B phases were slower: this PR gives 4.2% more frames (+-1.0%).
On
main(80c5e92d2dwith this PR and the capture experiment, 9 B phases):That is +0.6% (1.7 SE) on
mainalone, inside the noise: there the movie runs at 3.5 fps and the committer is not yet the limit. So this PR is for after #17786. It also relies on #17786's ordering-point rule (a walk that started after the caller's ordering point has stamped every store ordered before the draw), so it lands after that PR.Tests (Windows, RTX 5090): built
agc_driver_recorder_testsandagc_runtime_switches_testsonmain80c5e92d2dwith this PR and ranctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*|agc_collect_.*|agc_write_tracking.*)$'. 67 tests pass, including allagc_storage_*,agc_import_*,agc_collect_*andagc_write_tracking*tests andagc_copied_write_back. 8 did not run here: 5 binaries were not built by these targets, and 3agc_driver_msaa_dcc_compared_import_*tests fail to start on this machine with 0xc0000139, a DLL entry point not found.New test
agc_driver_memo_pending_collect(tests/execution/MemoPendingCollect.cpp). A compute store makes the results of a 1 MiB storage image pending. Through a test hook (StorageTexture::SetPendingHookForTest), the CPU fills one 64 KiB block of the surface just before the collect inmarkLayersPending. The test runs once without and once withAPS5_NO_MEMO_PENDING_COLLECT:It passes here, together with
agc_driver_store_over_untracked,agc_driver_store_pending_identityandagc_runtime_switches*. Mutation checks: if the switch is ignored, the test fails, and if the collect is removed, it fails too. With the collect removed, only the walk check fails; the byte check still passes, because the write-back checks for CPU writes itself. The surface is 1 MiB because a smaller import leaves the write watch: it is under the 1 MiB settle floor, and the collect then has nothing to walk.A host import that is compared rather than watched also takes the surface out of the write watch, so no walk can see the CPU's block. That is the likely case on Intel's Mesa driver (ANV), where the walk check failed.
APS5_WRITE_WATCH_IMPORTS=unwatchforces compared imports on Linux. On such an import the test checks only the results.agc_driver_memo_pending_collect_comparedruns it that way on Linux.Series
These PRs come from the same work on Cyberpunk 2077's character creator, Body Type screen, where the draw committer and queue worker 0 are the limit. They go together:
Each gain was measured with the earlier rows already in place, so the rows add up. The last row was measured on the intro movie, the others on Body Type; both scenes are limited by the same draw committer. Most of them are small or zero on
mainalone, becausemainis limited elsewhere on this screen; each PR says what it measured there. Not a PR:ANYPS5_PRESENT_MODE=mailboxgave +12 to 14% andimmediate+18 to 21% on the same screen, because FIFO holds the flip that the next frame's rendering wait waits for.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)