perf(agc): import a labelled guest mapping once it has outlived three flips #26384
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26384"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-23T22:04:45Z.
What
Since #7464 a queue-0 label whose guest memory no host import covers is stored on the CPU after
recorder.Sync()(WriteLabelOnGpureason 7), instead of importing the memory for the label. #7465 leaves mappings of 64 KiB or less unimported until their first GPU use, and #7464 measured that importing such a block for its label cost SuperTuxKart (PPSA69421) an import per frame, because it maps and unmaps its label block every frame (#25912).A title that keeps its label block mapped pays the sync on every label instead. Absolum (PPSA28311) writes labels into three 64 KiB guest allocations that stay mapped for the whole run and that nothing else imports. Private timers in
Driver::commitLabelandVulkanDevice::WriteLabelOnGpu(diagnostic builds, not part of this PR) in its campfire scene, per 10 s:WriteLabelOnGpureturnedrecorder.Sync()and a CPU storeThis PR keeps #7464's path for a mapping's first labels and imports a mapping that is clearly long-lived:
LabelMappingSettledremembers, per allocation, the backing serial and the flip (StorageTexture::FlipSerial(), the countNoteFlipalready keeps) of the first label it saw.HostImportFor) and is recorded on the GPU, as a compute-queue label already is. Every other case takes reason 7 as before.GuestAllocationsassigns one on insert, also at a reused address), so a block mapped and unmapped every frame never reaches three flips and keeps today's behaviour.The table is bounded (cleared at 4,096 allocations) and guarded by its own mutex.
agc_driver_unimported_label_ordergains a case: the first label of a new mapping still takes reason 7 without importing; after threeNoteFlip()a label of the same mapping returns 0 and imports its memory; the first label of another new mapping still takes reason 7; both labels land.Tested
Windows 11 Enterprise 22621, Ryzen 9 5950X, Radeon RX 6700 XT (AMD driver 26.11.2), WinLibs GCC 15.2 UCRT r7, Release, Ninja. Built and tested on
mainf784587f30(candidate commit7b6ee9180f23); the branch was then rebased onto5ae28f2373, which changes nothing undercore/libs/prx/libSceAgcDriver.GPU tests: every test of the 44 label, host import, pending producer and sleep wake executables (47 tests, including the three
agc_driver_unimported_label_ordervariants), 3 runs: 47/47 each run. Four skip here in every run:agc_driver_copied_writer_label_orderand its_drainvariant (the device reports aminStorageBufferOffsetAlignmentof 4),agc_driver_host_import_dma_buf_watch(the device does not select dma-buf) andagc_host_import_sparse(udmabuf is Linux only). Control: the same tree withVulkanDevice.cpprestored tomain(the new case andFlipSerialkept), 3 runs: all threeagc_driver_unimported_label_ordervariants fail every run witha label of a mapping labelled three flips earlier synced instead of importing its memory (reason 7).Absolum (PPSA28311,
01.002.000), the campfire scene with the character HUD, same converted title, save and route each arm (Cross every 6 s from 30 s), 3840×2160, each arm copying its build's libraries in (driver hashes inarm.txt),APS5_TRACE_SECONDS=290:20only. Arms in main, PR, PR, main order; the first main arm crashed in the title's own code at 11 s (app.exe+0x82612, a write just above0x200000000, the same early crash I have seen once before on plainmainbfcd717ebc5without this change), so one more main arm ran after them. The 300 s screenshots show the same frame in every arm.On average 939.5 against 538 presents (+75%) and p50 20.8 against 37.0 ms. All four summaries are
"dirty":falsewith only the four variables above inenv.Snoopy and the Great Mystery Club (PPSA28795), first backyard scene, same builds and machine, main, PR, PR, main: 223 / 260 / 256 / 223 presents per 20 s, p50 89.9 / 77.2 / 78.2 / 89.9 ms (+16% presents). Summary lines, digests and traces in this comment. A one-off Double Dragon Gaiden (PPSA16018) run with this PR showed no change.
Independent Windows validation reported by AlfaRojo: Windows 11 Pro 26200, GCC 15.2.0 Release, Khronos layer 1.4.363 inserted in every log, on an NVIDIA GeForce RTX 4070 and an AMD Radeon iGPU (gfx1036). The three
agc_driver_unimported_label_ordertests pass 9 of 9 on each GPU (3 runs). WithVulkanDevice.cpp,Texture.hppandTexture.cpprestored tomain, all three fail in every run with "a label of a mapping labelled three flips earlier synced instead of importing its memory (reason 7)". 0VUID-in every log. Test results only, no performance measured.Not tested: SuperTuxKart. There is no SuperTuxKart dump on this machine. By construction its per-frame label block keeps #7464's path as long as each mapping lives fewer than three flips; a block that lives longer would now be imported once per mapping instead of syncing for every label after its third flip. Linux and macOS, and other GPUs, are also untested.
Traces, summaries, screenshots, test logs, the control, scripts and the diagnostic timer patch, SHA-256
40694d547d0d43efca6c0b7eb35a8d788b289d00215a447ebcc16760cb86737a.tools/check_conventions.py --base origin/main: passed.Performance report
Summary lines (
aps5-summary.jsonl), in run order; traces in the release linked above.Summary lines
tools/trace_digest.py, main (run 4)
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): VideoOut.Flip 24.8, Driver.Present 24.8, VideoOut.Flip.present 24.8, batch 24.3, Recorder.Sync 18.4
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
seconds 290:20 from present 13939: 945 presents, frame p50 20.6 / p90 23.5 / p99 37.6 / max 48.6 ms, GPU busy 13.7 ms per present
AMD Radeon RX 6700 XT, AMD proprietary driver 26.11.2 (AMD proprietary shader compiler), Windows 10.0.22621, 3840x2160, commit 7b6ee9180f23, dropped: yes
Incomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): VideoOut.Flip 15.5, Driver.Present 15.3, VideoOut.Flip.present 15.3, batch 13.7, Recorder.WaitSerial 11.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T07:58:11Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the code I inspected supports the intended settled mapping behavior, and the reported focused test results cover its new path.
What I ran
Reviewed head
81f6333f36e30cbb494ae63f234341d93b9d500c. Read the prepared diff, manifest, description, commit list, and targeted source ranges throughrepo_read.py. I did not run commands or tests.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. I read the changed lines in all four changed files:
VulkanDevice.cpp,Texture.hpp,Texture.cpp, andUnimportedLabelOrder.cpp. The full text ofVulkanDevice.cppandTexture.cppwas excluded from the review folder; only targeted ranges were read through the repository reader. I did not read other changed-file lines or independently validate the reported performance results, hardware behavior, or operating systems.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:09:36Z.
Review: COMMENTED
Reviewed — no blocking findings
The change adds a bounded settled-mapping check for queue-0 labels; I inspected the changed logic and test additions, but did not run checks, so a formal approval is not justified.
What I ran
No commands or tests were run. Reviewed head
ec27bdd63d2ee3063cde36c3db71be6120020837; base ismainper the manifest. I read the prepared description, commits, manifest, diff, and the changed source ranges listed below.VulkanDevice.cppandTexture.cppwere excluded from the review folder due to size and were read throughrepo_read.py.Results
Negative control
Not run by me. The description reports that restoring
VulkanDevice.cpptomainmade the new settled-mapping case fail on tested configurations.Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Sources
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:3166-3183— bounded mapping/flip tracking;:3300-3306— settled mapping path in label handling.core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp:374andcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:4857-4863— flip serial declaration and implementation.core/libs/prx/libSceAgcDriver/tests/execution/UnimportedLabelOrder.cpp:248-269— new settled and fresh mapping cases.core/libs/prx/libc/include/GuestAllocations.hpp:14-28— range identity fields used by the check.Not verified
I did not run builds, tests, performance checks, or console behavior. I read the changed lines in all four changed files; the full texts of
VulkanDevice.cppandTexture.cppwere excluded from the review folder, and only relevant ranges were read. The prepared description's reported results were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T17:07:53Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code and focused test case support the settled mapping behavior; I did not run the reported tests or performance checks.
What I ran
Reviewed head
3dad12e1abf8ea7be0850152a1d13124018cf88eusingrepo_read.py. No commands or tests were run; no merged preview was checked.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I read all changed files listed in the manifest:
VulkanDevice.cpp,Texture.hpp,Texture.cpp, andUnimportedLabelOrder.cpp. No changed files were excluded. Tests, control runs, performance captures, and platform behavior were not independently verified; the description reports Windows validation and notes SuperTuxKart, Linux, macOS, and other GPUs were not tested.To get this to a good state
Nothing is required. The reported test and performance results are optional context and were not run during this review.