perf(agc): reuse a storage image's import segments while the mapping and import table are unchanged #18075
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18075"
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-10T09:52:03Z.
What
StorageTexture::importSegmentswalked the registered allocations and looked up a host import for every piece at each refresh of a storage image. A storage image now keeps its last result, with the guest mapping generation and the host-import table identity it was computed under. It reuses that result while both are unchanged, and touches the reused imports so their eviction order stays as before. The check and the touch happen under the imports lock, and the memo has its own mutex.APS5_NO_IMPORT_SEGMENT_MEMOturns it off, andAPS5_ABcan toggle it.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,5d9aaf02dc(now the PR head):Steady 10 s windows 3 to 7 of the movie:
main43.6 presents, this PR 44.4. 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. On5d9aaf02dc,APS5_AB=10:APS5_NO_IMPORT_SEGMENT_MEMOfrom 40 s, 11 B phases inside the movie: no difference in this scene (+0.24 +- 0.69). The gain is on the Body Type screen with the series (below), where storage images are refreshed at every draw.Recorder.Syncslices per present in the trace windows:main44.0, this PR 41.6.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
5d9aaf02dcseconds 60:10 from present 359: 44 presents, frame p50 227.2 / p90 241.4 / p99 244.4 / max 244.4 ms, GPU busy 44.8 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit
5d9aaf02dc, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 436.2, Driver.Packet.dispatch 216.4, Driver.Packet.memory_wait 196.0, Driver.Dispatch 151.5, Vulkan.Dispatch 100.9
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_IMPORT_SEGMENT_MEMO, 8 B phases):On
main(c51f4560c5with this PR and the capture experiment, 11 B phases):So the change is 3.6% on the series (7 SE) and nothing on
mainalone. Onmainthe screen runs at 2.2 fps and is limited elsewhere.Tests (Windows, RTX 5090): built
agc_driver_recorder_testsandagc_runtime_switches_testsonmainc51f4560c5with this PR and ranctest -R '^(agc_import_.*|agc_storage_.*|agc_.*_import_.*|agc_copied_write_back|agc_runtime_switches.*)$'. 48 tests pass, including allagc_storage_*andagc_import_*tests. 12 did not run here: their binaries belong to targets I didn't build, or fail to start on this machine with 0xc0000139, a DLL entry point not found. The PR is now rebased on currentmain.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)