Skip to content

perf(agc): defer small host imports until first GPU use - #7465

Merged
oneandonlydean merged 4 commits into
boykopovar:mainfrom
Dripl1x:codex/defer-small-host-imports
Oct 24, 2026
Merged

oneandonlydean merged 4 commits into
boykopovar:mainfrom
Dripl1x:codex/defer-small-host-imports

Conversation

@Dripl1x

@Dripl1x Dripl1x commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

ImportMappedRanges in Graphics/src/GuestBufferMemory.cpp, the observer that runs when a title maps memory for the GPU, imports every such range at map time (#1961). A title that maps and unmaps small ranges over and over pays a whole host import on the mapping thread at every map, and retires it at every unmap.

This PR leaves ranges of 64 KiB or less to their first GPU use:

  • ImportMappedRanges skips a mapped range of 64 KiB or less, and takes the registry lease only when a range in the batch still needs an eager import (five changed lines).
  • The first GPU use imports such a range through the existing on-demand path (HostImportFor, counted for the access requester), as before fix(agc): import GPU-mapped guest memory when it is mapped #1961; a small range the GPU never uses is never imported. As @oneandonlydean noted above, that path is the existing fallback, so the change moves when a small range is imported, not whether it can be.
  • Ranges over 64 KiB, including the pools mapped once while loading that fix(agc): import GPU-mapped guest memory when it is mapped #1961 was written for (PPSA36082), are still imported at map time.

Where it helps

  • Record of Lodoss War -Deedlit in Wonder Labyrinth- (PPSA05347), measured by @JJenkx (comment above; Linux 7.2.9, Ryzen 9 7950X, RX 6650 XT, RADV Mesa 26.2.4, this PR's same five lines merged onto main b5d763770a, order main, this PR, perf(agc): import a range mapped again on first use instead of at map #8622, perf(agc): import a range mapped again on first use instead of at map #8622, this PR, main): on main the title attempts about 1.2 million map-time imports per run and has them refused once early INVALID_EXTERNAL_HANDLE failures lower the import budget (1,252,731 and 1,183,020 refusals). With this PR, 59 refusals; the frame rate goes from 47.86 / 53.95 FPS to 59.94 / 59.94, the title's 60 FPS cap, with p99 16.7 ms in both runs. This is the PR's standalone gain. I could not reproduce it: I do not have the title.
  • SuperTuxKart (PPSA69421), menu, measured here: the menu maps about 48 blocks of 64 KiB per frame. Alone, this PR does not change its frame rate (table below): the first GPU use of each block is a label, which imports the block at that point. perf(agc): keep unimported label stores on the CPU #7464, which depends on this PR, stores those labels on the CPU; with both, the blocks are never imported and the menu runs at 25.87 / 25.99 FPS. Probe counters of 2026-10-21 (main 2185dbf92e against main with the eleven PRs of that series, which include this one; a local counter build with APS5_PROFILE_DRAW=1, not used for FPS): ImportMappedRanges 784 µs to 0.26 µs per call and sceKernelMapDirectMemory 869 µs to 23 µs per call, about 48 calls of each per frame.
Build Commit FPS, run 1 / run 2 frame p50 ms
main 94fbb8cea8 9.91 / 10.24 99.8 / 94.3
main + this PR a1cee90f52 10.29 / 10.19 94.7 / 95.6
main + this PR + #7464 223f2469f5 25.87 / 25.99 37.7 / 37.9

Tested

Update 2026-10-24. The head is now de24508db4: current main e2b9700a98 merged into this branch, with one conflict in tests/BdaResources.cpp (importAtMapOverBudgetTests: main's ClearHostImports(context.device) from #8622 is kept together with this PR's 128 KiB range, as in #7464's merge). On that head, Windows 11 Pro 26300, RTX 3070 Laptop GPU, NVIDIA 621.01: the 133 ctest entries of the set below pass; under the validation layer (same switches as below) 133/133 pass on main e2b9700a98 and on the head, neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS, and neither reports a VUID-. Linux (WSL Ubuntu 26.04, lavapipe): agc_driver_graphics, agc_driver_host_import_at_map and the 69 entries of agc_driver_recorder_tests (63 pass, the same 6 skip as below). The SuperTuxKart captures below were not repeated on this head. The rest of this section is about the previous head.

The previous head was a1cee90f52 on main 94fbb8cea8: the change (789a5f686f), its map-time import test update (e0764b9e14), and a test fixture fix (a1cee90f52). Windows 11 Pro 26300, Ryzen 7 5800H, WinLibs GCC 15.2.0 r7, Release.

  • The fixture fix. importMappedFailureGenerationTests in tests/BdaResources.cpp, added to main by fix(agc): retain map import failures across unrelated mappings #8802 after this PR's last rebase, maps one 64 KiB range and expects ImportMappedRanges to try its import; with this PR's previous head merged into current main, agc_driver_graphics failed with "the map failure fixture did not mutate an unrelated range during allocation". The fixture now maps 128 KiB as one window, which is still imported at map time. On plain main the updated test passes, and with fix(agc): retain map import failures across unrelated mappings #8802's fix reverted it fails at "an unrelated mapping during a failed import discarded its owner failure memo", so it still checks what fix(agc): retain map import failures across unrelated mappings #8802 added.
  • NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, ANYPS5_NO_SHADER_CACHE=1, three runs each: the 74 tests built from tests/Recorder.cpp, and agc_driver_graphics, agc_driver_host_import_windows, agc_driver_host_import_at_map, agc_driver_host_import_teardown, agc_driver_indirect_arguments_pending_producer, agc_driver_unimported_label_order, agc_driver_same_queue_label_wait, agc_driver_alias_copy_label, agc_driver_pipelined_dma, guest_sleep_wake, guest_sleep_wake_coarse, guest_nanosleep, precise_wait: 87/87 on this head and on main.
  • Validation layer, the same set once on main 94fbb8cea8 and on this head (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, ctest -V, RTX 3070 Laptop GPU, NVIDIA 617.42; DISABLE_LAYER=1 turns off a third-party implicit layer installed here, FPS Monitor, whose vkDestroyInstance hook crashes later instance lookups): 87/87 on both, neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS, and both report the same VUIDs the same number of times (VUID-VkImageViewCreateInfo-usage-02275 4, VUID-vkCmdCopyBuffer-srcBuffer-00118 2). The change adds none.
  • AMD Radeon(TM) Graphics (the Ryzen 7 5800H's integrated GPU, driver 31.0.21925.1001, selected with ANYPS5_GPU=AMD), the same set once and once under the validation layer: 84/87 on this head and on main. The same three tests fail on both (agc_sample_dumps, agc_driver_vertex_target_range_copied, agc_driver_vertex_target_range_imported), so they are main's; the validation logs report the same VUIDs as on NVIDIA and none new.
  • Linux (WSL Ubuntu 26.04, GCC, lavapipe llvmpipe (LLVM 21.1.8)): 71 tests of the set are registered there; 65 pass, among them agc_driver_graphics, agc_driver_host_import_windows, agc_driver_host_import_at_map and agc_driver_host_import_teardown, and 6 skip themselves with exit 77 (agc_pipeline_cache_file, agc_storage_clear_hand_over, agc_unit_shadow, agc_shadowed_key_stores, agc_driver_unit_shadow, agc_driver_unit_shadow_budget).
  • Earlier, by @savvaniss on the head 384652a52 (the same five changed lines, merged into main 07377573f): the 56 tests built from tests/Recorder.cpp and HostImportWindows.cpp pass on an Intel UHD 770 (49 pass, 7 skip without a second queue family) and an AMD RX 9070 XT; with this PR's tests on main without its change, 9 fail on both.
  • tools/check_conventions.py passes for this range.
  • Not run: the whole CTest suite, and titles other than SuperTuxKart.

SuperTuxKart captures. RTX 3070 Laptop GPU, NVIDIA 617.42, same machine and build as above; SuperTuxKart (PPSA69421) tutorial prompt over the main menu, 1920x1080 internal rendering in a maximized 2560x1369 window, warm shader caches, audio muted, no input; APS5_TRACE_SECONDS=20:8 with APS5_TRACE_EVENTS=1048576, console output not redirected, no other APS5_* switch; 2026-10-22, one session, order main, this PR, this PR + #7464 (twice; its lines are in #7464), this PR, main; every run kept the window in the foreground, and every summary line reports dirty: false and trace_dropped: false.

Summary lines (main, this PR, this PR, main)
{"commit":"94fbb8cea80a","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":38,"ms":8076.426},"presents":80,"frame_ms":{"p50":99.757,"p90":110.517,"p99":128.310,"max":128.310},"gpu_busy_ms_per_present":5.610,"worker_busy_pct":{"queue worker 0x0":2.846},"top_phases_ms_per_frame":{"Graphics.Draw":7.873,"Graphics.Draw.draw_and_resource_release":7.574,"Vulkan.DrawFromRecipe":6.254,"Graphics.DrawWithRecipe":6.229,"Graphics.DrawWithRecipe.draw_and_resource_release":6.216,"Recorder.Submit":2.908,"Driver.Packet":2.834,"Driver.Packet.draw":2.260},"trace_dropped":false,"trace":"aps5-trace-94fbb8cea80a-424.json.gz"}
{"commit":"a1cee90f52cc","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":55,"ms":8065.429},"presents":83,"frame_ms":{"p50":94.730,"p90":106.217,"p99":129.954,"max":129.954},"gpu_busy_ms_per_present":5.650,"worker_busy_pct":{"queue worker 0x0":2.889},"top_phases_ms_per_frame":{"Graphics.Draw":8.166,"Graphics.Draw.draw_and_resource_release":7.877,"Vulkan.DrawFromRecipe":6.616,"Graphics.DrawWithRecipe":6.589,"Graphics.DrawWithRecipe.draw_and_resource_release":6.576,"Recorder.Submit":2.785,"Driver.Packet":2.769,"Driver.Packet.draw":2.207},"trace_dropped":false,"trace":"aps5-trace-a1cee90f52cc-21452.json.gz"}
{"commit":"a1cee90f52cc","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":60,"ms":8047.206},"presents":82,"frame_ms":{"p50":95.592,"p90":109.603,"p99":121.282,"max":121.282},"gpu_busy_ms_per_present":5.638,"worker_busy_pct":{"queue worker 0x0":2.804},"top_phases_ms_per_frame":{"Graphics.Draw":8.185,"Graphics.Draw.draw_and_resource_release":7.900,"Vulkan.DrawFromRecipe":6.988,"Graphics.DrawWithRecipe":6.962,"Graphics.DrawWithRecipe.draw_and_resource_release":6.949,"Recorder.Submit":2.777,"Driver.Packet":2.710,"Driver.Packet.draw":2.157},"trace_dropped":false,"trace":"aps5-trace-a1cee90f52cc-30808.json.gz"}
{"commit":"94fbb8cea80a","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":60,"ms":8004.322},"presents":82,"frame_ms":{"p50":94.350,"p90":108.262,"p99":142.124,"max":142.124},"gpu_busy_ms_per_present":5.714,"worker_busy_pct":{"queue worker 0x0":2.913},"top_phases_ms_per_frame":{"Graphics.Draw":7.571,"Graphics.Draw.draw_and_resource_release":7.276,"Vulkan.DrawFromRecipe":6.235,"Graphics.DrawWithRecipe":6.207,"Graphics.DrawWithRecipe.draw_and_resource_release":6.194,"Recorder.Submit":2.886,"Driver.Packet":2.803,"Driver.Packet.draw":2.235},"trace_dropped":false,"trace":"aps5-trace-94fbb8cea80a-36604.json.gz"}
tools/performance_compare.py (first capture of main against the first capture of this PR)

