perf(agc): expand recent host imports cache to 16 entries and consult it in findImport #27270
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27270"
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:52Z.
What
HostImportskept a 4-entryrecentImportsfast-path cache that was consulted only inHostImportFor, leavingfindImportandExistingHostImportForto walk thestd::map(peekImport) on every lookup and thrashing when a frame alternates across more than 4 large host-imported arenas (buffers, vertex/index heaps, labels, and scratch regions).Changes
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:HostImports::recentImportsfrom 4 to 16 entries and resetrecentNext = 0when the cache is cleared on epoch or import-count change.recentImportbeforepeekImportinfindImportand populaterememberImporton a map hit.recentImport/lastUse/rememberImportwork fromHostImportFor,HostImportJoinedFor, andExistingHostImportFor(follow-up7861a468bd) so misses scan the cache once and write each entry into one slot, while keepingExistingHostImportForread-only (importsStalereturnsnullptrwithout mutating state).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
7861a468bd(follow-up on3bb93e7408, baseorigin/mainc032ba7c52) 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:agc_driver_host_import_*,agc_host_import_*,agc_driver_bda_device,agc_driver_linear_target_import_creation,agc_driver_sparse_heap_import,agc_driver_recorder): 19 / 20 passed on bothorigin/main0af6efad52and7861a468bd,Insert instance layer "VK_LAYER_KHRONOS_validation"confirmed 25 times on both, 0VUID-errors. The single failure on both sides is pre-existingagc_driver_linear_target_import_creation(verified identical withAPS5_NO_RECENT_IMPORTS=1).tools/check_conventions.py --base origin/main: passed.tools/debt_fold.py --check: passed.Lies of P (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza):61250ca018,~6,800live host imports):10.97 → 11.25 FPS(p50 90.7 → 87.9 ms,gpu 59.8 → 58.4 ms/f), 0 mismatches across 243,421 live cross-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).3bb93e7408):8.93 FPS(-0.07),p50 111.2 ms(+0.7 ms),p90 118.6 ms(+0.9 ms),max 153.6 ms,gpu 69.61 ms/f(-0.69 ms/f),Graphics.Draw 73.36 ms/f(+1.03 ms/f) (aps5-trace-3bb93e740836-35972.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(3bb93e7408):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: Linux, NVIDIA/Intel GPUs, fresh Lies of P capture on follow-up
7861a468bd(captures above are from3bb93e7408).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:03:04Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
3bb93e7408361844bbe4b4f947e600f70cb09b3ausing the prepared diff andrepo_read.pyreader. No build or test commands were run. The author reports unit tests and conventions/debt checks passed; those results were not independently run here.Results
Findings
Blocking
None.
Non-blocking
Not verified
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppwas read through the pinned reader at relevant ranges; it was excluded fromreview/files/because it was too large. The diff shows its changed lines. No other repository files were reviewed.To get this to a good state
Nothing is required. The performance clarification above is optional.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T10:57:35Z.
Review: APPROVED
Reviewed — looks good
The cache changes appear internally consistent at head
7861a468bdc19c5652247e0188f947c346297469; one changed source file was read, while no checks were run and performance claims were not independently verified.What I ran
No commands or tests were run. I read the prepared description, commit summary, manifest, diff, and the changed source ranges through the pinned reader.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The complete
GuestBufferMemory.cppwas not read; the inspected ranges covered all changed hunks and the cache helpers they use. No test or build was run. Author-reported focused tests, convention checks, debt checks, and performance measurements were not independently verified. The review-folderfiles.jsonwas not available; the manifest and directory listing show one changed file, excluded from full-text inclusion due to size.To get this to a good state
Nothing is required.