Repository navigation
perf(agc): keep unimported label stores on the CPU - #7464
Conversation
ade8325 to
ca7b45b
Compare
|
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.
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.
|
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, To pick it up: Head is |
|
Correction: the first push missed a required |
ca7b45b to
aa92e2c
Compare
|
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 |
|
@Dripl1x thanks. The ordering is right. Three things before this can merge:
|
|
NVIDIA Linux run with the Khronos validation layer of the current head Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
The pattern is the Linux-runnable No new AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
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.
|
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,
So about twice the frame rate on this iGPU too. Both builds ran with AI-assisted: yes (Claude Code) |
…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.
|
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.
Order was Not changed by this PR: the title still does about three full-frame write-backs per presented frame in both builds (
Protocol note: this does not follow the performance-report protocol. The numbers are The runs were driven with an AI assistant; the table is measured log output. |
…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.
…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.
… 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.
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.
… 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>
… 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>
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::WriteLabelOnGputakes that path only for queue 0 and only while no submit is held (Recorder::SubmitHeld()); it returns a new code 7, which every caller (commitLabelinPacketMemory.cpp,recordDeferredLabelsinDeferredLabels.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 keepmain'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 andon 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
maina 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 atmain'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:main94fbb8cea8main+ #7465a1cee90f52main+ #7465 + this PR223f2469f5The cost of the path is visible in the same traces:
Recorder.Synctakes 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: currentmain94fbb8cea8, #7465's heada1cee90f52, and this PR's five commits on top, picked without conflicts and unchanged from the previous headb31bc845fb. Windows 11 Pro 26300, Ryzen 7 5800H, WinLibs GCC 15.2.0 r7, Release.ANYPS5_NO_SHADER_CACHE=1, three runs each: the 74 tests built fromtests/Recorder.cpp, andagc_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 onmainand on perf(agc): defer small host imports until first GPU use #7465 (agc_driver_cpu_label_wakeis added here).main94fbb8cea8and 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=1turns off a third-party implicit layer installed here, FPS Monitor, whosevkDestroyInstancehook crashes later instance lookups): 87/87 and 88/88 pass, neither log reportswas 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-022754,VUID-vkCmdCopyBuffer-srcBuffer-001182). The change adds none.ANYPS5_GPU=AMD), the same set once and once under the validation layer: 85/88 on this head, 84/87 onmainand 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 aremain's; the validation logs report the same VUIDs as on NVIDIA and none new.llvmpipe (LLVM 21.1.8)):libSceAgcDriverbuilds;agc_driver_unimported_label_order,agc_driver_cpu_label_wake,agc_driver_same_queue_label_wait,agc_driver_indirect_arguments_pending_producer,guest_sleep_wakeandagc_driver_host_import_windowspass.b31bc845fbwith the same source: without the queue-0 gate the compute-queue case fails with reason 7; withSubmitHeld()ignoring a held batch still in flight the held-batch case fails after its 5 s watchdog; without the two wake callsagc_driver_cpu_label_wakefails.tools/check_conventions.pypasses for this range.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:8withAPS5_TRACE_EVENTS=1048576, console output not redirected, no otherAPS5_*switch; 2026-10-22, one session, ordermain, #7465, this PR, this PR, #7465,main; every run kept the window in the foreground, and every summary line reportsdirty: falseandtrace_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
**
**Configuration differences
**
**Frame and GPU times (ms)
**
**Top phases (ms per frame)
**
tools/trace_digest.py(first capture of #7465, then of this PR; every digest is in the evidence archive)v23-s02-7465seconds 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)
Threads (ms per frame)
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
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
v23-s03-pairseconds 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)
Threads (ms per frame)
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
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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
main2185dbf92ewith 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.mainimports each block when it is mapped (48.5 imports per frame,ImportMappedRanges784 µs per call). In a build ofmainwith 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,WriteLabelOnGpu194 µ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 (WriteLabelOnGpu696 µ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.Sync41 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.
main's path.Dependencies and overlap
COPY_DATAstores) changes the same} else if (reason == 1) {line ofpreparePacketMemoryinPacketMemory.cppthat this PR extends with code 7, and fix(shader): validate and optimize SPIR-V on a host thread when the stack is short #9495 inserts lines after the sameagc_driver_gpu_map_on_fiber_testsline oflibSceAgcDriver/CMakeLists.txtas this PR's test registration. Both conflict with this head textually; neither implements the same thing.WriteLabelOnGpu(small labels behind copied write-backs) and merges cleanly with this head.Checklist
main94fbb8cea8through perf(agc): defer small host imports until first GPU use #7465a1cee90f52; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code