perf(agc): reuse an equal untracked compare made after the caller's ordering point #18078
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18078"
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-10T10:05:12Z.
What
StorageTexture::compareUntrackedkeeps a small memo of equal compares of untracked guest bytes (memory outside the write watch). Each entry was tied to the comparing thread's collect epoch, so every thread, and every epoch of a thread, compared the same bytes again. On Cyberpunk 2077's Body Type screen that is a large part of the committer's time, because render targets and storage images there are untracked and are refreshed at every draw.With shared collect walks on (#17786), an entry now records when its compare started. It serves any caller, on any thread, whose ordering point lies before that time, while the other stamp parts (driver stamps, forgets, recorded GPU writes) still match. A CPU write made before the caller's point is visible to a compare that started after it, which is the same rule #17786 uses for walks. Ranges with a write-watch hint keep using the hint.
APS5_NO_SHARED_UNTRACKED_COMPARESrestores the per-epoch memo, andAPS5_ABcan toggle it.Tested
Summary lines of the base (#17786) and 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-10#17786 merged with
maine95cc604e2,1c754d29a5(now #17786's head):this PR merged with the same
main,4de7bc3a98(now the PR head):Steady 10 s windows 3 to 7 of the movie: #17786 44.8 presents, this PR 48.4. Separate runs differ here by more than these changes, so the in-run A/B is the measure. In the run of the second line,
APS5_AB=10:APS5_NO_SHARED_UNTRACKED_COMPARESfrom 80 s, 9 B phases inside the movie: no difference in this scene (-0.05 +- 0.61), so the 8% between the two lines is run-to-run variation.mainitself ran 43.0 and 43.6 (3339e01f59) and 47.0 (e95cc604e2, themainmerged into both branches, a run at 22:20 that is also in the release) in the same windows. The gain of this PR is on the Body Type screen (below), where untracked targets are refreshed at every draw. In #17786's run, its own switch (APS5_AB=10:APS5_NO_SHARED_COLLECT_WALKS, 9 B phases) gave 5.0% more frames onmain(-2.10 +- 0.20 presents per 10 s).trace_digest.py, #17786
1c754d29a5seconds 60:10 from present 379: 45 presents, frame p50 224.0 / p90 238.7 / p99 246.5 / max 246.5 ms, GPU busy 44.7 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit
1c754d29a5, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 432.2, Driver.Packet.dispatch 210.6, Driver.Packet.memory_wait 197.2, Driver.Dispatch 146.6, Vulkan.Dispatch 104.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py, this PR
4de7bc3a98seconds 60:10 from present 389: 49 presents, frame p50 203.9 / p90 215.4 / p99 221.1 / max 221.1 ms, GPU busy 43.2 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit
4de7bc3a98, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 391.2, Driver.Packet.dispatch 190.6, Driver.Packet.memory_wait 179.5, Driver.Dispatch 131.7, Vulkan.Dispatch 95.2
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), character creator, Body Type screen, warm caches,
APS5_PROFILE_DRAW=1.All numbers are in-run A/B: one run flips the PR's switch every 30 s (
APS5_AB=30:<switch>,APS5_AB_START=170sor200s), 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" below 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.maincannot reach this screen without the capture experiment (the storage write-back abort), so themainruns below carry that one commit too.On the series (
APS5_AB=30:APS5_NO_SHARED_UNTRACKED_COMPARES, 9 B phases):This PR gives 3.2% more frames (8 SE). That run used the experiment version of this change, which kept the start time in a new field of the memo entry; this PR keeps it in the existing stamp with the same rule. It needs #17786, so there is no
main-only measurement.Tests (Windows, RTX 5090): built
agc_driver_recorder_testsandagc_runtime_switches_testson #17786's head9eb1178210with this PR and ranctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*)$'. 51 tests pass, including allagc_storage_*andagc_import_*tests. The same 51 pass on #17786's head without this PR.agc_copied_write_backexits with 0xc0000374 (heap corruption) on both, and also on #17786's baseca761cadc5alone, so it predates both PRs; it passes on currentmain. 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
sharedUntrackedCompareTests(tests/Recorder.cpp), which runs as part ofagc_untracked_forget. With shared compares on, it checks three cases:RaiseCollectSincemoves the point past the start, the refresh compares again.With
APS5_NO_SHARED_UNTRACKED_COMPARESset, it checks the per-epoch memo:I ran it on this PR merged with
main320d47bd3d, because on the PR's own base the recorder tests fail to start here (0xc0000139). 61 tests pass, includingagc_untracked_forgetandagc_copied_write_back. The same 5 binaries were not built, and the same 3agc_driver_msaa_dcc_compared_import_*tests did not start. Mutation check: with the time comparison inverted,agc_untracked_forgetfails.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(e95cc604e2); 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)Pull request closed