Skip to content

perf(agc): keep unimported label stores on the CPU - #7464

Merged
oneandonlydean merged 17 commits into
boykopovar:mainfrom
Dripl1x:codex/cpu-unimported-labels
Nov 21, 2026
Merged

oneandonlydean merged 17 commits into
boykopovar:mainfrom
Dripl1x:codex/cpu-unimported-labels

Conversation

@Dripl1x

@Dripl1x Dripl1x commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Store a queue-0 label on the CPU after a recorder sync when no host import covers its destination, instead of importing the destination's allocation for the label. VulkanDevice::WriteLabelOnGpu takes that path only for queue 0 and only while no submit is held (Recorder::SubmitHeld()); it returns a new code 7, which every caller (commitLabel in PacketMemory.cpp, recordDeferredLabels in DeferredLabels.cpp) handles like code 1: a CPU store without a device drain. Labels on compute queues, labels behind a held submit and labels whose memory an import already covers keep main's path (import on demand, store recorded on the GPU). The [sync] profile line counts the new path on its own: no covering import (recorder synced) among the fallbacks and on the CPU with no covering import (recorder synced) among the stores (SynchronizationStatistics).

A label the driver stores from the CPU (commitLabel, recordDeferredLabels) also ends short guest sleeps (#6658), as a completed GPU batch or a flip already does.

Why it depends on #7465. On main a small block is imported when the title maps it, so its labels find a covering import and this path does not run. #7465 leaves mappings of 64 KiB or less unimported until their first GPU use. In SuperTuxKart (PPSA69421) that first use is a label, so with #7465 alone each of the blocks the menu maps every frame is imported by its first label instead, and the frame rate stays at main's. With this PR on top, those labels are stored on the CPU after a recorder sync and the blocks are not imported at all:

Build Commit FPS, run 1 / run 2 frame p50 ms
main 94fbb8cea8 9.91 / 10.24 99.8 / 94.3
main + #7465 a1cee90f52 10.29 / 10.19 94.7 / 95.6
main + #7465 + this PR 223f2469f5 25.87 / 25.99 37.7 / 37.9

The cost of the path is visible in the same traces: Recorder.Sync takes 12.0 ms per frame on the draw committer, which #7465 alone does not show, and the frame still drops from 94.7 to 37.7 ms (p50).

Tested

This head is 223f2469f5: current main 94fbb8cea8, #7465's head a1cee90f52, and this PR's five commits on top, picked without conflicts and unchanged from the previous head b31bc845fb. Windows 11 Pro 26300, Ryzen 7 5800H, WinLibs GCC 15.2.0 r7, Release.

  • 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_indirect_arguments_pending_producer, agc_driver_unimported_label_order, agc_driver_cpu_label_wake, agc_driver_same_queue_label_wait, agc_driver_alias_copy_label, agc_driver_pipelined_dma, agc_driver_graphics, agc_driver_host_import_windows, agc_driver_host_import_at_map, agc_driver_host_import_teardown, guest_sleep_wake, guest_sleep_wake_coarse, guest_nanosleep, precise_wait. 88/88 on this head; 87/87 on main and on perf(agc): defer small host imports until first GPU use #7465 (agc_driver_cpu_label_wake is added here).
  • 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 and 88/88 pass, 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: 85/88 on this head, 84/87 on main and on perf(agc): defer small host imports until first GPU use #7465. The same three tests fail on all three trees (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)): libSceAgcDriver builds; agc_driver_unimported_label_order, agc_driver_cpu_label_wake, agc_driver_same_queue_label_wait, agc_driver_indirect_arguments_pending_producer, guest_sleep_wake and agc_driver_host_import_windows pass.
  • Negative controls, on the previous head b31bc845fb with the same source: without the queue-0 gate the compute-queue case fails with reason 7; with SubmitHeld() ignoring a held batch still in flight the held-batch case fails after its 5 s watchdog; without the two wake calls agc_driver_cpu_label_wake fails.
  • 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, #7465, this PR, this PR, #7465, main; every run kept the window in the foreground, and every summary line reports dirty: false and trace_dropped: false.

Summary lines (main, #7465, this PR, this PR, #7465, 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":"223f2469f5b7","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":131,"ms":8002.835},"presents":207,"frame_ms":{"p50":37.675,"p90":42.179,"p99":54.788,"max":57.409},"gpu_busy_ms_per_present":4.721,"worker_busy_pct":{"queue worker 0x0":5.801},"top_phases_ms_per_frame":{"Recorder.Sync":11.955,"Graphics.Draw":6.348,"Graphics.Draw.draw_and_resource_release":6.104,"Vulkan.DrawFromRecipe":5.275,"Graphics.DrawWithRecipe":5.255,"Graphics.DrawWithRecipe.draw_and_resource_release":5.243,"Recorder.Submit":2.463,"Driver.Packet":2.212},"trace_dropped":false,"trace":"aps5-trace-223f2469f5b7-7524.json.gz"}
{"commit":"223f2469f5b7","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":136,"ms":8002.542},"presents":208,"frame_ms":{"p50":37.925,"p90":41.354,"p99":46.729,"max":49.249},"gpu_busy_ms_per_present":4.706,"worker_busy_pct":{"queue worker 0x0":5.815},"top_phases_ms_per_frame":{"Recorder.Sync":11.984,"Graphics.Draw":6.381,"Graphics.Draw.draw_and_resource_release":6.138,"Vulkan.DrawFromRecipe":5.259,"Graphics.DrawWithRecipe":5.238,"Graphics.DrawWithRecipe.draw_and_resource_release":5.227,"Recorder.Submit":2.455,"Driver.Packet":2.205},"trace_dropped":false,"trace":"aps5-trace-223f2469f5b7-36088.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 #7465 against the first capture of this PR)

**Performance comparison
**

Capture Commit Trace Presents Window (ms)
baseline a1cee90 aps5-trace-a1cee90f52cc-21452.json.gz 83 8065.429
candidate 223f246 aps5-trace-223f2469f5b7-7524.json.gz 207 8002.835
  • 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 55 131

**Frame and GPU times (ms)
**

Metric Baseline Candidate Change Change (%)
frame_ms.p50 94.730 37.675 -57.055 -60.229
frame_ms.p90 106.217 42.179 -64.038 -60.290
frame_ms.p99 129.954 54.788 -75.166 -57.840
frame_ms.max 129.954 57.409 -72.545 -55.824
mean_frame_ms 97.174 38.661 -58.513 -60.215
gpu_busy_ms_per_present 5.650 4.721 -0.929 -16.442

**Top phases (ms per frame)
**

Metric Baseline Candidate Change Change (%)
Driver.Packet 2.769 2.212 -0.557 -20.116
Driver.Packet.draw 2.207 n/a n/a n/a
Graphics.Draw 8.166 6.348 -1.818 -22.263
Graphics.Draw.draw_and_resource_release 7.877 6.104 -1.773 -22.509
Graphics.DrawWithRecipe 6.589 5.255 -1.334 -20.246
Graphics.DrawWithRecipe.draw_and_resource_release 6.576 5.243 -1.333 -20.271
Recorder.Submit 2.785 2.463 -0.322 -11.562
Recorder.Sync n/a 11.955 n/a n/a
Vulkan.DrawFromRecipe 6.616 5.275 -1.341 -20.269
tools/trace_digest.py (first capture of #7465, then of this PR; every digest is in the evidence archive)

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

v23-s03-pair

seconds 20:8 from present 131: 207 presents, frame p50 37.7 / p90 42.2 / p99 54.8 / max 57.4 ms, GPU busy 4.7 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 1920x1080, commit 223f246, dropped: no

{"commit":"223f2469f5b7","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":131,"ms":8002.835},"presents":207,"frame_ms":{"p50":37.675,"p90":42.179,"p99":54.788,"max":57.409},"gpu_busy_ms_per_present":4.721,"worker_busy_pct":{"queue worker 0x0":5.801},"top_phases_ms_per_frame":{"Recorder.Sync":11.955,"Graphics.Draw":6.348,"Graphics.Draw.draw_and_resource_release":6.104,"Vulkan.DrawFromRecipe":5.275,"Graphics.DrawWithRecipe":5.255,"Graphics.DrawWithRecipe.draw_and_resource_release":5.243,"Recorder.Submit":2.463,"Driver.Packet":2.212},"trace_dropped":false,"trace":"aps5-trace-223f2469f5b7-7524.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 139: 57.4 ms at 399 ms: Driver.WorkerWait (queue worker 0x0) 53.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 53.3, Recorder.Sync (draw committer) 16.0, Graphics.Draw (draw committer) 11.6
  • present 131: 57.2 ms at 0 ms: Driver.WorkerWait (queue worker 0x0) 53.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 53.4, Recorder.Sync (draw committer) 14.2, Vulkan.DrawFromRecipe (draw committer) 12.0
  • present 136: 54.8 ms at 254 ms: Driver.WorkerWait (queue worker 0x0) 51.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 51.1, Recorder.Sync (draw committer) 15.9, Vulkan.DrawFromRecipe (draw committer) 9.8

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 1.4 (4 %) 36.1 (93 %) 1.1 3.9 Driver.Packet 1.4, Shader.DrawStage 0.0
draw committer 23.6 (61 %) 0.7 (2 %) 14.4 0.1 Recorder.Sync 12.0, Graphics.Draw 6.3
presenter 0.9 (2 %) 0.0 (0 %) 37.7 0.1 VideoOut.Flip 0.9, Driver.Present 0.0
gpu 4.7 (12 %) 0.0 (0 %) 33.9 0.0 batch 4.7

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 36.1, Driver.WorkerWait.idle_and_completion_poll 36.1, Recorder.Sync 12.0, Graphics.Draw 6.3, Graphics.Draw.draw_and_resource_release 6.1, Vulkan.DrawFromRecipe 5.3

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 3.5 ms at 145 ms, present 133
  • Driver.WorkerWait (queue worker 0x0) 2.9 ms at 897 ms, present 150
  • Driver.WorkerWait (queue worker 0x0) 2.9 ms at 233 ms, present 135
  • Driver.WorkerWait (queue worker 0x0) 2.9 ms at 196 ms, present 134
  • Driver.WorkerWait (queue worker 0x0) 2.8 ms at 4073 ms, present 233
  • Driver.WorkerWait (queue worker 0x0) 2.8 ms at 774 ms, present 147

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

  • batch 1155: 2.5 ms at 897 ms, present 150: GPU no ranges; recorded by Recorder.Sync (draw committer) 2.6, Vulkan.DrawFromRecipe (draw committer) 0.0, Graphics.DrawWithRecipe (draw committer) 0.0, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.0
  • batch 270: 2.4 ms at 233 ms, present 135: GPU no ranges; recorded by Recorder.Sync (draw committer) 2.5, Vulkan.DrawFromRecipe (draw committer) 0.0, Graphics.DrawWithRecipe (draw committer) 0.0, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.0
  • batch 978: 2.4 ms at 774 ms, present 147: GPU no ranges; recorded by Recorder.Sync (draw committer) 2.5, Vulkan.DrawFromRecipe (draw committer) 0.0, Graphics.DrawWithRecipe (draw committer) 0.0, Graphics.DrawWithRecipe.draw_and_resource_release (draw committer) 0.0

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

Where it helps, and what it costs

Probe counters from 2026-10-21, on main 2185dbf92e with a local counter build that is not part of this PR (APS5_PROFILE_DRAW=1, medians of two runs per flip over the same 8-s window; they carry profiling overhead and are not used for FPS), in the scene above: the menu maps about 48 blocks of 64 KiB per frame and writes about 59 labels into them. main imports each block when it is mapped (48.5 imports per frame, ImportMappedRanges 784 µs per call). In a build of main with the eleven PRs of that series, which include #7465 and this one, no block is imported (0 per frame) and the labels take this path instead: 58.9 recorder syncs per frame, WriteLabelOnGpu 194 µs per call. With this PR reduced to its wake calls in the same build, 47.8 imports per frame come back, every one made by a label (WriteLabelOnGpu 696 µs per call).

@LeandroLP23 measured the same path in a SuperTuxKart race on a Radeon 860M (comment above): it is the largest cost left there (Recorder.Sync 41 ms of a ~96 ms frame), and the two alternatives he tried, importing the label pages and deferring the store to the batch reap, were slower (5.4 and 0.7 FPS against 10.5).

Known limitations.

Dependencies and overlap

Checklist

  • Based on current main 94fbb8cea8 through perf(agc): defer small host imports until first GPU use #7465 a1cee90f52; 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: perf(agc): defer small host imports until first GPU use #7465
  • 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 22426 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Synchronization/SynchronizationStatistics.hpp L33
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/SynchronizationStatistics.cpp L24, L42
PR 23479 core/libs/prx/libSceAgcDriver/tests/execution/CopiedWriterLabelOrder.cpp L49, L75-76

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 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4847 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6936 docs/dev/debt/libkernel.md
PR 7002 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libkernel.md
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_same_queue_label_wait_tests.cmake
PR 7643 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8605 docs/dev/debt/libkernel.md
PR 9156 docs/dev/debt/libkernel.md
PR 9293 docs/dev/debt/libkernel.md
PR 9297 docs/dev/debt/libkernel.md
PR 9302 docs/dev/debt/libkernel.md
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9389 docs/dev/debt/libkernel.md
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_same_queue_label_wait_tests.cmake
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9938 docs/dev/debt/libkernel.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_same_queue_label_wait_tests.cmake
PR 10351 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10652 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11215 docs/dev/debt/libkernel.md
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 11483 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11628 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libkernel.md
PR 11896 docs/dev/debt/libkernel.md
PR 12682 docs/dev/debt/libkernel.md
PR 12688 docs/dev/debt/libkernel.md
PR 12700 docs/dev/debt/libkernel.md
PR 12828 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12840 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12965 docs/dev/debt/libkernel.md
PR 13148 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/execution/CopiedWriterLabelOrder.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/execution/CopiedWriterLabelOrder.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_same_queue_label_wait_tests.cmake
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_same_queue_label_wait_tests.cmake
PR 14217 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 14871 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 15037 docs/dev/debt/libkernel.md
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/DeferredLabels.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 15343 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 15548 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 15845 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Synchronization/SynchronizationStatistics.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/DeferredLabels.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/SynchronizationStatistics.cpp
PR 16571 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16790 docs/dev/debt/libkernel.md
PR 16831 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 17611 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 17943 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 18029 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 18082 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18173 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 18457 docs/dev/debt/libkernel.md
PR 19697 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 20030 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20111 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20172 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/DeferredLabels.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/SynchronizationStatistics.cpp
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/execution/CopiedWriterLabelOrder.cpp
PR 20187 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20248 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 20519 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21708 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22025 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22071 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22190 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 22424 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 22692 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22697 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 22787 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 23243 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 23244 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

@github-actions github-actions Bot added libkernel build docs prx agc libSceAgc* needs rebase Conflicts with main, rebase needed labels Oct 18, 2026
@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main (both commits, authorship unchanged). One docs-debt conflict, unioned.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the two known main regressions (agc_driver_tessellation — Mesa, #5444; agc_driver_bda_device — #7584), neither from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7464
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is fdf2b016d.

@blawesom

Copy link
Copy Markdown
Contributor

Correction: the first push missed a required ENVIRONMENT.md row for APS5_NO_SLEEP_WAKE (the conventions check reads the commit, not the working tree — the row is now amended in). Head is now f7e0a81c2; conventions pass.

@Dripl1x
Dripl1x force-pushed the codex/cpu-unimported-labels branch from ca7b45b to aa92e2c Compare October 18, 2026 18:28
@Dripl1x

Dripl1x commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the rebase handoff, Linux validation, and the follow-up ENVIRONMENT.md row. Picked up your corrected handoff and rebased it onto main e1dae23; published head is aa92e2c. Both sides of the debt-doc conflict are retained, and I clarified that APS5_NO_SLEEP_WAKE disables early wakeups. The six focused Windows Release checks pass, including unimported-label ordering, CPU wake, same-queue waits, and the sleep checks. A matched SuperTuxKart A-B-B-A repeat with only libSceAgcDriver.prx differing gives 11.945 FPS for the exact #6658 control and 11.900 FPS for this topic (-0.045 FPS); the description now reports the individual captures and their limits instead of using the combined series to justify this topic. Logs, manifests and raw traces: https://github.com/Dripl1x/AnyPS5/releases/download/performance-series-20261018/review-rebase-20261018.zip

@github-actions github-actions Bot added perf Performance change perf numbers missing perf pull request without a before and after summary line and removed needs rebase Conflicts with main, rebase needed perf numbers missing perf pull request without a before and after summary line labels Oct 18, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 19, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Dripl1x thanks. The ordering is right. Three things before this can merge:

  1. Main imports an unimported label store once and then frees later GPU label stores; this PR syncs the recorder on every label in unimported memory instead, and its own A/B is -0.38%. Could you post the [sync] profile line from main and from this PR in the measured scene, with the new stall counted separately: how many labels per frame take the Sync path, and how many imports does it avoid?
  2. Please give "unimported, synced" its own return code or counter, so it isn't counted as idle in that line.
  3. The first commit carries perf(libkernel): end short sleeps when the GPU or a flip completes #6658. Once perf(libkernel): end short sleeps when the GPU or a flip completes #6658 merges, please rebase and drop the duplicate APS5_NO_SLEEP_WAKE row.

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

NVIDIA Linux run with the Khronos validation layer of the current head 4e2ae4323e; the NVIDIA runs in Tested are on Windows and Linux only ran on lavapipe.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 4e2ae4323e merged onto main 40206fe50d with --no-ff (clean, as 718888f589). Main baseline is a Release build of 40206fe50d on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_driver_(indirect_arguments_pending_producer|unimported_label_order|cpu_label_wake|same_queue_label_wait|alias_copy_label|pipelined_dma|host_import_at_map|host_import_teardown|copied_writer_label_order)|^agc_driver_graphics$' -V
main 40206fe50d this PR
Result 16 of 16 passed 17 of 17 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 18 19
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

The pattern is the Linux-runnable agc_driver_* tests from Tested plus the copied_writer_label_order tests the PR changes; the _draw_pipeline and _plan_verify variants match too. agc_driver_host_import_windows is Windows-only and the CPU-only guest_sleep_wake, guest_sleep_wake_coarse, guest_nanosleep and precise_wait are left out. agc_driver_cpu_label_wake is added by this PR and does not exist on main; that is the 17th test. All tests that open a device selected the RTX 4090. The [sync] profile and the SuperTuxKart speed claim were not measured here, and there is no negative control in this run (Tested lists the author's).

No new VUID- errors; all 17 focused tests pass on Ada, 16 of 16 on main.

AI-assisted: yes (Claude Code)

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head 4e2ae4323ec03c14485b1183887511b8876eb812 from the prepared diff and the pinned repository source using repo_read.py. No tests or build commands were run; the test results in the PR description are author reported.

Results

Check Result Note
Changed code review passed Inspected all changed files
Build and tests not run Results supplied by author only
Negative control not run Not independently repeated

Findings

Blocking

None.

Non-blocking

  • Recorder::SubmitHeld() deliberately stops gating unimported-label sync once the held batch signals. Consider a focused regression test for a held submit that completes before a later label arrives, since the new helper’s in-flight transition is central to the queue-wait safety condition (core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp:4681).

Not verified

The full CTest suite, console behavior beyond the reported SuperTuxKart run, and author reported build/test results were not independently verified. Read the prepared description, commits, manifest and diff; inspected all changed source and test files, including the full relevant VulkanDevice.cpp function. files.json reports no excluded changed files.

To get this to a good state

Nothing is required. The optional regression-test suggestion above can be considered for follow-up.

@LeandroLP23

Copy link
Copy Markdown
Contributor

An AMD Windows data point, since the runs above are on NVIDIA: SuperTuxKart (PPSA69421) on an AMD Radeon 860M (AMD 26.10.2, LLPC), Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release, main 74f685158e and this head 4e2ae4323e merged onto it (clean), tools/title_run.py with 2 runs of 45 s each and APS5_PROFILE_DRAW=1. Steady-state 10 s windows (the first, loading window left out):

build presents per 10 s frame p50
main 56–72 131–161 ms
this PR 133–149 63–66 ms

So about twice the frame rate on this iGPU too. Both builds ran with title_run's frame dumps (every 30 frames, scale 8), so the absolute numbers are lower than without them.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 20, 2026
Dripl1x added a commit to Dripl1x/AnyPS5 that referenced this pull request Nov 20, 2026
…mport

A Windows import of private memory under 1 MiB was compared until its
deferred settle, and the deferred return to the write watch is skipped
while a live storage image overlaps the range (the rewatch stamps it as
a CPU store, which the image would take as a write over its results).
SuperTuxKart views its small textures (96 KiB to 352 KiB) from storage
images, so they stayed compared for good and every draw sampling one
took the full revalidation walk with a byte compare.

Imports larger than one 64 KiB block now settle at the import, as the
1 MiB ones did, and stay in the write watch; 64 KiB imports, the size a
title maps around every submission, keep the deferred settle. The cost
moves to the import: each new private import from 128 KiB up to 1 MiB
waits for its settle read (the [buffers] line's "settled inside their
window" counts them). APS5_SETTLE_FLOOR_KIB sets the floor (1024
restores the old one), and the retire test, which needs a 128 KiB
import on the deferred path, sets it so.

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, boykopovar#9402 and three local changes (early
unimported labels, an idle spin of the queue worker and committer, import
refresh spans diffed in place) plus this one; protocol runs interleaved.
With APS5_SETTLE_FLOOR_KIB=1024: 59.94 / 59.94 FPS (a third run lost the
window focus and is left out), the same as with this change at the
title's vblank cap, and the longest idle gap of queue worker 0 and the
committer per frame 5.9 and 6.2 ms (median) against 6.7-7.0 ms. On an
earlier stack (main a0900b9 with boykopovar#7464, boykopovar#9402, two local direct-memory
changes and the other three changes named above; the menu with the tutorial
prompt, about 59 draws a frame), APS5_PROFILE_DRAW over
10 s with the old floor against this one:
revalidations 33583 in 1339 ms with 19435 full walks (19355 for a failed
collect) against 18287 in 315 ms with 204 (audits only), a draw recorded
in 104 us against 82, and dumped menu frames 0 to 6 of both matched within
a mean difference of 0.001.


Rebased onto main as one commit from 90b9574, 63e9ee1 and 17cee29; the initial DCC committer test added on main since gets the same 1 MiB floor as the initial DCC test.
@M4gnif1cus

Copy link
Copy Markdown

A data point from a title the runs above don't cover: Godot 4.7.2 for PS5 (PPSA99847, bring-up thread #24732), running its built-in Pong. It renders through its own Mesa build on AGC.

Build Run A, [present] per 10 s Run B, [present] per 10 s Mean
main 335fdd7 271, 283, 281, 281, 275 267, 272, 274, 273, 276 27.5 fps
main 335fdd7 + this PR (4e2ae43, git merge --no-ff, no conflicts) 328, 327, 325, 327, 322 321, 321, 322, 330, 329 32.5 fps

Order was main, PR, main, PR; 70 s each, first 10 s window dropped, warm shader caches, no input, same scene (the idle Pong court with the ball in play). No exception or crash in either build.

Not changed by this PR: the title still does about three full-frame write-backs per presented frame in both builds ([storage] ... write-backs by reason: label 825/6525.9 on main, label 965/7633.3 with the PR, over 10 s). The author reports 60 FPS for this scene on a PS5 on firmware 5.10, so the title stays well below the console either way.

  • Host: Intel Core Ultra 9 275HX, Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 5070 Ti Laptop GPU (driver 621.14), on AC, WinLibs GCC 15.2.0 r7, Release.
  • Conversion and environment are in Godot PS5 (PPSA99847) #24732.

Protocol note: this does not follow the performance-report protocol. The numbers are [present] lines from a redirected log, not tools/trace_digest.py summaries. I can repeat it with APS5_TRACE_SUMMARY_EVERY if that is more useful.

The runs were driven with an AI assistant; the table is measured log output.

@oneandonlydean
oneandonlydean merged commit a38eebd into boykopovar:main Nov 21, 2026
14 checks passed
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.
oneandonlydean pushed a commit that referenced this pull request Nov 25, 2026
… window

A queue-0 label whose memory no import covers synced the recorder and was
stored on the CPU (#7464). That is cheap for the small blocks it was made
for, which the title maps every frame, but a label in a large allocation
that the import budget refuses waits for every batch in flight each time.
In Cult of the Lamb (PPSA06465) on a Renoir APU, whose import budget is
586 MiB, the labels land in 16 MiB allocations and the sync costs about
60 ms per frame in gameplay.

Such a label now requests a 64 KiB window of its allocation (Label
requester) and is recorded on the GPU when the window imports. An
allocation no larger than the window keeps the CPU path, so the small
blocks of #7464 are still not imported.
oneandonlydean pushed a commit that referenced this pull request Nov 25, 2026
A label in a 64 KiB allocation must still return reason 7 without making
an import, as #7464 requires for the small blocks titles map per frame.
JJenkx added a commit to JJenkx/AnyPS5 that referenced this pull request Nov 26, 2026
… flips

A queue-0 label whose guest memory no host import covers stores on the
CPU after a recorder sync (boykopovar#7464), because importing a small mapping
for its first label cost an import per frame in a title that maps and
unmaps its label block every frame. A title that keeps its label block
mapped pays that sync on every label instead: Absolum (PPSA28311)
labels three long-lived 64 KiB blocks and spends about half of each
10 s in those syncs in its campfire scene.

The label path now remembers, per allocation, the backing serial and
the flip of the first label it saw. Once the same mapping (same backing
serial) is labelled again three or more flips later, the label imports
its memory and is recorded on the GPU, as a compute-queue label already
is. A new mapping, including one at a reused address, starts over and
takes the CPU path for its first three flips.

StorageTexture::FlipSerial exposes the flip count NoteFlip keeps.
agc_driver_unimported_label_order checks that the first label of a new
mapping still syncs, that a later label of the same mapping three flips
on imports and lands, and that another new mapping still syncs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JJenkx added a commit to JJenkx/AnyPS5 that referenced this pull request Nov 27, 2026
… flips

A queue-0 label whose guest memory no host import covers stores on the
CPU after a recorder sync (boykopovar#7464), because importing a small mapping
for its first label cost an import per frame in a title that maps and
unmaps its label block every frame. A title that keeps its label block
mapped pays that sync on every label instead: Absolum (PPSA28311)
labels three long-lived 64 KiB blocks and spends about half of each
10 s in those syncs in its campfire scene.

The label path now remembers, per allocation, the backing serial and
the flip of the first label it saw. Once the same mapping (same backing
serial) is labelled again three or more flips later, the label imports
its memory and is recorded on the GPU, as a compute-queue label already
is. A new mapping, including one at a reused address, starts over and
takes the CPU path for its first three flips.

StorageTexture::FlipSerial exposes the flip count NoteFlip keeps.
agc_driver_unimported_label_order checks that the first label of a new
mapping still syncs, that a later label of the same mapping three flips
on imports and lands, and that another new mapping still syncs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.