perf(agc): reuse a walk after the ordering point when storage results become pending #18102

Merged
klosixgaming-arch merged 7 commits from upstream-pr/18102 into main 2026-11-15 10:56:17 +00:00
klosixgaming-arch commented 2026-11-10 12:14:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-11-10T12:14:07Z.


What

StorageTexture::markLayersPending walked 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' pendingSince generation. 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 a6ba7ddd48 gives a later CPU store.

APS5_NO_MEMO_PENDING_COLLECT restores the uncached walk, and APS5_AB can toggle it. The CollectWritesUncached comment in GuestMemory.hpp now says why this decision may use a memoized walk.

Tested

Summary lines of main 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

main 3339e01f59:

{"commit":"3339e01f5961","dirty":false,"env":{"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":357,"ms":10024.712},"presents":43,"frame_ms":{"p50":231.356,"p90":246.036,"p99":261.798,"max":261.798},"gpu_busy_ms_per_present":42.981,"worker_busy_pct":{"queue worker 0x0":99.533,"queue worker 0x23":99.965},"top_phases_ms_per_frame":{"Driver.Packet":453.350,"Driver.Packet.dispatch":218.773,"Driver.Packet.memory_wait":205.130,"Driver.Dispatch":153.578,"Vulkan.Dispatch":102.389,"Vulkan.Dispatch.shader_resources":97.225,"Graphics.Draw":67.192,"Graphics.Draw.draw_and_resource_release":65.999},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-3339e01f5961-53448.json.gz"}

this PR merged with main, a8a31c0c19 (now the PR head):

{"commit":"a8a31c0c19a1","dirty":false,"env":{"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":370,"ms":10209.376},"presents":49,"frame_ms":{"p50":206.590,"p90":221.959,"p99":235.747,"max":235.747},"gpu_busy_ms_per_present":41.231,"worker_busy_pct":{"queue worker 0x0":99.498,"queue worker 0x23":99.960},"top_phases_ms_per_frame":{"Driver.Packet":404.599,"Driver.Packet.dispatch":195.961,"Driver.Packet.memory_wait":182.864,"Driver.Dispatch":136.610,"Vulkan.Dispatch":90.490,"Vulkan.Dispatch.shader_resources":87.661,"Graphics.Draw":60.023,"Graphics.Draw.draw_and_resource_release":58.819},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-a8a31c0c19a1-56020.json.gz"}

Steady 10 s windows 3 to 7 of the movie: main 43.6 presents, this PR 48.6. The PR side is the PR merged with main e95cc604e2, six commits after the main capture (libSceNpWebApi, macOS and freetype build files, one RunReport.cpp line); 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. main itself ran 43.0 and 43.6 (3339e01f59) and 47.0 (e95cc604e2, the main merged 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. On a8a31c0c19, APS5_AB=10:APS5_NO_MEMO_PENDING_COLLECT from 40 s, 10 B phases inside the movie: this PR gives 2.3% more frames on main alone in this scene (3 SE). Recorder.Sync slices per present in the trace windows: main 44.0, this PR 39.9.

metric                                  A          B        B-A    B/A-1   B vs neighbouring A: mean +- SE (SD, n)
presents/10s                        47.33      46.22      -1.11    -2.3%   -1.06 +- 0.31 (SD 0.99, n 10)
frame ms                           211.35     216.41      +5.06    +2.4%   +4.88 +- 1.46 (SD 4.62, n 10)
trace_digest.py, main 3339e01f59

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

Slowest frames (largest slices inside each, inclusive)

  • present 395: 261.8 ms at 8861 ms: Driver.Packet (queue worker 0x23) 254.4, Driver.Packet (queue worker 0x0) 248.9, Driver.Packet.memory_wait (queue worker 0x23) 220.7, Driver.Packet.dispatch (queue worker 0x0) 214.1
  • present 387: 256.8 ms at 7022 ms: Driver.Packet (queue worker 0x23) 250.7, Driver.Packet (queue worker 0x0) 244.5, Driver.Packet.memory_wait (queue worker 0x23) 218.0, Driver.Packet.dispatch (queue worker 0x0) 210.5
  • present 371: 250.5 ms at 3260 ms: Driver.Packet (queue worker 0x23) 245.9, Driver.Packet (queue worker 0x0) 237.9, Driver.Packet.memory_wait (queue worker 0x23) 211.7, Driver.Packet.dispatch (queue worker 0x0) 204.1

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 202.8 (87 %) 25.7 (11 %) 4.6 12.9 Driver.Packet 221.4, Driver.EndSubmission 7.1
draw committer 74.4 (32 %) 12.1 (5 %) 146.7 1.5 Graphics.Draw 67.2, Vulkan.DrawFromRecipe 11.1
presenter 1.4 (1 %) 0.0 (0 %) 231.7 0.1 VideoOut.Flip 1.4
title 0.1 (0 %) 0.1 (0 %) 233.0 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.1 (0 %) 0.1 (0 %) 233.0 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0
queue worker 0x23 21.4 (9 %) 208.4 (89 %) 3.3 2.3 Driver.Packet 225.3, Driver.EndSubmission 4.5
gpu 43.0 (18 %) 0.0 (0 %) 190.1 0.0 batch 43.0

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

  • Driver.Packet.memory_wait (queue worker 0x23) 139.7 ms at 7147 ms, present 387
  • Driver.Packet.memory_wait (queue worker 0x23) 135.9 ms at 3136 ms, present 370
  • Driver.Packet.memory_wait (queue worker 0x23) 133.5 ms at 6901 ms, present 386
  • Driver.Packet.memory_wait (queue worker 0x23) 132.5 ms at 5035 ms, present 378
  • Driver.Packet.memory_wait (queue worker 0x23) 131.7 ms at 1485 ms, present 363

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

  • batch 29422: 11.4 ms at 7188 ms, present 387: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 13.4, Driver.Packet.dispatch (queue worker 0x0) 13.4, Driver.Dispatch (queue worker 0x0) 13.3, Vulkan.Dispatch (queue worker 0x0) 12.6
  • batch 29162: 10.6 ms at 6703 ms, present 385: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.7, Driver.Packet.dispatch (queue worker 0x0) 12.7, Driver.Dispatch (queue worker 0x0) 12.6, Vulkan.Dispatch (queue worker 0x0) 12.1
  • batch 30700: 10.4 ms at 9499 ms, present 397: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.7, Driver.Packet.dispatch (queue worker 0x0) 11.7, Driver.Dispatch (queue worker 0x0) 11.6, Vulkan.Dispatch (queue worker 0x0) 11.2
trace_digest.py, this PR a8a31c0c19

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

Slowest frames (largest slices inside each, inclusive)

  • present 415: 235.7 ms at 9320 ms: Driver.Packet (queue worker 0x23) 231.3, Driver.Packet (queue worker 0x0) 223.9, Driver.Packet.memory_wait (queue worker 0x23) 197.3, Driver.Packet.dispatch (queue worker 0x0) 189.8
  • present 408: 228.2 ms at 7786 ms: Driver.Packet (queue worker 0x23) 223.7, Driver.Packet (queue worker 0x0) 215.1, Driver.Packet.memory_wait (queue worker 0x23) 192.9, Driver.Packet.dispatch (queue worker 0x0) 183.8
  • present 416: 224.9 ms at 9556 ms: Driver.Packet (queue worker 0x23) 219.3, Driver.Packet (queue worker 0x0) 214.9, Driver.Packet.memory_wait (queue worker 0x23) 190.8, Driver.Packet.dispatch (queue worker 0x0) 185.4

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 182.6 (88 %) 21.2 (10 %) 4.5 12.9 Driver.Packet 197.4, Driver.EndSubmission 6.4
draw committer 66.8 (32 %) 11.9 (6 %) 129.7 1.5 Graphics.Draw 60.0, Vulkan.DrawFromRecipe 10.3
presenter 1.4 (1 %) 0.0 (0 %) 207.0 0.1 VideoOut.Flip 1.4
queue worker 0x23 18.8 (9 %) 186.7 (90 %) 2.9 2.4 Driver.Packet 200.9, Driver.EndSubmission 4.5
gpu 42.1 (20 %) 0.0 (0 %) 166.3 0.0 batch 42.1

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

  • Driver.Packet.memory_wait (queue worker 0x23) 130.0 ms at 9436 ms, present 415
  • Driver.Packet.memory_wait (queue worker 0x23) 122.3 ms at 9881 ms, present 417
  • Driver.Packet.memory_wait (queue worker 0x23) 121.0 ms at 7032 ms, present 404
  • Driver.Packet.memory_wait (queue worker 0x23) 120.9 ms at 7900 ms, present 408
  • Driver.Packet.memory_wait (queue worker 0x23) 118.9 ms at 9667 ms, present 416

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

  • batch 31528: 10.6 ms at 7071 ms, present 404: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.5, Driver.Packet.dispatch (queue worker 0x0) 12.5, Driver.Dispatch (queue worker 0x0) 12.4, Vulkan.Dispatch (queue worker 0x0) 11.9
  • batch 29697: 10.3 ms at 3996 ms, present 389: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.3, Driver.Packet.dispatch (queue worker 0x0) 10.3, Driver.Dispatch (queue worker 0x0) 10.3, Vulkan.Dispatch (queue worker 0x0) 9.9
  • batch 27641: 10.1 ms at 535 ms, present 372: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.1, Driver.Packet.dispatch (queue worker 0x0) 10.0, Driver.Dispatch (queue worker 0x0) 10.0, Vulkan.Dispatch (queue worker 0x0) 9.6

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), 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" 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. Two more experiments were compiled in and turned off. main aborts on a storage write-back after the title without the capture experiment, so the main run carries that one commit too.

On the series, two runs:

metric                                  A          B        B-A    B/A-1   B vs neighbouring A: mean +- SE (SD, n)
presents/10s                        93.40      90.16      -3.24    -3.5%   -3.91 +- 0.92 (SD 1.59, n 3)
frame ms                           107.10     110.95      +3.85    +3.6%   +4.63 +- 1.10 (SD 1.91, n 3)
metric                                  A          B        B-A    B/A-1   B vs neighbouring A: mean +- SE (SD, n)
presents/10s                        95.93      92.50      -3.43    -3.6%   -3.43 (n 1)
frame ms                           104.24     108.10      +3.87    +3.7%   +3.87 (n 1)
committer us/commit                105.40     108.40      +3.00    +2.8%   +3.00 (n 1)

All four B phases were slower: this PR gives 4.2% more frames (+-1.0%).

On main (80c5e92d2d with this PR and the capture experiment, 9 B phases):

metric                                  A          B        B-A    B/A-1   B vs neighbouring A: mean +- SE (SD, n)
presents/10s                        34.97      34.78      -0.19    -0.6%   -0.22 +- 0.13 (SD 0.38, n 9)
frame ms                           285.94     287.53      +1.59    +0.6%   +1.83 +- 1.07 (SD 3.22, n 9)

That is +0.6% (1.7 SE) on main alone, 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_tests and agc_runtime_switches_tests on main 80c5e92d2d with this PR and ran ctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*|agc_collect_.*|agc_write_tracking.*)$'. 67 tests pass, including all agc_storage_*, agc_import_*, agc_collect_* and agc_write_tracking* tests and agc_copied_write_back. 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 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 in markLayersPending. The test runs once without and once with APS5_NO_MEMO_PENDING_COLLECT:

  • without the switch, the collect reuses the storage refresh's walk and does not stamp the block again;
  • with it, the collect walks the block again;
  • in both runs, the write-back leaves the CPU's block as the CPU wrote it and stores the GPU's results in the other block.

It passes here, together with agc_driver_store_over_untracked, agc_driver_store_pending_identity and agc_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=unwatch forces compared imports on Linux. On such an import the test checks only the results. agc_driver_memo_pending_collect_compared runs 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:

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 current main; 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 (relies on its ordering-point rule; lands after it)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5241062978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18102). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-11-10T12:14:07Z. --- ### What `StorageTexture::markLayersPending` walked 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' `pendingSince` generation. 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 a6ba7ddd48 gives a later CPU store. `APS5_NO_MEMO_PENDING_COLLECT` restores the uncached walk, and `APS5_AB` can toggle it. The `CollectWritesUncached` comment in `GuestMemory.hpp` now says why this decision may use a memoized walk. ### Tested **Summary lines of `main` 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 `main` `3339e01f59`: ```json {"commit":"3339e01f5961","dirty":false,"env":{"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":357,"ms":10024.712},"presents":43,"frame_ms":{"p50":231.356,"p90":246.036,"p99":261.798,"max":261.798},"gpu_busy_ms_per_present":42.981,"worker_busy_pct":{"queue worker 0x0":99.533,"queue worker 0x23":99.965},"top_phases_ms_per_frame":{"Driver.Packet":453.350,"Driver.Packet.dispatch":218.773,"Driver.Packet.memory_wait":205.130,"Driver.Dispatch":153.578,"Vulkan.Dispatch":102.389,"Vulkan.Dispatch.shader_resources":97.225,"Graphics.Draw":67.192,"Graphics.Draw.draw_and_resource_release":65.999},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-3339e01f5961-53448.json.gz"} ``` this PR merged with `main`, `a8a31c0c19` (now the PR head): ```json {"commit":"a8a31c0c19a1","dirty":false,"env":{"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":370,"ms":10209.376},"presents":49,"frame_ms":{"p50":206.590,"p90":221.959,"p99":235.747,"max":235.747},"gpu_busy_ms_per_present":41.231,"worker_busy_pct":{"queue worker 0x0":99.498,"queue worker 0x23":99.960},"top_phases_ms_per_frame":{"Driver.Packet":404.599,"Driver.Packet.dispatch":195.961,"Driver.Packet.memory_wait":182.864,"Driver.Dispatch":136.610,"Vulkan.Dispatch":90.490,"Vulkan.Dispatch.shader_resources":87.661,"Graphics.Draw":60.023,"Graphics.Draw.draw_and_resource_release":58.819},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-a8a31c0c19a1-56020.json.gz"} ``` Steady 10 s windows 3 to 7 of the movie: `main` 43.6 presents, this PR 48.6. The PR side is the PR merged with `main` `e95cc604e2`, six commits after the `main` capture (libSceNpWebApi, macOS and freetype build files, one `RunReport.cpp` line); 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. `main` itself ran 43.0 and 43.6 (`3339e01f59`) and 47.0 (`e95cc604e2`, the `main` merged 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. On `a8a31c0c19`, `APS5_AB=10:APS5_NO_MEMO_PENDING_COLLECT` from 40 s, 10 B phases inside the movie: this PR gives 2.3% more frames on `main` alone in this scene (3 SE). `Recorder.Sync` slices per present in the trace windows: `main` 44.0, this PR 39.9. ``` metric A B B-A B/A-1 B vs neighbouring A: mean +- SE (SD, n) presents/10s 47.33 46.22 -1.11 -2.3% -1.06 +- 0.31 (SD 0.99, n 10) frame ms 211.35 216.41 +5.06 +2.4% +4.88 +- 1.46 (SD 4.62, n 10) ``` <details><summary>trace_digest.py, main 3339e01f59</summary> **seconds 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 3339e01f5961, dropped: no **Slowest frames** (largest slices inside each, inclusive) - present 395: 261.8 ms at 8861 ms: Driver.Packet (queue worker 0x23) 254.4, Driver.Packet (queue worker 0x0) 248.9, Driver.Packet.memory_wait (queue worker 0x23) 220.7, Driver.Packet.dispatch (queue worker 0x0) 214.1 - present 387: 256.8 ms at 7022 ms: Driver.Packet (queue worker 0x23) 250.7, Driver.Packet (queue worker 0x0) 244.5, Driver.Packet.memory_wait (queue worker 0x23) 218.0, Driver.Packet.dispatch (queue worker 0x0) 210.5 - present 371: 250.5 ms at 3260 ms: Driver.Packet (queue worker 0x23) 245.9, Driver.Packet (queue worker 0x0) 237.9, Driver.Packet.memory_wait (queue worker 0x23) 211.7, Driver.Packet.dispatch (queue worker 0x0) 204.1 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 202.8 (87 %) | 25.7 (11 %) | 4.6 | 12.9 | Driver.Packet 221.4, Driver.EndSubmission 7.1 | | draw committer | 74.4 (32 %) | 12.1 (5 %) | 146.7 | 1.5 | Graphics.Draw 67.2, Vulkan.DrawFromRecipe 11.1 | | presenter | 1.4 (1 %) | 0.0 (0 %) | 231.7 | 0.1 | VideoOut.Flip 1.4 | | title | 0.1 (0 %) | 0.1 (0 %) | 233.0 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.1 (0 %) | 0.1 (0 %) | 233.0 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | queue worker 0x23 | 21.4 (9 %) | 208.4 (89 %) | 3.3 | 2.3 | Driver.Packet 225.3, Driver.EndSubmission 4.5 | | gpu | 43.0 (18 %) | 0.0 (0 %) | 190.1 | 0.0 | batch 43.0 | **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** - Driver.Packet.memory_wait (queue worker 0x23) 139.7 ms at 7147 ms, present 387 - Driver.Packet.memory_wait (queue worker 0x23) 135.9 ms at 3136 ms, present 370 - Driver.Packet.memory_wait (queue worker 0x23) 133.5 ms at 6901 ms, present 386 - Driver.Packet.memory_wait (queue worker 0x23) 132.5 ms at 5035 ms, present 378 - Driver.Packet.memory_wait (queue worker 0x23) 131.7 ms at 1485 ms, present 363 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 29422: 11.4 ms at 7188 ms, present 387: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 13.4, Driver.Packet.dispatch (queue worker 0x0) 13.4, Driver.Dispatch (queue worker 0x0) 13.3, Vulkan.Dispatch (queue worker 0x0) 12.6 - batch 29162: 10.6 ms at 6703 ms, present 385: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.7, Driver.Packet.dispatch (queue worker 0x0) 12.7, Driver.Dispatch (queue worker 0x0) 12.6, Vulkan.Dispatch (queue worker 0x0) 12.1 - batch 30700: 10.4 ms at 9499 ms, present 397: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.7, Driver.Packet.dispatch (queue worker 0x0) 11.7, Driver.Dispatch (queue worker 0x0) 11.6, Vulkan.Dispatch (queue worker 0x0) 11.2 </details> <details><summary>trace_digest.py, this PR a8a31c0c19</summary> **seconds 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 a8a31c0c19a1, dropped: no **Slowest frames** (largest slices inside each, inclusive) - present 415: 235.7 ms at 9320 ms: Driver.Packet (queue worker 0x23) 231.3, Driver.Packet (queue worker 0x0) 223.9, Driver.Packet.memory_wait (queue worker 0x23) 197.3, Driver.Packet.dispatch (queue worker 0x0) 189.8 - present 408: 228.2 ms at 7786 ms: Driver.Packet (queue worker 0x23) 223.7, Driver.Packet (queue worker 0x0) 215.1, Driver.Packet.memory_wait (queue worker 0x23) 192.9, Driver.Packet.dispatch (queue worker 0x0) 183.8 - present 416: 224.9 ms at 9556 ms: Driver.Packet (queue worker 0x23) 219.3, Driver.Packet (queue worker 0x0) 214.9, Driver.Packet.memory_wait (queue worker 0x23) 190.8, Driver.Packet.dispatch (queue worker 0x0) 185.4 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 182.6 (88 %) | 21.2 (10 %) | 4.5 | 12.9 | Driver.Packet 197.4, Driver.EndSubmission 6.4 | | draw committer | 66.8 (32 %) | 11.9 (6 %) | 129.7 | 1.5 | Graphics.Draw 60.0, Vulkan.DrawFromRecipe 10.3 | | presenter | 1.4 (1 %) | 0.0 (0 %) | 207.0 | 0.1 | VideoOut.Flip 1.4 | | queue worker 0x23 | 18.8 (9 %) | 186.7 (90 %) | 2.9 | 2.4 | Driver.Packet 200.9, Driver.EndSubmission 4.5 | | gpu | 42.1 (20 %) | 0.0 (0 %) | 166.3 | 0.0 | batch 42.1 | **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** - Driver.Packet.memory_wait (queue worker 0x23) 130.0 ms at 9436 ms, present 415 - Driver.Packet.memory_wait (queue worker 0x23) 122.3 ms at 9881 ms, present 417 - Driver.Packet.memory_wait (queue worker 0x23) 121.0 ms at 7032 ms, present 404 - Driver.Packet.memory_wait (queue worker 0x23) 120.9 ms at 7900 ms, present 408 - Driver.Packet.memory_wait (queue worker 0x23) 118.9 ms at 9667 ms, present 416 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 31528: 10.6 ms at 7071 ms, present 404: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.5, Driver.Packet.dispatch (queue worker 0x0) 12.5, Driver.Dispatch (queue worker 0x0) 12.4, Vulkan.Dispatch (queue worker 0x0) 11.9 - batch 29697: 10.3 ms at 3996 ms, present 389: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.3, Driver.Packet.dispatch (queue worker 0x0) 10.3, Driver.Dispatch (queue worker 0x0) 10.3, Vulkan.Dispatch (queue worker 0x0) 9.9 - batch 27641: 10.1 ms at 535 ms, present 372: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.1, Driver.Packet.dispatch (queue worker 0x0) 10.0, Driver.Dispatch (queue worker 0x0) 10.0, Vulkan.Dispatch (queue worker 0x0) 9.6 </details> 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`), 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" 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. Two more experiments were compiled in and turned off. `main` aborts on a storage write-back after the title without the capture experiment, so the `main` run carries that one commit too. **On the series**, two runs: ``` metric A B B-A B/A-1 B vs neighbouring A: mean +- SE (SD, n) presents/10s 93.40 90.16 -3.24 -3.5% -3.91 +- 0.92 (SD 1.59, n 3) frame ms 107.10 110.95 +3.85 +3.6% +4.63 +- 1.10 (SD 1.91, n 3) ``` ``` metric A B B-A B/A-1 B vs neighbouring A: mean +- SE (SD, n) presents/10s 95.93 92.50 -3.43 -3.6% -3.43 (n 1) frame ms 104.24 108.10 +3.87 +3.7% +3.87 (n 1) committer us/commit 105.40 108.40 +3.00 +2.8% +3.00 (n 1) ``` All four B phases were slower: this PR gives 4.2% more frames (+-1.0%). **On `main`** (`80c5e92d2d` with this PR and the capture experiment, 9 B phases): ``` metric A B B-A B/A-1 B vs neighbouring A: mean +- SE (SD, n) presents/10s 34.97 34.78 -0.19 -0.6% -0.22 +- 0.13 (SD 0.38, n 9) frame ms 285.94 287.53 +1.59 +0.6% +1.83 +- 1.07 (SD 3.22, n 9) ``` That is +0.6% (1.7 SE) on `main` alone, 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_tests` and `agc_runtime_switches_tests` on `main` `80c5e92d2d` with this PR and ran `ctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*|agc_collect_.*|agc_write_tracking.*)$'`. 67 tests pass, including all `agc_storage_*`, `agc_import_*`, `agc_collect_*` and `agc_write_tracking*` tests and `agc_copied_write_back`. 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** `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 in `markLayersPending`. The test runs once without and once with `APS5_NO_MEMO_PENDING_COLLECT`: - without the switch, the collect reuses the storage refresh's walk and does not stamp the block again; - with it, the collect walks the block again; - in both runs, the write-back leaves the CPU's block as the CPU wrote it and stores the GPU's results in the other block. It passes here, together with `agc_driver_store_over_untracked`, `agc_driver_store_pending_identity` and `agc_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=unwatch` forces compared imports on Linux. On such an import the test checks only the results. `agc_driver_memo_pending_collect_compared` runs 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: | 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 current `main`; 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 (relies on its ordering-point rule; lands after it) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 - [x] AI-assisted: yes
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!18102
No description provided.