**Performance comparison
**

Capture Commit Trace Presents Window (ms)
baseline 94fbb8c aps5-trace-94fbb8cea80a-424.json.gz 80 8076.426
candidate a1cee90 aps5-trace-a1cee90f52cc-21452.json.gz 83 8065.429
  • Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene.
  • Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
  • A missing top phase is unreported, not zero; its change is unavailable.
  • Recorded configuration differs; these measurements do not isolate the code change.

**Configuration differences
**

Setting Baseline Candidate
window.first_present 38 55

**Frame and GPU times (ms)
**

Metric Baseline Candidate Change Change (%)
frame_ms.p50 99.757 94.730 -5.027 -5.039
frame_ms.p90 110.517 106.217 -4.300 -3.891
frame_ms.p99 128.310 129.954 +1.644 +1.281
frame_ms.max 128.310 129.954 +1.644 +1.281
mean_frame_ms 100.955 97.174 -3.781 -3.746
gpu_busy_ms_per_present 5.610 5.650 +0.040 +0.713

**Top phases (ms per frame)
**

Metric Baseline Candidate Change Change (%)
Driver.Packet 2.834 2.769 -0.065 -2.294
Driver.Packet.draw 2.260 2.207 -0.053 -2.345
Graphics.Draw 7.873 8.166 +0.293 +3.722
Graphics.Draw.draw_and_resource_release 7.574 7.877 +0.303 +4.001
Graphics.DrawWithRecipe 6.229 6.589 +0.360 +5.779
Graphics.DrawWithRecipe.draw_and_resource_release 6.216 6.576 +0.360 +5.792
Recorder.Submit 2.908 2.785 -0.123 -4.230
Vulkan.DrawFromRecipe 6.254 6.616 +0.362 +5.788
tools/trace_digest.py (first capture of main, then of this PR; every digest is in the evidence archive)

