perf(agc): hold 262144 draw-cache entries by default #26597
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26597"
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-24T09:21:04Z.
What
The draw cache's default entry count goes from 65536 to 262144 (
DrawCache.cppdrawCacheEntries). The byte budget (APS5_DRAW_CACHE_BYTES, 256 MiB) is unchanged and still bounds what the cache holds, andAPS5_DRAW_CACHE_ENTRIES=65536restores the previous default. The key and shape sighting tables that decide admission stay at the previous size, 65,536 × 4 keys (Driver::DrawKeySightingKeys(), sized frommin(entries, 65536)). Sizing them from the larger cap, as the first version of this PR did, admitted far more one-off draws: on Trails in the Sky the 2nd Chapter the cache then sat at its byte budget (~106,500 entries) and inserted up to ~75 % more entries per 10 s, which cost ~5 % of frames.#21467 raised the default from 4096 to 65536 for the same reason on Anger Foot. Snoopy and the Great Mystery Club (PPSA28795) now overflows 65536: in its backyard scene the cache is pinned at 65,536 entries while holding ~149 MiB of its budget, and it evicts ~110,000 entries per 10 s that would be hit again. Only 5-10 % of lookups hit, and about half of all draws then pay
Driver.Draw.shader_compile_and_link(~29 µs each, ~34 ms per frame) on a queue worker that is 99 % busy. The measurements are in #26586.agc_driver_draw_cache_capacitykeeps its 4352-draw reuse case unchanged and addsDefaultEntryCapExceedsThePreviousOne: withAPS5_DRAW_CACHE_ENTRIESunset, it requires the default cap from the now-publicDriver::DrawCacheEntries()(renamed from the privatedrawCacheEntries()) to be 262,144, and the sighting tables to hold 65,536 × 4 keys, above the previous 65,536. An earlier version instead inserted 70,000 distinct draws and checked that none were evicted. It held but took about 60 s under the validation layer on an RTX 4070, over the 30 s test limit, so it was replaced. Its results are kept below.Tested
Current head
8c0d924948(rebased ontomain7c44e0ba9d, sighting tables kept at the previous size), RX 6700 XT, Windows:agc_driver_draw_cache_capacitypasses 3 of 3 underVK_LAYER_KHRONOS_validation1.4.363 (6 insertions, 0VUID-). Speed below for this head was measured onmain7c44e0ba9dwith the same change applied (min(entries, 65536)sighting tables), arms differing only in the library set andAPS5_DRAW_CACHE_ENTRIES(65536 onmain, 262144 on the change), one unmeasured warm-up per set, alternating runs,APS5_TRACE_SECONDSonly:mainpresents / 20 smainp50The measurements from here down are for the first version (sighting tables sized from 262144).
Windows 11 Enterprise 22621, Ryzen 9 5950X, RX 6700 XT (AMD 26.11.2), WinLibs GCC 15.2 UCRT r7, Release.
mainc5c9134731and this branch6ca1d5633bbuilt in the same tree.agc_driver_draw_cache_capacity(current test, head7e01571ddc), Linux 7.3.5, GCC 16.2.1, Release, RX 7900 XTX, with the Khronos validation layer inserted: passes 3 of 3 runs in 5.3 to 6.0 s, with 0 VUID and 0 SYNC messages. Withmain's 65,536 default restored inDrawCache.cppit fails withthe default draw cache entry cap is 65536, not 262144.Earlier 70,000-draw test (head
6ca1d5633b): passed 3 of 3 runs with this change (25.2 s each). Withmain'sDrawCache.cppit failed 3 of 3 withsighting and inserting 70000 more distinct draws evicted 6814 entries(6974 and 6861 in the other runs). @cozejarr's RTX 4070 run reproduced both: about 6,900 evictions onmainand a pass on this branch.Speed, Snoopy (PPSA28795) backyard. Standard 180 s route with scripted input, title relinked once, arms differ only in the libraries. Only
APS5_TRACE_SECONDS=100:20was set, no other trace or profile switch. The order wasmain, PR, PR,main, and every run reached the cap.mainmainmain+27 % presents, and every run with this change is faster than every
mainrun.Other titles, same machine, measured with
APS5_DRAW_CACHE_ENTRIES=262144on amainbinary (equivalent to this change):mainbd9a6c00a6gave 88.7 against 94.0 ms (details). Neither set separates on its own, but both point the same way.aps5-summary.jsonl, run 1 (main)aps5-summary.jsonl, run 2 (this PR)tools/trace_digest.py --top 6, run 1 (main)seconds 100:20 from present 2144: 230 presents, frame p50 87.2 / p90 91.4 / p99 101.0 / max 103.4 ms, GPU busy 41.6 ms per present
AMD Radeon RX 6700 XT, AMD proprietary driver 26.11.2 (AMD proprietary shader compiler), Windows 10.0.22621, 1920x1080, commit
c5c9134731, dropped: yesIncomplete 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): batch 41.6, Driver.Packet 20.0, Graphics.Draw 19.9, Graphics.Draw.draw_and_resource_release 15.7, Driver.Packet.draw 15.1, Driver.Draw 14.9
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
tools/trace_digest.py --top 6, run 2 (this PR)seconds 100:20 from present 2254: 297 presents, frame p50 67.1 / p90 71.3 / p99 74.0 / max 74.6 ms, GPU busy 31.6 ms per present
AMD Radeon RX 6700 XT, AMD proprietary driver 26.11.2 (AMD proprietary shader compiler), Windows 10.0.22621, 1920x1080, commit 6ca1d5633b9e, 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): batch 31.6, Driver.Packet 20.9, Recorder.Sync 15.3, Driver.Packet.draw 14.4, Driver.Draw 14.3, Graphics.Draw 13.2
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T01:52:04Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes raise the default draw-cache entry cap to 262,144 while keeping the key and shape sighting tables at their previous size; I found no verified blocking defect.
What I ran
Inspected the prepared diff and targeted source at head
8c0d924948a4f610572d412fbaf39a1304246e48using the review reader. No build or test commands were run; no merged-preview check was performed.Results
Findings
Blocking
None verified in the inspected changes.
Non-blocking
None.
Not verified
Build and test execution were not performed. The performance and validation-layer results in the PR description are author-reported, not independently verified. The full text of
Draw.cppandENVIRONMENT.mdwas not read; their changed hunks were inspected. The other four changed files were read in full.To get this to a good state
Nothing is required.