perf(agc): fast-path existing imports and open batches in WriteLabelOnGpu #27269
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27269"
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 birdmarty on 2026-11-25T17:31:45Z.
What
VulkanDevice::WriteLabelOnGpuis called hundreds to over a thousand times per frame on label writes. Previously, every call on queue 0 ranrecorder.Reap()even when an open batch was active and no copied writers or pending completion stores were queued, and then performed aGuestAllocationsLookup+HostImportCovers+HostImportForsequence even when the label address was already covered by an existing host import.Changes
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:recorder.Reap()inWriteLabelOnGpuwhen!recorder.Recording(), copied writers exist, pending completion stores are nonzero, orAPS5_LABEL_GATE_ALLis set with pending completions (uses existingRecorder::Recording(), noRecorder.hppchange).Graphics::ExistingHostImportFor(context, address, bytes.size())first and fall through toGuestAllocationsLookup/HostImportCovers/HostImportFor(..., ImportRequester::Label)(#26718) /HostImportFor/UnregisteredHostImportonly on a miss (reusing theHostImport*returned by theLabelwindow call without a second lookup).Tested
Windows 11 Pro (build 26300), i9-9900K, MinGW-w64 GCC 15.3.0, Release build, AMD Radeon RX 6800 (
vendor=0x1002,device=0x73bf), AMD proprietary driver26.10.1(Windows driver32.0.21045.16010, Vulkan1.4.315).Unit tests on
929d09c8cb(rebased ontoorigin/main0af6efad52) compared againstorigin/main0af6efad52withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK1.4.363.0),VK_LOADER_DEBUG=layer:ctest -R "^(agc_.*label.*|agc_driver_recorder)$": 41 / 41 passed (38 passed, 3 skipped, 0 failedon bothorigin/main0af6efad52and929d09c8cb, includingagc_driver_label_import_window,_draw_pipeline, and_plan_verifyfrom #26718),Insert instance layer "VK_LAYER_KHRONOS_validation"confirmed 51 times on both, 0VUID-errors.tools/check_conventions.py --base origin/main: passed.tools/debt_fold.py --check: passed.Synthetic
WriteLabelOnGpuCPU microbenchmark (0af6efad52vs929d09c8cb, 4 alternating A/B pairs)Controlled Release benchmark (no validation layer, no trace/profile env vars, identical executable linked against
libSceAgcDriver.prxfrom0af6efad52vs929d09c8cb; 256 registered guest allocations, 33 host imports, 4 alternating fresh-process pairsA1 -> B1 -> ... -> A4 -> B4, verifyingreason == 0on every call and final label bytes afterWaitIdle()):0af6efad52median (µs/call)929d09c8cbmedian (µs/call)0.573–0.605vs0.475–0.482)0.794–0.879vs0.672–0.703)80/80in flight), 1 block, queue 0 (16k calls/run)1.538–1.892vs1.043–1.443)80/80in flight), 16 blocks, queue 0 (16k calls/run)1.813–2.235vs1.475–1.712)0x20(30k calls/run)0.696–0.736vs0.709–0.717)Saving
0.11–0.40 µsper queue-0 label write corresponds to~0.4 ms/frameat~1,058label runs/frame (as in Lies of P below), which explains why isolated whole-frame FPS on a110 ms/framescene (or Insomnis at~105 ms/frame) falls inside run-to-run variance while per-call CPU overhead drops17–25%.Lies of P (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza,~1,058Graphics.Barrier.label-run/frame):61250ca018):10.83 → 10.97 FPS(p50 91.0 → 90.7 ms,p90 99.2 → 96.9 ms,gpu 62.9 → 59.8 ms/f), clean exit with 0 mismatches across 3-verifier live checks.Performance captures (
APS5_TRACE_SECONDS=120:30, clean warm shader cache, no extraAPS5_TRACE_*orAPS5_PROFILE_*switches)Same machine, title (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza), and flags (APS5_DRAW_PIPELINE=1 APS5_NO_DRAW_STAGING=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1 APS5_FAST_F32=1):main,c032ba7c52):9.00 FPS,p50 110.5 ms,p90 117.7 ms,max 151.1 ms,gpu 70.31 ms/f,Graphics.Draw 72.33 ms/f(aps5-trace-c032ba7c5273-23148.json.gz).9.01 FPS(+0.01),p50 109.9 ms(-0.6 ms),p90 118.2 ms(+0.5 ms),max 156.7 ms,gpu 69.34 ms/f(-0.97 ms/f),Graphics.Draw 72.95 ms/f(+0.62 ms/f) (aps5-trace-6de3ab3d71a1-35824.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(6de3ab3d71a1):Series context & interleaved ablation
This PR is part of a general AGC/libc performance series measured on Lies of P (
PPSA10621,v01.012.000,3200x1800, UE4) covering #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, and #27273 (tested together with #20130, #18757, #26778, #27117, and now-merged #26581 and #26681). Combined on base61250ca018(plus remaining unsplit stack changes), steady-state performance rose from7.25 FPS(p50 135.6 ms,gpu 92.7 ms/f, default settings) to12.15 FPSaverage (12.00/12.30 FPS, peak12.33 FPS,p50 81.5 ms,gpu 57.12 ms/f,+67.6%to+70.1%).Because five of the smaller PRs (#27253, #27254, #27270, #27271, and #27273) looked like they slightly lost average FPS (
-0.03to-0.31 FPS) in single isolated runs onc032ba7c52, we ran an interleaved 4-run ablation (A1 -> B1 -> A2 -> B2,APS5_TRACE_SECONDS=120:30, identical warm shader cache and flags) on the full stack to test whether removing those 5 PRs helped or hurt:61250ca018(WITH all 11 PRs): #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, #27273 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes (per-64 KiB proof/pending tracking and ShapeRecipe).61250ca018MINUS the 5 PRs (#27253, #27254, #27270, #27271, #27273): keeps #27249, #27250, #27251, #27252, #27268, #27269 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes.DrawWithRecipe(ms/f)DrawFinish(ms/f)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)+0.39 FPS(+3.3%)-2.1 ms-4.6 ms-10.5 ms-3.21 ms/f-1.02 ms/f-0.88 ms/fRemoving those 5 PRs hurt every run (
A1 > B1andA2 > B2across all metrics), showing that their single-run isolated dips onc032ba7c52were within±0.25 FPSscene variance while larger bottlenecks (#27268, #27249, #27252, #20130, #18757) still dominated. Individual PR captures above remain isolated againstc032ba7c52.Not tested: NVIDIA/Intel GPUs, fresh Lies of P capture on rebased
929d09c8cb(captures above are from 6de3ab3d71; JJenkx also ran 6de3ab3d71 on Insomnis PPSA06829 on Linux/RADV RX 6650 XT with no crashes and overlapping 9.52 vs 9.81 FPS arms).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)main0af6efad52and this change, 0 VUIDsImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T18:04:08Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code and its directly relevant import and recorder implementations were read at head
6de3ab3d71a11254bca04209c3ac3213c80e6e36; no checks were run in this reader-only environment.What I ran
Read the prepared diff and targeted source context at the exact head above using
repo_read.py. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Builds, tests, and runtime behavior were not verified in this session. The author reports Windows unit tests and console measurements in the PR description; these were not independently run. Both changed files listed in the manifest were read. No changed files were excluded from review.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:14:06Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
929d09c8cbb2fa5f2c1b3dde4d9786134f7629c6has no verified blocking defect; its runtime and performance claims remain only partly verified from the available code review.What I ran
No build or tests were run. I inspected the prepared diff and targeted code at the pinned head.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp, was read around the changed function. Its full text was excluded from the prepared bundle due to size; other portions were not reviewed.To get this to a good state
Nothing is required.