perf(agc): reuse an equal untracked compare made after the caller's ordering point #18078

Closed
klosixgaming-arch wants to merge 7 commits from upstream-pr/18078 into main
klosixgaming-arch commented 2026-11-10 10:05:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-11-10T10:05:12Z.


What

StorageTexture::compareUntracked keeps 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_COMPARES restores the per-epoch memo, and APS5_AB can 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 main e95cc604e2, 1c754d29a5 (now #17786's head):

{"commit":"1c754d29a502","dirty":false,"env":{"APS5_AB":"10:APS5_NO_SHARED_COLLECT_WALKS","APS5_AB_START":"80s","APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":379,"ms":10143.834},"presents":45,"frame_ms":{"p50":223.988,"p90":238.682,"p99":246.465,"max":246.465},"gpu_busy_ms_per_present":44.682,"worker_busy_pct":{"queue worker 0x0":99.476,"queue worker 0x23":100.065},"top_phases_ms_per_frame":{"Driver.Packet":439.171,"Driver.Packet.dispatch":210.783,"Driver.Packet.memory_wait":199.985,"Driver.Dispatch":147.009,"Vulkan.Dispatch":104.706,"Vulkan.Dispatch.shader_resources":98.970,"Graphics.Draw":63.268,"Graphics.Draw.draw_and_resource_release":62.070},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-1c754d29a502-22040.json.gz"}

this PR merged with the same main, 4de7bc3a98 (now the PR head):

{"commit":"4de7bc3a98fd","dirty":false,"env":{"APS5_AB":"10:APS5_NO_SHARED_UNTRACKED_COMPARES","APS5_AB_START":"80s","APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":389,"ms":10005.575},"presents":49,"frame_ms":{"p50":203.935,"p90":215.353,"p99":221.140,"max":221.140},"gpu_busy_ms_per_present":43.245,"worker_busy_pct":{"queue worker 0x0":99.487,"queue worker 0x23":99.890},"top_phases_ms_per_frame":{"Driver.Packet":397.323,"Driver.Packet.dispatch":190.733,"Driver.Packet.memory_wait":181.837,"Driver.Dispatch":132.201,"Vulkan.Dispatch":95.607,"Vulkan.Dispatch.shader_resources":90.597,"Graphics.Draw":56.919,"Graphics.Draw.draw_and_resource_release":55.942},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-4de7bc3a98fd-75164.json.gz"}

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_COMPARES from 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. main itself ran 43.0 and 43.6 (3339e01f59) and 47.0 (e95cc604e2, the main merged 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 on main (-2.10 +- 0.20 presents per 10 s).

metric                                  A          B        B-A    B/A-1   B vs neighbouring A: mean +- SE (SD, n)
presents/10s                        43.07      43.10      +0.02    +0.1%   -0.05 +- 0.61 (SD 1.84, n 9)
frame ms                           232.46     232.55      +0.10    +0.0%   +0.52 +- 3.42 (SD 10.27, n 9)
trace_digest.py, #17786 1c754d29a5

seconds 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: no

Slowest frames (largest slices inside each, inclusive)

  • present 392: 246.5 ms at 2953 ms: Driver.Packet (queue worker 0x23) 241.0, Driver.Packet (queue worker 0x0) 233.0, Driver.Packet.memory_wait (queue worker 0x23) 207.9, Driver.Packet.dispatch (queue worker 0x0) 191.7
  • present 393: 245.6 ms at 3199 ms: Driver.Packet (queue worker 0x23) 239.5, Driver.Packet (queue worker 0x0) 233.4, Driver.Packet.memory_wait (queue worker 0x23) 208.0, Driver.Packet.dispatch (queue worker 0x0) 196.3
  • present 391: 243.3 ms at 2710 ms: Driver.Packet (queue worker 0x23) 238.4, Driver.Packet (queue worker 0x0) 231.4, Driver.Packet.memory_wait (queue worker 0x23) 209.7, Driver.Packet.dispatch (queue worker 0x0) 189.3

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 198.2 (88 %) 22.3 (10 %) 4.9 13.2 Driver.Packet 214.9, Driver.EndSubmission 5.6
draw committer 68.8 (31 %) 15.4 (7 %) 141.3 1.5 Graphics.Draw 63.2, Vulkan.DrawFromRecipe 8.8
presenter 1.4 (1 %) 0.0 (0 %) 224.0 0.1 VideoOut.Flip 1.4
queue worker 0x23 19.8 (9 %) 202.4 (90 %) 3.2 2.4 Driver.Packet 217.3, Driver.EndSubmission 4.9
gpu 44.6 (20 %) 0.0 (0 %) 180.8 0.0 batch 44.6

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

  • Driver.Packet.memory_wait (queue worker 0x23) 137.3 ms at 2825 ms, present 391
  • Driver.Packet.memory_wait (queue worker 0x23) 134.4 ms at 6911 ms, present 409
  • Driver.Packet.memory_wait (queue worker 0x23) 133.4 ms at 1443 ms, present 385
  • Driver.Packet.memory_wait (queue worker 0x23) 133.4 ms at 3076 ms, present 392
  • Driver.Packet.memory_wait (queue worker 0x23) 133.3 ms at 4674 ms, present 399

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 27723: 11.8 ms at 5619 ms, present 403: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.1, Driver.Packet.dispatch (queue worker 0x0) 12.1, Driver.Dispatch (queue worker 0x0) 12.0, Vulkan.Dispatch (queue worker 0x0) 11.5
  • batch 25752: 11.6 ms at 1946 ms, present 387: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.2, Driver.Packet.dispatch (queue worker 0x0) 12.2, Driver.Dispatch (queue worker 0x0) 12.2, Vulkan.Dispatch (queue worker 0x0) 11.7
  • batch 26875: 11.4 ms at 4053 ms, present 396: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.6, Driver.Packet.dispatch (queue worker 0x0) 12.6, Driver.Dispatch (queue worker 0x0) 12.6, Vulkan.Dispatch (queue worker 0x0) 12.1
trace_digest.py, this PR 4de7bc3a98

seconds 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: no

Slowest frames (largest slices inside each, inclusive)

  • present 398: 221.1 ms at 1845 ms: Driver.Packet (queue worker 0x23) 219.6, Driver.Packet (queue worker 0x0) 213.1, Driver.Packet.memory_wait (queue worker 0x23) 188.8, Driver.Packet.dispatch (queue worker 0x0) 182.0
  • present 421: 220.6 ms at 6507 ms: Driver.Packet (queue worker 0x23) 214.8, Driver.Packet (queue worker 0x0) 209.9, Driver.Packet.memory_wait (queue worker 0x23) 189.1, Driver.Packet.dispatch (queue worker 0x0) 180.9
  • present 437: 219.8 ms at 9786 ms: Driver.Packet (queue worker 0x0) 208.6, Driver.Packet.dispatch (queue worker 0x0) 181.1, Driver.Dispatch (queue worker 0x0) 118.0, Driver.Packet (queue worker 0x23) 100.7

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 179.3 (88 %) 20.5 (10 %) 4.5 12.6 Driver.Packet 194.7, Driver.EndSubmission 5.0
draw committer 61.5 (30 %) 13.7 (7 %) 128.9 1.5 Graphics.Draw 56.9, Vulkan.DrawFromRecipe 8.2
presenter 1.2 (1 %) 0.0 (0 %) 203.0 0.1 VideoOut.Flip 1.2
queue worker 0x23 16.9 (8 %) 184.3 (90 %) 3.0 2.3 Driver.Packet 196.5, Driver.EndSubmission 4.7
gpu 42.4 (21 %) 0.0 (0 %) 161.8 0.0 batch 42.4

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

  • Driver.Packet.memory_wait (queue worker 0x23) 123.8 ms at 6612 ms, present 421
  • Driver.Packet.memory_wait (queue worker 0x23) 122.8 ms at 1951 ms, present 398
  • Driver.Packet.memory_wait (queue worker 0x23) 122.4 ms at 9674 ms, present 436
  • Driver.Packet.memory_wait (queue worker 0x23) 121.3 ms at 5783 ms, present 417
  • Driver.Packet.memory_wait (queue worker 0x23) 118.5 ms at 8262 ms, present 429

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 25958: 10.9 ms at 344 ms, present 390: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.8, Driver.Packet.dispatch (queue worker 0x0) 10.8, Driver.Dispatch (queue worker 0x0) 10.8, Vulkan.Dispatch (queue worker 0x0) 10.4
  • batch 28363: 10.5 ms at 4447 ms, present 410: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.1, Driver.Packet.dispatch (queue worker 0x0) 10.1, Driver.Dispatch (queue worker 0x0) 10.0, Vulkan.Dispatch (queue worker 0x0) 9.7
  • batch 28126: 10.4 ms at 4061 ms, present 408: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.9, Driver.Packet.dispatch (queue worker 0x0) 11.9, Driver.Dispatch (queue worker 0x0) 11.9, Vulkan.Dispatch (queue worker 0x0) 11.4

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=170s or 200s), and tools/ab_split.py compares 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: f5fe807353 with #11485, #10443 (APS5_SETTLE_FLOOR_KIB=64), the APS5_CAPTURE_UNPROVEN_PENDING capture experiment, #17786, per-block walk reuse (#17766's model), dispatch items for dispatch-cache misses (local, with APS5_PIPELINE_DISPATCH=1), and the earlier PRs of the series. main cannot reach this screen without the capture experiment (the storage write-back abort), so the main runs below carry that one commit too.

On the series (APS5_AB=30:APS5_NO_SHARED_UNTRACKED_COMPARES, 9 B phases):

metric                                  A          B        B-A    B/A-1   B vs neighbouring A: mean +- SE (SD, n)
presents/10s                        40.96      39.67      -1.29    -3.1%   -1.28 +- 0.16 (SD 0.48, n 9)
frame ms                           244.14     252.09      +7.94    +3.3%   +7.89 +- 1.01 (SD 3.03, n 9)

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_tests and agc_runtime_switches_tests on #17786's head 9eb1178210 with this PR and ran ctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*)$'. 51 tests pass, including all agc_storage_* and agc_import_* tests. The same 51 pass on #17786's head without this PR. agc_copied_write_back exits with 0xc0000374 (heap corruption) on both, and also on #17786's base ca761cadc5 alone, so it predates both PRs; it passes on current main. 8 did not run here: 5 binaries were not built by these targets, and 3 agc_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 of agc_untracked_forget. With shared compares on, it checks three cases:

  • a refresh whose ordering point comes after an equal compare's start compares again;
  • a refresh in another collect epoch whose ordering point comes before that start reuses the compare;
  • after RaiseCollectSince moves the point past the start, the refresh compares again.

With APS5_NO_SHARED_UNTRACKED_COMPARES set, it checks the per-epoch memo:

  • a new epoch compares;
  • a second refresh in the same epoch reuses the compare;
  • another epoch whose point comes before the compare's start still compares.

I ran it on this PR merged with main 320d47bd3d, because on the PR's own base the recorder tests fail to start here (0xc0000139). 61 tests pass, including agc_untracked_forget and agc_copied_write_back. The same 5 binaries were not built, and the same 3 agc_driver_msaa_dcc_compared_import_* tests did not start. Mutation check: with the time comparison inverted, agc_untracked_forget fails.

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:

PR change gain on the series (in-run A/B)
#17786 share collect walks between threads after the caller's ordering point +11.9%
#17766 (chitters2004) per-64 KiB block observation table; I measured this reuse model on top of #17786 +2.6%
#18078 reuse an equal untracked compare made after the caller's ordering point (needs #17786) +3.2%
#18075 reuse a storage image's import segments while the mapping and import table are unchanged +3.6%
#18076 prove an untracked storage image unchanged from an equal compare +2.7% on its first head; now a draft, because its fix for compared host imports removes the gain
#18102 reuse a walk after the ordering point when storage results become pending +4.2% (intro movie)

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 main alone, because main is limited elsewhere on this screen; each PR says what it measured there. Not a PR: ANYPS5_PRESENT_MODE=mailbox gave +12 to 14% and immediate +18 to 21% on the same screen, because FIFO holds the flip that the next frame's rendering wait waits for.

Checklist

  • Based on #17786's branch, both merged with current main (e95cc604e2); no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #17786
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5239419123 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18078). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-11-10T10:05:12Z. --- ### What `StorageTexture::compareUntracked` keeps 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_COMPARES` restores the per-epoch memo, and `APS5_AB` can 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 `main` `e95cc604e2`, `1c754d29a5` (now #17786's head): ```json {"commit":"1c754d29a502","dirty":false,"env":{"APS5_AB":"10:APS5_NO_SHARED_COLLECT_WALKS","APS5_AB_START":"80s","APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":379,"ms":10143.834},"presents":45,"frame_ms":{"p50":223.988,"p90":238.682,"p99":246.465,"max":246.465},"gpu_busy_ms_per_present":44.682,"worker_busy_pct":{"queue worker 0x0":99.476,"queue worker 0x23":100.065},"top_phases_ms_per_frame":{"Driver.Packet":439.171,"Driver.Packet.dispatch":210.783,"Driver.Packet.memory_wait":199.985,"Driver.Dispatch":147.009,"Vulkan.Dispatch":104.706,"Vulkan.Dispatch.shader_resources":98.970,"Graphics.Draw":63.268,"Graphics.Draw.draw_and_resource_release":62.070},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-1c754d29a502-22040.json.gz"} ``` this PR merged with the same `main`, `4de7bc3a98` (now the PR head): ```json {"commit":"4de7bc3a98fd","dirty":false,"env":{"APS5_AB":"10:APS5_NO_SHARED_UNTRACKED_COMPARES","APS5_AB_START":"80s","APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":389,"ms":10005.575},"presents":49,"frame_ms":{"p50":203.935,"p90":215.353,"p99":221.140,"max":221.140},"gpu_busy_ms_per_present":43.245,"worker_busy_pct":{"queue worker 0x0":99.487,"queue worker 0x23":99.890},"top_phases_ms_per_frame":{"Driver.Packet":397.323,"Driver.Packet.dispatch":190.733,"Driver.Packet.memory_wait":181.837,"Driver.Dispatch":132.201,"Vulkan.Dispatch":95.607,"Vulkan.Dispatch.shader_resources":90.597,"Graphics.Draw":56.919,"Graphics.Draw.draw_and_resource_release":55.942},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-4de7bc3a98fd-75164.json.gz"} ``` 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_COMPARES` from 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. `main` itself ran 43.0 and 43.6 (`3339e01f59`) and 47.0 (`e95cc604e2`, the `main` merged 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 on `main` (-2.10 +- 0.20 presents per 10 s). ``` metric A B B-A B/A-1 B vs neighbouring A: mean +- SE (SD, n) presents/10s 43.07 43.10 +0.02 +0.1% -0.05 +- 0.61 (SD 1.84, n 9) frame ms 232.46 232.55 +0.10 +0.0% +0.52 +- 3.42 (SD 10.27, n 9) ``` <details><summary>trace_digest.py, #17786 1c754d29a5</summary> **seconds 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 1c754d29a502, dropped: no **Slowest frames** (largest slices inside each, inclusive) - present 392: 246.5 ms at 2953 ms: Driver.Packet (queue worker 0x23) 241.0, Driver.Packet (queue worker 0x0) 233.0, Driver.Packet.memory_wait (queue worker 0x23) 207.9, Driver.Packet.dispatch (queue worker 0x0) 191.7 - present 393: 245.6 ms at 3199 ms: Driver.Packet (queue worker 0x23) 239.5, Driver.Packet (queue worker 0x0) 233.4, Driver.Packet.memory_wait (queue worker 0x23) 208.0, Driver.Packet.dispatch (queue worker 0x0) 196.3 - present 391: 243.3 ms at 2710 ms: Driver.Packet (queue worker 0x23) 238.4, Driver.Packet (queue worker 0x0) 231.4, Driver.Packet.memory_wait (queue worker 0x23) 209.7, Driver.Packet.dispatch (queue worker 0x0) 189.3 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 198.2 (88 %) | 22.3 (10 %) | 4.9 | 13.2 | Driver.Packet 214.9, Driver.EndSubmission 5.6 | | draw committer | 68.8 (31 %) | 15.4 (7 %) | 141.3 | 1.5 | Graphics.Draw 63.2, Vulkan.DrawFromRecipe 8.8 | | presenter | 1.4 (1 %) | 0.0 (0 %) | 224.0 | 0.1 | VideoOut.Flip 1.4 | | queue worker 0x23 | 19.8 (9 %) | 202.4 (90 %) | 3.2 | 2.4 | Driver.Packet 217.3, Driver.EndSubmission 4.9 | | gpu | 44.6 (20 %) | 0.0 (0 %) | 180.8 | 0.0 | batch 44.6 | **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** - Driver.Packet.memory_wait (queue worker 0x23) 137.3 ms at 2825 ms, present 391 - Driver.Packet.memory_wait (queue worker 0x23) 134.4 ms at 6911 ms, present 409 - Driver.Packet.memory_wait (queue worker 0x23) 133.4 ms at 1443 ms, present 385 - Driver.Packet.memory_wait (queue worker 0x23) 133.4 ms at 3076 ms, present 392 - Driver.Packet.memory_wait (queue worker 0x23) 133.3 ms at 4674 ms, present 399 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 27723: 11.8 ms at 5619 ms, present 403: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.1, Driver.Packet.dispatch (queue worker 0x0) 12.1, Driver.Dispatch (queue worker 0x0) 12.0, Vulkan.Dispatch (queue worker 0x0) 11.5 - batch 25752: 11.6 ms at 1946 ms, present 387: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.2, Driver.Packet.dispatch (queue worker 0x0) 12.2, Driver.Dispatch (queue worker 0x0) 12.2, Vulkan.Dispatch (queue worker 0x0) 11.7 - batch 26875: 11.4 ms at 4053 ms, present 396: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.6, Driver.Packet.dispatch (queue worker 0x0) 12.6, Driver.Dispatch (queue worker 0x0) 12.6, Vulkan.Dispatch (queue worker 0x0) 12.1 </details> <details><summary>trace_digest.py, this PR 4de7bc3a98</summary> **seconds 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 4de7bc3a98fd, dropped: no **Slowest frames** (largest slices inside each, inclusive) - present 398: 221.1 ms at 1845 ms: Driver.Packet (queue worker 0x23) 219.6, Driver.Packet (queue worker 0x0) 213.1, Driver.Packet.memory_wait (queue worker 0x23) 188.8, Driver.Packet.dispatch (queue worker 0x0) 182.0 - present 421: 220.6 ms at 6507 ms: Driver.Packet (queue worker 0x23) 214.8, Driver.Packet (queue worker 0x0) 209.9, Driver.Packet.memory_wait (queue worker 0x23) 189.1, Driver.Packet.dispatch (queue worker 0x0) 180.9 - present 437: 219.8 ms at 9786 ms: Driver.Packet (queue worker 0x0) 208.6, Driver.Packet.dispatch (queue worker 0x0) 181.1, Driver.Dispatch (queue worker 0x0) 118.0, Driver.Packet (queue worker 0x23) 100.7 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 179.3 (88 %) | 20.5 (10 %) | 4.5 | 12.6 | Driver.Packet 194.7, Driver.EndSubmission 5.0 | | draw committer | 61.5 (30 %) | 13.7 (7 %) | 128.9 | 1.5 | Graphics.Draw 56.9, Vulkan.DrawFromRecipe 8.2 | | presenter | 1.2 (1 %) | 0.0 (0 %) | 203.0 | 0.1 | VideoOut.Flip 1.2 | | queue worker 0x23 | 16.9 (8 %) | 184.3 (90 %) | 3.0 | 2.3 | Driver.Packet 196.5, Driver.EndSubmission 4.7 | | gpu | 42.4 (21 %) | 0.0 (0 %) | 161.8 | 0.0 | batch 42.4 | **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** - Driver.Packet.memory_wait (queue worker 0x23) 123.8 ms at 6612 ms, present 421 - Driver.Packet.memory_wait (queue worker 0x23) 122.8 ms at 1951 ms, present 398 - Driver.Packet.memory_wait (queue worker 0x23) 122.4 ms at 9674 ms, present 436 - Driver.Packet.memory_wait (queue worker 0x23) 121.3 ms at 5783 ms, present 417 - Driver.Packet.memory_wait (queue worker 0x23) 118.5 ms at 8262 ms, present 429 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 25958: 10.9 ms at 344 ms, present 390: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.8, Driver.Packet.dispatch (queue worker 0x0) 10.8, Driver.Dispatch (queue worker 0x0) 10.8, Vulkan.Dispatch (queue worker 0x0) 10.4 - batch 28363: 10.5 ms at 4447 ms, present 410: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.1, Driver.Packet.dispatch (queue worker 0x0) 10.1, Driver.Dispatch (queue worker 0x0) 10.0, Vulkan.Dispatch (queue worker 0x0) 9.7 - batch 28126: 10.4 ms at 4061 ms, present 408: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.9, Driver.Packet.dispatch (queue worker 0x0) 11.9, Driver.Dispatch (queue worker 0x0) 11.9, Vulkan.Dispatch (queue worker 0x0) 11.4 </details> 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=170s` or `200s`), and `tools/ab_split.py` compares 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: `f5fe807353` with #11485, #10443 (`APS5_SETTLE_FLOOR_KIB=64`), the `APS5_CAPTURE_UNPROVEN_PENDING` capture experiment, #17786, per-block walk reuse (#17766's model), dispatch items for dispatch-cache misses (local, with `APS5_PIPELINE_DISPATCH=1`), and the earlier PRs of the series. `main` cannot reach this screen without the capture experiment (the storage write-back abort), so the `main` runs below carry that one commit too. **On the series** (`APS5_AB=30:APS5_NO_SHARED_UNTRACKED_COMPARES`, 9 B phases): ``` metric A B B-A B/A-1 B vs neighbouring A: mean +- SE (SD, n) presents/10s 40.96 39.67 -1.29 -3.1% -1.28 +- 0.16 (SD 0.48, n 9) frame ms 244.14 252.09 +7.94 +3.3% +7.89 +- 1.01 (SD 3.03, n 9) ``` 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_tests` and `agc_runtime_switches_tests` on #17786's head `9eb1178210` with this PR and ran `ctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*)$'`. 51 tests pass, including all `agc_storage_*` and `agc_import_*` tests. The same 51 pass on #17786's head without this PR. `agc_copied_write_back` exits with 0xc0000374 (heap corruption) on both, and also on #17786's base `ca761cadc5` alone, so it predates both PRs; it passes on current `main`. 8 did not run here: 5 binaries were not built by these targets, and 3 `agc_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 of `agc_untracked_forget`. With shared compares on, it checks three cases: - a refresh whose ordering point comes after an equal compare's start compares again; - a refresh in another collect epoch whose ordering point comes before that start reuses the compare; - after `RaiseCollectSince` moves the point past the start, the refresh compares again. With `APS5_NO_SHARED_UNTRACKED_COMPARES` set, it checks the per-epoch memo: - a new epoch compares; - a second refresh in the same epoch reuses the compare; - another epoch whose point comes before the compare's start still compares. I ran it on this PR merged with `main` `320d47bd3d`, because on the PR's own base the recorder tests fail to start here (0xc0000139). 61 tests pass, including `agc_untracked_forget` and `agc_copied_write_back`. The same 5 binaries were not built, and the same 3 `agc_driver_msaa_dcc_compared_import_*` tests did not start. Mutation check: with the time comparison inverted, `agc_untracked_forget` fails. ### 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: | PR | change | gain on the series (in-run A/B) | |---|---|---| | #17786 | share collect walks between threads after the caller's ordering point | +11.9% | | #17766 (chitters2004) | per-64 KiB block observation table; I measured this reuse model on top of #17786 | +2.6% | | #18078 | reuse an equal untracked compare made after the caller's ordering point (needs #17786) | +3.2% | | #18075 | reuse a storage image's import segments while the mapping and import table are unchanged | +3.6% | | #18076 | prove an untracked storage image unchanged from an equal compare | +2.7% on its first head; now a draft, because its fix for compared host imports removes the gain | | #18102 | reuse a walk after the ordering point when storage results become pending | +4.2% (intro movie) | 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 `main` alone, because `main` is limited elsewhere on this screen; each PR says what it measured there. Not a PR: `ANYPS5_PRESENT_MODE=mailbox` gave +12 to 14% and `immediate` +18 to 21% on the same screen, because FIFO holds the flip that the next frame's rendering wait waits for. ### Checklist - [x] Based on #17786's branch, both merged with current `main` (`e95cc604e2`); no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #17786 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 - [x] AI-assisted: yes

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18078
No description provided.