perf(agc): hold 65536 draw-cache entries by default #21467
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21467"
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 klosixgaming-arch on 2026-11-16T07:22:23Z.
What
The draw cache is bounded twice: by entry count (
APS5_DRAW_CACHE_ENTRIES, default 4096) and, since #9129, by the bytes its variants hold (APS5_DRAW_CACHE_BYTES, 256 MiB). A title that cycles through more than 4096 distinct draw keys before a key repeats evicts each entry under LRU before it is used again, so its draws are captured, recompiled and prepared again every frame while the byte budget is mostly unused.This raises the default entry count to 65536. The byte budget is unchanged and still bounds what the cache holds;
APS5_DRAW_CACHE_ENTRIES=4096restores the previous default. Entries hold host memory only (decodes, captured words, recompile results; recipes keepweak_ptrs to Vulkan objects), so the larger count adds no GPU memory. Things that scale with the count:entries * 4keys: 2 MiB each instead of 128 KiB;Draw.cppandDrawLookup.cpp(drawCacheEntries() / 8hits) goes from 512 to 8192 hits.Anger Foot (PPSA29043), first level, about 7,800 draws per frame (
APS5_PROFILE_DRAW=1withAPS5_TRACE_DRAW_CACHE=1, 10 s lines, warm run; samemainbinary, the second line withAPS5_DRAW_CACHE_ENTRIES=65536):ENVIRONMENT.md's row gives the new default. New execution testagc_driver_draw_cache_capacity: 4352 distinct draws submitted three times (the first pass sights each key, the second inserts it, the third must hit all 4352 under the default cap).Tested
Ubuntu 26.04.1 (Linux 7.0.0-43), NVIDIA GeForce RTX 2080 Ti (595.99.02), Xeon E5-2699 v3, GCC 15.2.0 Release.
maine04bd77e7fand this branch96e5323f46built in separate trees.Speed. Anger Foot (PPSA29043 01.000.000), run with
tools/title_run.py --runs 2 --seconds 170andAPS5_TRACE_SECONDS=120:10, relinked with--registry --module-dir Media/Modules --module-dir Media/Plugins, Cross pressed at 32, 40 and 48 s. In the warm run the presses reach the first level and the player stands still; the window starts 120 s after the first present. In the cold run the third press falls into a load and the run stays on the main menu. Rounds in order base, change, change, base:mainmainmainwindows agree within 2 ms. The change's round 2 window is within that noise (26 presents, p50 405.1 ms); round 3 has 29 presents and a p50 12 % lower. The cache keeps filling during the level: every 10 s interval of the change from 112 s on (27 to 31 presents) is above everymaininterval (24 to 26), about +10 to +17 %.trace_dropped), so the digests' slice tables cover the retained part; the summary numbers are complete.Traces, every window's summary line and the digests: https://github.com/klosixgaming-arch/AnyPS5/releases/tag/perf-captures-2026-11-16
Summary line, round 1, main, warm
Summary line, round 3, this PR, warm
Summary lines, rounds 2 and 4, warm
trace_digest.py, round 1 main and round 3 this PR, warm
Tests.
agc_driver_draw_cache_capacitypasses in 11.3 s. With the default put back to 4096 it fails:the third pass over 4352 distinct draws made 0 draw-cache hits and 4253 evictions; the default entry cap does not hold them.ctest -R 'draw_cache|draw_recipe|address_draw|image_table_cache_bounds|draw_ahead' -Vonmainand on this branch withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer(validation layer 1.4.341): 27 of 27 pass onmain, 28 of 28 on this branch. Both logs showInsert instance layer "VK_LAYER_KHRONOS_validation"and nowas not found but was requested; neither has aVUID-line. Under the validation layer the new test takes 38 s; without it, 11.3 s.tools/check_conventions.py --base origin/mainandtools/env_reference.py --checkpass.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-16T22:21:43Z.
Review: APPROVED
Reviewed — looks good
The reviewed change raises the draw cache’s default entry limit and adds a capacity regression test; the inspected code supports the stated behavior, while reported test results were not independently run.
What I ran
No commands were run. I inspected the prepared diff and changed files at head
96e5323f46d840d951c6391c51fa289d38dcc989usingrepo_read.py.Results
Negative control
Could not run a negative control. The PR description reports that restoring the default to 4096 makes the new test fail, but I did not run it.
Findings
Blocking
None.
Non-blocking
None.
Sources
DrawCache.cppchanges the fallback entry limit to 65536 at the reviewed commit. The cache eviction loop still enforces both entry and byte limits.DrawCacheCapacity.cppadds a test that submits 4352 distinct draws three times and checks cache hits and retained entry count at the reviewed commit.ENVIRONMENT.mddocuments the updated default and override at the reviewed commit.Not verified
manifest.json:DrawCache.cpp,DrawCacheCapacity.cpp, andENVIRONMENT.md. No changed files were excluded by the supplied manifest.To get this to a good state
Nothing is required.