v23-s01-main

seconds 20:8 from present 38: 80 presents, frame p50 99.8 / p90 110.5 / p99 128.3 / max 128.3 ms, GPU busy 5.6 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 94fbb8c, dropped: no

{"commit":"94fbb8cea80a","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":38,"ms":8076.426},"presents":80,"frame_ms":{"p50":99.757,"p90":110.517,"p99":128.31,"max":128.31},"gpu_busy_ms_per_present":5.61,"worker_busy_pct":{"queue worker 0x0":2.846},"top_phases_ms_per_frame":{"Graphics.Draw":7.873,"Graphics.Draw.draw_and_resource_release":7.574,"Vulkan.DrawFromRecipe":6.254,"Graphics.DrawWithRecipe":6.229,"Graphics.DrawWithRecipe.draw_and_resource_release":6.216,"Recorder.Submit":2.908,"Driver.Packet":2.834,"Driver.Packet.draw":2.26},"trace_dropped":false,"trace":"aps5-trace-94fbb8cea80a-424.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 92: 128.3 ms at 5467 ms: Driver.WorkerWait (queue worker 0x0) 124.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 124.3, Graphics.Draw (draw committer) 10.6, Graphics.Draw.draw_and_resource_release (draw committer) 10.2
  • present 85: 114.7 ms at 4705 ms: Driver.WorkerWait (queue worker 0x0) 110.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 110.7, Graphics.Draw (draw committer) 10.1, Graphics.Draw.draw_and_resource_release (draw committer) 9.7
  • present 66: 113.7 ms at 2808 ms: Driver.WorkerWait (queue worker 0x0) 109.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 109.8, Graphics.Draw (draw committer) 10.4, Graphics.Draw.draw_and_resource_release (draw committer) 10.1

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.0 (0 %) 100.9 0.4 Recorder.Sync 0.0
queue worker 0x0 2.1 (2 %) 97.8 (97 %) 1.1 3.9 Driver.Packet 2.1
draw committer 17.0 (17 %) 0.7 (1 %) 83.2 0.2 Graphics.Draw 7.9, Vulkan.DrawFromRecipe 6.3
presenter 1.0 (1 %) 0.0 (0 %) 99.9 0.1 VideoOut.Flip 1.0, Driver.Present 0.0
gpu 5.6 (6 %) 0.0 (0 %) 95.3 0.0 batch 5.6

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 97.8, Driver.WorkerWait.idle_and_completion_poll 97.7, Graphics.Draw 7.9, Graphics.Draw.draw_and_resource_release 7.6, Vulkan.DrawFromRecipe 6.3, Graphics.DrawWithRecipe 6.2

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 15.7 ms at 5475 ms, present 92
  • Driver.WorkerWait (queue worker 0x0) 11.2 ms at 5868 ms, present 95
  • Driver.WorkerWait (queue worker 0x0) 9.6 ms at 1680 ms, present 54
  • Driver.WorkerWait (queue worker 0x0) 9.2 ms at 923 ms, present 47
  • Driver.WorkerWait (queue worker 0x0) 9.1 ms at 3076 ms, present 68
  • Driver.WorkerWait (queue worker 0x0) 8.9 ms at 6084 ms, present 97

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

  • batch 4705: 1.7 ms at 8049 ms, present 117: GPU no ranges; recorded by Vulkan.DrawFromRecipe (draw committer) 0.3, Graphics.DrawWithRecipe (draw committer) 0.3, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.3, Recorder.Submit (draw committer) 0.0
  • batch 3643: 1.7 ms at 6272 ms, present 99: GPU no ranges; recorded by Vulkan.DrawFromRecipe (draw committer) 0.2, Graphics.DrawWithRecipe (draw committer) 0.2, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.2, Recorder.Submit (draw committer) 0.0
  • batch 1283: 1.7 ms at 2183 ms, present 59: GPU no ranges; recorded by Vulkan.DrawFromRecipe (draw committer) 0.1, Graphics.DrawWithRecipe (draw committer) 0.1, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.1, Recorder.Submit (draw committer) 0.0

