Repository navigation
perf(agc): store an unimported label at once when unfinished work leaves guest memory alone - #24162
LeandroLP23 wants to merge 19 commits into
Conversation
…orts An import covers a run of adjacent registered allocations. When VirtualAlloc placed the temporary block right after the 128 KiB-aligned labels block, the labels import also covered the temporary block, the eight-byte label correctly went to the GPU and the case failed (4 of 12 runs in review). The temporary block is now registered between two unregistered 64 KiB guards of its own allocation, so no import made for another block can cover it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unimported label path synced the recorder: it submitted the open batch and waited for every batch in flight under the GPU mutex, running their completion actions. A compute worker must never run them (labels from other queues only submit), and the sync waited forever on a batch whose submit was held on a semaphore that only a later submission releases: agc_driver_indirect_arguments_pending_producer timed out in its argument-label case, which needs the label imported and recorded on the GPU. The path is now taken only for queue 0 while no submit is held (a hold armed for the next submit, or a held batch the GPU has not finished). Other labels import their memory and are recorded on the GPU, as on main. UnimportedLabelOrder covers a compute-queue label and a label behind a held batch, each of which must be recorded without a submit or a wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eir own The unimported path returned 1, the code of a label the CPU stores because nothing is recorded, so the [sync] line counted its labels as idle fallbacks and its stores as idle CPU stores. It now returns 7, which every caller handles as it handles 1 (the CPU writes the bytes without a device wait, and the label is noted and wakes short sleeps where 1 does), and the [sync] line counts it separately as "no covering import (recorder synced)" among the fallbacks and "on the CPU with no covering import (recorder synced)" among the stores. PipelinedDma counts these stores with the other committed ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rces Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since boykopovar#8180 a label of 8 bytes or less goes behind the completions while a copied writer is listed or a completion store is pending: a completion action stores it on the CPU when its batch is reaped, which needs no host import. The unimported check ran first and synced the recorder for such a label (reason 7), the wait boykopovar#8180 avoids. The unimported path now takes the same completion gate first (reason 5, or 2 with APS5_DRAIN_COMPLETION_LABELS=1) and syncs only when it does not apply; imported labels take it where they did. CopiedWriterLabelOrder checks the imported paths boykopovar#8180 added, so its label block is now imported before the passes (on main every label it stores gets an import); a new pass stores a label to a block that stays unimported (unregistered pages on both sides keep imports of its neighbours off it) behind a copied writer and expects reason 5, or 2 with the drain. Without the fix that pass fails with reason 7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # core/libs/prx/libSceAgcDriver/CMakeLists.txt # core/libs/prx/libSceAgcDriver/tests/execution/SameQueueLabelWait.cpp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A label whose memory no guest range covers keeps the behaviour main gives it: stored on the GPU through an import of the unregistered memory when nothing is listed or pending, otherwise drained (reason 3), also for read-only memory. Only a label in guest memory that no import covers takes the recorder-sync CPU path.
…Memory PacketMemory.cpp: the CPU store branch takes the synced unimported store (reason 7) beside main's GPU-clock COPY_DATA store (reason 3 with no store pending over the range); reason 7 counts as a synced unimported store, the others as CPU stores. SameQueueLabelWait.cpp: both sides' includes are kept.
Keep main's clock_getres entry and this branch's short sleeps entry.
# Conflicts: # core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketMemory.cpp
…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>
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 bd5ab55c5a4fdfc2598cfcdacb9ee011482a1d01 using the prepared diff and repo_read.py. No test commands were run in this environment. The author reports 18/18 targeted CTest cases passing on both builds, with two device-specific skips, plus SuperTuxKart performance measurements; these results were not independently reproduced here.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Core label and recorder paths inspected |
| Tests in this environment | not run | Author-reported results only |
| Full suite and other GPUs | not run | Not reported by author |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The review bundle includes full text for 13 of 16 changed files. VulkanDevice.cpp, ShaderResources.cpp, and tests/Recorder.cpp were excluded from the bundle as too large; relevant changed ranges in the first two were read through repo_read.py, but tests/Recorder.cpp was not read. No local tests, build, or hardware run was performed. The author reports the full CTest suite, other titles, and other GPUs were not tested.
To get this to a good state
Nothing is required.
|
@LeandroLP23 one gap in the early label check: a sampled texture built from host import copies ( The storage upload path already notes this ( if (staging != nullptr || !sources.empty()) {
...
if (!sources.empty()) recorder->NotePendingRead(descriptor.baseAddress, static_cast<std::size_t>(guestBytes), Recorder::ReadKind::StorageUpload);
}A test with an import-sourced texture and an unimported label would pin it. Separately, the perf numbers would be easier to weigh as paired runs against the scene's noise floor. |
|
Thanks, confirmed: with #7464 alone the label waited for the recorder sync, so the copy had finished; storing it early opens this. Dripl1x asked to keep the review on #10442, so I'm closing this PR. The AI-assisted: yes (Claude Code) |
What
mainon top of perf(agc): keep unimported label stores on the CPU #7464. The change is Dripl1x's commit77fe6e4d65, cherry-picked with its authorship kept. Dripl1x hasn't been active on the repository since early November and didn't answer on perf(agc): store an unimported label at once when unfinished work leaves guest memory alone #10442, so I picked it up as I offered there. perf(agc): store an unimported label at once when unfinished work leaves guest memory alone #10442 can be closed in favour of this one if it lands.Recorder::UnfinishedGuestTouch). The open batch is submitted right after the store (VulkanDevice::SubmitAfterEarlyLabel), so the label never lands before work recorded ahead of it. A draw that snapshotted its buffers no longer counts those ranges as read in place (ShaderResources::readsLeftInPlace).APS5_NO_EARLY_LABELS=1restores the wait.mainresolved while rebasing:keepRecordedDrawkeepsmain's signature and takes the draw's bindings as a last argument, passed toMarkGpuWrites.MarkGpuWrites,main'sinPlaceReadsbranch (fix(agc): rebind moved read-only buffers in place instead of snapshotting them #19131) stays first; the snapshot trimming is the branch after the split read list. Draw bindings carry noinPlaceReadsonmain(they come frominputs.inPlaceReads), so passing them changes nothing else.DrawBindingskeepsmain'sinPlace/inPlaceReadsand addssnapshotted;PrepareDrawBindingsfills it from the snapshot selection aftermain's early return.tools/pr_overlap.py: fix(agc): write back BDA stores into writable heap mirrors #12840, perf(agc): remove fixed per-draw clock reads, owner copies and allocations #16753, perf(agc): record Vulkan draw commands on an encoder thread #17943, perf(agc): record transfers in the encoder stream without waiting #18029, perf(agc): record buffer fills across several host imports on the GPU #22001, perf(agc): record a pipelined small DMA copy on the GPU behind its source's pending writes #22426, feat(agc): record graphics batches into sealed command streams #22697 and test(agc): force a copied allocation in label ordering checks #23479 touch the same lines (mostly thekeepRecordedDrawsignature inDraw.cpp); none implements the same thing.Tested
Windows 11 (10.0.26300), AMD Radeon 860M (AMD 26.10.2, LLPC), WinLibs GCC 15.2.0 r7, Release. "Base" is this branch without the last commit (
416d72bcb5:maine825fa1492+ #7464), "this PR" isbd5ab55c5a.ctest -R '^agc_driver_(recorder|graphics|unimported_label_order|same_queue_label_wait|cpu_label_wake|copied_writer_label_order|pipelined_dma|host_import_windows)' -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(layer 1.4.363): 18 of 18 pass on both builds, the layer inserted in every log, nowas not found but was requested, 0VUID-lines.agc_driver_copied_writer_label_orderand its_drainform skip on both (this device).SuperTuxKart (PPSA69421) menu through
tools/title_run.py, 2 runs of 45 s per build,APS5_PROFILE_DRAW=1, steady-state 10 s windows:[early-labels]: 16,311 and 25,781 labels stored at once per run; 2,967 and 4,674 waited because unfinished work read guest memory in place, about 144 because it wrote it.Traces (
APS5_TRACE_SECONDS=20:8 APS5_TRACE_EVENTS=1048576, one run each,title_run's frame dumps on in both),tools/trace_digest.py:Recorder.Sync26.9 ms per frame.Recorder.Syncno longer among its largest slices.base (
416d72bcb5):{"commit":"416d72bcb5d5","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon(TM) 860M Graphics","driver":"AMD proprietary driver 26.10.2 (LLPC)","os":"Windows 10.0.26300","cpu":"AMD Ryzen AI 7 350 w/ Radeon 860M","cpu_threads":16,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":140,"ms":8030.275},"presents":98,"frame_ms":{"p50":74.722,"p90":105.25,"p99":240.849,"max":240.849},"gpu_busy_ms_per_present":12.36,"worker_busy_pct":{"queue worker 0x0":4.318},"trace_dropped":false,"trace":"aps5-trace-416d72bcb5d5-3340.json.gz"}this PR (
bd5ab55c5a):{"commit":"bd5ab55c5a4f","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"20:8","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon(TM) 860M Graphics","driver":"AMD proprietary driver 26.10.2 (LLPC)","os":"Windows 10.0.26300","cpu":"AMD Ryzen AI 7 350 w/ Radeon 860M","cpu_threads":16,"title_id":"PPSA69421","title":"SuperTuxKart","content_version":"00.001.000","resolution":"1920x1080","window":{"spec":"seconds 20:8","first_present":170,"ms":8047.335},"presents":150,"frame_ms":{"p50":53.173,"p90":57.064,"p99":62.552,"max":67.355},"gpu_busy_ms_per_present":14.229,"worker_busy_pct":{"queue worker 0x0":6.37},"trace_dropped":false,"trace":"aps5-trace-bd5ab55c5a4f-9588.json.gz"}Not run: the whole CTest suite, other titles, other GPUs.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)