v23-s02-7465

seconds 20:8 from present 55: 83 presents, frame p50 94.7 / p90 106.2 / p99 130.0 / max 130.0 ms, GPU busy 5.7 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit a1cee90, dropped: no

{"commit":"a1cee90f52cc","dirty":false,"env":{"APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","cpu":"AMD Ryzen 7 5800H with Radeon Graphics","cpu_threads":16,"memory_mib":64863,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":55,"ms":8065.429},"presents":83,"frame_ms":{"p50":94.73,"p90":106.217,"p99":129.954,"max":129.954},"gpu_busy_ms_per_present":5.65,"worker_busy_pct":{"queue worker 0x0":2.889},"top_phases_ms_per_frame":{"Graphics.Draw":8.166,"Graphics.Draw.draw_and_resource_release":7.877,"Vulkan.DrawFromRecipe":6.616,"Graphics.DrawWithRecipe":6.589,"Graphics.DrawWithRecipe.draw_and_resource_release":6.576,"Recorder.Submit":2.785,"Driver.Packet":2.769,"Driver.Packet.draw":2.207},"trace_dropped":false,"trace":"aps5-trace-a1cee90f52cc-21452.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 128: 130.0 ms at 7006 ms: Driver.WorkerWait (queue worker 0x0) 125.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 125.0, Graphics.Draw (draw committer) 13.4, Graphics.Draw.draw_and_resource_release (draw committer) 13.0
  • present 127: 124.1 ms at 6882 ms: Driver.WorkerWait (queue worker 0x0) 119.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 119.3, Graphics.Draw (draw committer) 12.5, Graphics.Draw.draw_and_resource_release (draw committer) 12.1
  • present 129: 122.4 ms at 7136 ms: Driver.WorkerWait (queue worker 0x0) 117.9, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 117.7, Graphics.Draw (draw committer) 12.4, Graphics.Draw.draw_and_resource_release (draw committer) 12.0

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.2 (0 %) 0.0 (0 %) 97.0 0.4 Recorder.Sync 0.2
queue worker 0x0 2.0 (2 %) 94.0 (97 %) 1.1 4.0 Driver.Packet 2.0
draw committer 17.6 (18 %) 0.6 (1 %) 79.0 0.2 Graphics.Draw 8.2, Vulkan.DrawFromRecipe 6.6
presenter 0.9 (1 %) 0.0 (0 %) 96.2 0.1 VideoOut.Flip 0.9, Driver.Present 0.0
gpu 5.7 (6 %) 0.0 (0 %) 91.5 0.0 batch 5.7

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 94.0, Driver.WorkerWait.idle_and_completion_poll 94.0, Graphics.Draw 8.2, Graphics.Draw.draw_and_resource_release 7.9, Vulkan.DrawFromRecipe 6.6, Graphics.DrawWithRecipe 6.6

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 18.2 ms at 7659 ms, present 133
  • Driver.WorkerWait (queue worker 0x0) 8.3 ms at 1529 ms, present 70
  • Driver.WorkerWait (queue worker 0x0) 6.3 ms at 5616 ms, present 114
  • Driver.WorkerWait (queue worker 0x0) 6.1 ms at 5047 ms, present 108
  • Driver.WorkerWait (queue worker 0x0) 5.7 ms at 7120 ms, present 128
  • Driver.WorkerWait (queue worker 0x0) 5.7 ms at 989 ms, present 65

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

  • batch 1637: 2.5 ms at 2655 ms, present 82: GPU no ranges; recorded by Vulkan.DrawFromRecipe (draw committer) 0.2, Graphics.DrawWithRecipe (draw committer) 0.2, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.2, Recorder.Submit (draw committer) 0.1
  • batch 4174: 1.7 ms at 6737 ms, present 125: GPU no ranges; recorded by Vulkan.DrawFromRecipe (draw committer) 0.2, Graphics.DrawWithRecipe (draw committer) 0.2, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.2, Recorder.Submit (draw committer) 0.1
  • batch 1991: 1.7 ms at 3218 ms, present 88: GPU no ranges; recorded by Vulkan.DrawFromRecipe (draw committer) 0.2, Graphics.DrawWithRecipe (draw committer) 0.2, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.2, Recorder.Submit (draw committer) 0.0

Evidence: 7465-evidence-20261022.zip (traces, summary lines, digests and comparisons, test and validation-layer logs).

Known limitations

  • The import of a small range now happens at its first GPU use, on the thread that records that use, instead of on the mapping thread. In a title whose first use is a queue-0 label (SuperTuxKart), the cost moves to that label; perf(agc): keep unimported label stores on the CPU #7464 handles that case.
  • A title that maps a small range once and uses it every frame pays the same single import as before, only later.

Dependencies and overlap

Checklist

  • Based on current main (e2b9700a98 merged in); no other open PR implements the same functions (perf(agc): lease mapped readable runs for import events #9011 above; perf(agc): import a range mapped again on first use instead of at map #8622 is in main now)
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 11 Pro 26300; AMD Radeon(TM) Graphics (Ryzen 7 5800H), 31.0.21925.1001, Windows 11 Pro 26300; lavapipe (llvmpipe, LLVM 21.1.8) on Linux
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9011 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L3674, L3677-3678
PR 9879 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp L1144-1146, L1232

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1191 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 1368 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1395 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 2434 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6187 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6188 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6192 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6209 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6628 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6820 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/HostImportWindows.cpp
PR 6971 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7048 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7201 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7604 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7618 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7844 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8484 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9521 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 9898 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10194 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp

@github-actions github-actions Bot added agc libSceAgc* perf Performance change labels Oct 18, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 19, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Dripl1x thanks, this looks correct: first-use import is the existing fallback, so deferring only drops an optimisation. The +9% rests on one capture, though. Could you repeat it interleaved (main, PR, PR, main) in the same scene, or post the count of imports avoided? Also, together with #7464, a small GPU-mapped label page would never be imported, so every label to it would wait for all recorded GPU work. We'll measure the two together if both go in.

@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: with this PR the 56 tests built from tests/Recorder.cpp and HostImportWindows.cpp pass on an Intel UHD 770 and an AMD RX 9070 XT. Without it, agc_driver_host_import_windows and 8 import-settle and host-import tests fail on both.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head 384652a52 merged into main 07377573f. "Without" means this PR's test files on main 07377573f, with none of its other changes.

Tests, ×3 UHD 770 RX 9070 XT
This head: 56 tests 49 pass, 7 import-watch and import-settle tests skip (no other queue family to settle imports on) 56 of 56 pass
Without 9 fail: agc_driver_host_import_windows (mapping did not defer exactly the small import), and with (9) a scan under a pending write was kept the 6 import-settle tests, agc_driver_host_import_lifetime and agc_driver_host_import_mutation_race 9 fail: agc_driver_host_import_windows (same message), and with a signaled batch's read still refuses (... write is not settled for settle_deferred) the same 8

This is a correctness check only; I measured no speed.

I also ran full CTest with this PR and the 13 other open AGC and shader PRs I tested in the same batch merged together (#7668, #7659, #7504, #7432, #7426, #7413, #7480, #7466, #7464, #7449, #7489, #7673, #7560). Neither GPU showed a failure beyond main's own: the five image-table tests (#6647) and agc_driver_sample_multisample_target (#6957) on the UHD 770, and agc_driver_layered_volume_vertex_no_gpl (#4768) on the RX 9070 XT.

AI-assisted: yes (Claude Code)

@JJenkx

JJenkx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

AMD/Linux data point on a second title, for this PR and #8622 side by side.

Setup

Run FPS (presents/window) frame p50 / p99 ms host imports made / refused at shutdown compilers in window
main 47.86 20.6 / 28.5 5,057 / 1,252,731 up to 7
#7465 59.94 16.7 / 16.7 133 / 59 0
#8622 56.38 17.6 / 21.5 248 / 2,575 0
#8622 55.65 17.8 / 21.2 225 / 2,580 0
#7465 59.94 16.7 / 16.7 133 / 59 up to 6
main 53.95 18.1 / 24.7 5,318 / 1,183,020 0

On main this title maps and unmaps small direct-memory ranges continuously. About 1.2 million map-time imports are attempted per run and refused, and the refusals start once early INVALID_EXTERNAL_HANDLE failures have lowered the import budget.

So on this title this PR's size gate is the larger win of the two. This is one machine and one scene, three alternated pairs.

AI-assisted: yes (Claude Code); results above were run on this machine.

Dripl1x and others added 3 commits October 22, 2026 09:35
…PU use

The import-requester test now counts the map requester on a 128 KiB range
and asserts that a 64 KiB range is not imported at map time and is imported,
for the access requester, at its first use. The over-budget map test maps
128 KiB so it still reaches the budget check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…time

importMappedFailureGenerationTests (boykopovar#8802) maps a single 64 KiB range and
expects ImportMappedRanges to try its import. Ranges of 64 KiB are now left
to their first GPU use, so the probe saw no allocation. The fixture maps
128 KiB as one window, which is still imported at map time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Dripl1x

Dripl1x commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Updated on 2026-10-22; the description is rewritten to match.

@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Protocol note on my measurement above (comment 6328228766): it does not meet the performance-report protocol's "do not redirect the log" rule. The game ran under script, which gave it a pseudo-terminal but also recorded its output to a file, and the wrapper sent stdout to a second log file. Both captures add work. The results stay as diagnostic observations, but I am withdrawing any claim of measured speed impact or direction from them until a terminal-attached rerun. The counts, logs and traces themselves are unaffected.

AI-assisted: yes (Claude Code)

@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Lodoss rerun under the performance-report protocol. It replaces my earlier Lodoss comment above, whose game output was captured to files (see my protocol note). The direction is the same.

Setup

  • Record of Lodoss War (PPSA05347), Linux 7.2.9, Ryzen 9 7950X, RX 6650 XT, RADV (Mesa 26.2.4).
  • main 94fbb8cea8 against this PR's head a1cee90f52 (based on that main). Clean Release builds.
  • Each run ran in a terminal. The game's stdout and stderr were that terminal (/dev/pts/7, checked before launch) and were not written to any file. APS5_TRACE_SECONDS=200:30, APS5_TRACE_EVENTS=1048576.
  • Identical shader-cache and save seeds copied in before every run. Scripted inputs, 280 s per run, order main, PR, PR, main.
  • Every trace reports dirty false and dropped false. The 190 s and 240 s screenshots of all four runs show the same tutorial scene (mean pixel difference ≤ 0.10 of 255 against the first run).
  • Non-default settings, identical on every run: APS5_PIPELINE_DMA, APS5_PIPELINED_DRAWS, APS5_SPIRV_OPT, APS5_HOST_IMPORT_MIB, APS5_DRAW_CACHE_ENTRIES. No other APS5_TRACE_* or APS5_PROFILE_* switch.
Run presents in 30 s / FPS frame p50 / p99 ms
main 1333 / 44.41 18.18 / 47.41
PR 1798 / 59.91 16.68 / 18.06
PR 1799 / 59.94 16.68 / 16.70
main 1491 / 49.69 19.95 / 27.39

Both PR runs hold the title's 60 FPS cap. Both main runs are below it, at 44 and 50 FPS. The sample is two runs per side on one machine.

AI-assisted: yes (Claude Code); results above were run on this machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 23, 2026
@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Composition data for this PR with #8091, measured on Lodoss under the performance-report protocol on one pinned main 94fbb8cea8: #8091 (comment)

FPS
main 43.89, 53.02
this PR (a1cee90f52) 59.94, 59.94
this PR + #8091 59.81, 59.74

#8091 alone regresses Lodoss to about 34–35 FPS on its own merge base; with this PR present it holds the cap.

AI-assisted: yes (Claude Code); results above were run on this machine.

Dripl1x added a commit to Dripl1x/AnyPS5 that referenced this pull request Oct 24, 2026
…ves guest memory alone

An unimported queue-0 label synced the recorder before its CPU store, so
every batch had finished first. Only what that work does to guest memory
can tell the two orders apart: a batch that reads guest memory in place (a
store landing first would be read), writes it (the guest would read the old
bytes after seeing the label), or has completion actions. Work that leaves
guest memory alone, such as draws from copied inputs into host-side
targets, cannot be observed by the guest before or after the label.

Recorder::UnfinishedGuestTouch reports what the open batch and the in-flight
batches whose fences have not signaled still do: in-place reads, noted
writes and labels, stores or sample dumps still to record, and completion
actions (also of signaled batches, and of batches another thread is
finishing). WriteLabelOnGpu stores the label at once (reason 7) when nothing
is reported, and syncs as before otherwise. APS5_NO_EARLY_LABELS=1 always
syncs. APS5_PROFILE_DRAW prints an [early-labels] line with the counts by
reason.

The open batch is left open and the reap of finished batches is put off:
nothing depends on either before the store. The caller submits and reaps
through SubmitAfterEarlyLabel once the label is stored, its waiters woken
and an end-of-pipe interrupt delivered; every caller that stores a reason-7
label calls it (the committer's label commit through submitDueAfterCommit).
With no completion action in any unfinished batch the reap neither changes
the import table nor what the label waits for.

Draws noted every in-place region of their resources as read, also the
regions of read-only elements that PrepareDrawBindings bound to snapshots,
which the GPU never reads in place. MarkGpuWrites now leaves out a region
that only snapshotted allocations overlap (every buffer element is a
descriptor of one allocation; a BDA build gets no draw bindings and keeps
noting every region).

SuperTuxKart (PPSA69421) main menu without the tutorial prompt (about 33
draws a frame) on Windows 11, RTX 3070 Laptop, Ryzen 7 5800H; main 9d4fb4f with boykopovar#7464 and boykopovar#9402, this commit and three other
local changes (an idle spin of the queue worker and committer, Windows
imports over 64 KiB settled at the import, import refresh spans diffed in
place); protocol runs interleaved, 3 each. With APS5_NO_EARLY_LABELS=1:
58.69 / 59.28 / 57.44 FPS, 8 / 7 / 18 present intervals over 20 ms, and
38 / 171 / 8 of about 470 frames waited for their vblank. With early
labels: 59.94 FPS in all three (the title's vblank cap), no interval over
20 ms, every frame waited for its vblank, and the longest idle gap of
queue worker 0 and the committer per frame went from 0.4 ms to 6.7-7.0 ms
(median). APS5_PROFILE_DRAW, cumulative over a run: 27090 labels stored
at once, 58 waited (42 for an in-place read, 1 for a write, 15 for
completion actions). boykopovar#7464's branch on the same main (with boykopovar#7465 under it,
without boykopovar#9402 and the other changes): 48.75-49.89 FPS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
@Dripl1x

Dripl1x commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main (e2b9700a98) into this branch to clear the conflict; the head is now de24508db4 (a merge commit, no force-push, so #7464's stack is unchanged).

  • The conflict was importAtMapOverBudgetTests in tests/BdaResources.cpp: perf(agc): import a range mapped again on first use instead of at map #8622, now in main, added ClearHostImports(context.device) there, and this PR maps 128 KiB so the range is still imported at map time. Both are kept, the same resolution perf(agc): keep unimported label stores on the CPU #7464's merge already has.
  • Tested on the new head, Windows 11 Pro 26300, RTX 3070 Laptop GPU, NVIDIA 621.01: the 133 ctest entries of the set in the description pass. Under VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 (ctest -V, DISABLE_LAYER=1 as before) the same set passes 133/133 on main e2b9700a98 and on the head; neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS (the loader inserts VkLayer_khronos_validation.dll, SDK 1.4.363), and neither reports a VUID-. Linux (WSL Ubuntu 26.04, lavapipe): agc_driver_graphics, agc_driver_host_import_at_map and the 69 entries of agc_driver_recorder_tests pass (6 of them skip, the same 6 as before).
  • Not repeated: the SuperTuxKart captures in the description are on main 94fbb8cea8, before perf(agc): import a range mapped again on first use instead of at map #8622 landed.
  • Description: added an update paragraph at the top of Tested, changed the base on the first checklist line, and added one sentence to the perf(agc): import a range mapped again on first use instead of at map #8622 bullet saying it is in main now. The rest is unchanged.

AI-assisted: yes (Claude Code).

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@oneandonlydean
oneandonlydean merged commit 9c85790 into boykopovar:main Oct 24, 2026
12 checks passed
JJenkx pushed a commit to JJenkx/AnyPS5 that referenced this pull request Oct 24, 2026
Resolve ImportMappedRanges onto the lazy lease from boykopovar#7465: ranges of
0x10000 bytes or less still take no lease, the first larger range takes
the narrow lease over the mapped runs instead of a full one, and an import
that would replace another (with the GPU mutex held) re-acquires a full
lease. The adopting path keeps its full lease for refreshImports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Alexius0815 Alexius0815 mentioned this pull request Nov 6, 2026
LeandroLP23 pushed a commit to LeandroLP23/AnyPS5 that referenced this pull request Nov 21, 2026
…ves guest memory alone

An unimported queue-0 label synced the recorder before its CPU store, so
every batch had finished first. Only what that work does to guest memory
can tell the two orders apart: a batch that reads guest memory in place (a
store landing first would be read), writes it (the guest would read the old
bytes after seeing the label), or has completion actions. Work that leaves
guest memory alone, such as draws from copied inputs into host-side
targets, cannot be observed by the guest before or after the label.

Recorder::UnfinishedGuestTouch reports what the open batch and the in-flight
batches whose fences have not signaled still do: in-place reads, noted
writes and labels, stores or sample dumps still to record, and completion
actions (also of signaled batches, and of batches another thread is
finishing). WriteLabelOnGpu stores the label at once (reason 7) when nothing
is reported, and syncs as before otherwise. APS5_NO_EARLY_LABELS=1 always
syncs. APS5_PROFILE_DRAW prints an [early-labels] line with the counts by
reason.

The open batch is left open and the reap of finished batches is put off:
nothing depends on either before the store. The caller submits and reaps
through SubmitAfterEarlyLabel once the label is stored, its waiters woken
and an end-of-pipe interrupt delivered; every caller that stores a reason-7
label calls it (the committer's label commit through submitDueAfterCommit).
With no completion action in any unfinished batch the reap neither changes
the import table nor what the label waits for.

Draws noted every in-place region of their resources as read, also the
regions of read-only elements that PrepareDrawBindings bound to snapshots,
which the GPU never reads in place. MarkGpuWrites now leaves out a region
that only snapshotted allocations overlap (every buffer element is a
descriptor of one allocation; a BDA build gets no draw bindings and keeps
noting every region).

SuperTuxKart (PPSA69421) main menu without the tutorial prompt (about 33
draws a frame) on Windows 11, RTX 3070 Laptop, Ryzen 7 5800H; main 9d4fb4f with boykopovar#7464 and boykopovar#9402, this commit and three other
local changes (an idle spin of the queue worker and committer, Windows
imports over 64 KiB settled at the import, import refresh spans diffed in
place); protocol runs interleaved, 3 each. With APS5_NO_EARLY_LABELS=1:
58.69 / 59.28 / 57.44 FPS, 8 / 7 / 18 present intervals over 20 ms, and
38 / 171 / 8 of about 470 frames waited for their vblank. With early
labels: 59.94 FPS in all three (the title's vblank cap), no interval over
20 ms, every frame waited for its vblank, and the longest idle gap of
queue worker 0 and the committer per frame went from 0.4 ms to 6.7-7.0 ms
(median). APS5_PROFILE_DRAW, cumulative over a run: 27090 labels stored
at once, 58 waited (42 for an in-place read, 1 for a write, 15 for
completion actions). boykopovar#7464's branch on the same main (with boykopovar#7465 under it,
without boykopovar#9402 and the other changes): 48.75-49.89 FPS.
Dripl1x added a commit to Dripl1x/AnyPS5 that referenced this pull request Nov 22, 2026
…ves guest memory alone

An unimported queue-0 label synced the recorder before its CPU store, so
every batch had finished first. Only what that work does to guest memory
can tell the two orders apart: a batch that reads guest memory in place (a
store landing first would be read), writes it (the guest would read the old
bytes after seeing the label), or has completion actions. Work that leaves
guest memory alone, such as draws from copied inputs into host-side
targets, cannot be observed by the guest before or after the label.

Recorder::UnfinishedGuestTouch reports what the open batch and the in-flight
batches whose fences have not signaled still do: in-place reads, noted
writes and labels, stores or sample dumps still to record, and completion
actions (also of signaled batches, and of batches another thread is
finishing). WriteLabelOnGpu stores the label at once (reason 7) when nothing
is reported, and syncs as before otherwise. APS5_NO_EARLY_LABELS=1 always
syncs. APS5_PROFILE_DRAW prints an [early-labels] line with the counts by
reason.

The open batch is left open and the reap of finished batches is put off:
nothing depends on either before the store. The caller submits and reaps
through SubmitAfterEarlyLabel once the label is stored, its waiters woken
and an end-of-pipe interrupt delivered; every caller that stores a reason-7
label calls it (the committer's label commit through submitDueAfterCommit).
With no completion action in any unfinished batch the reap neither changes
the import table nor what the label waits for.

Draws noted every in-place region of their resources as read, also the
regions of read-only elements that PrepareDrawBindings bound to snapshots,
which the GPU never reads in place. MarkGpuWrites now leaves out a region
that only snapshotted allocations overlap (every buffer element is a
descriptor of one allocation; a BDA build gets no draw bindings and keeps
noting every region).

SuperTuxKart (PPSA69421) main menu without the tutorial prompt (about 33
draws a frame) on Windows 11, RTX 3070 Laptop, Ryzen 7 5800H; main 9d4fb4f with boykopovar#7464 and boykopovar#9402, this commit and three other
local changes (an idle spin of the queue worker and committer, Windows
imports over 64 KiB settled at the import, import refresh spans diffed in
place); protocol runs interleaved, 3 each. With APS5_NO_EARLY_LABELS=1:
58.69 / 59.28 / 57.44 FPS, 8 / 7 / 18 present intervals over 20 ms, and
38 / 171 / 8 of about 470 frames waited for their vblank. With early
labels: 59.94 FPS in all three (the title's vblank cap), no interval over
20 ms, every frame waited for its vblank, and the longest idle gap of
queue worker 0 and the committer per frame went from 0.4 ms to 6.7-7.0 ms
(median). APS5_PROFILE_DRAW, cumulative over a run: 27090 labels stored
at once, 58 waited (42 for an in-place read, 1 for a write, 15 for
completion actions). boykopovar#7464's branch on the same main (with boykopovar#7465 under it,
without boykopovar#9402 and the other changes): 48.75-49.89 FPS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants