perf(libSceAgcDriver): bypass the draw cache while its hit rate is under 5% #5407
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5407"
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 bcortezf on 2026-10-13T19:05:11Z.
What
The draw cache (
APS5_DRAW_CACHE_ENTRIES, 4096 entries) misses on almost every draw in scenes whose user-data words change every frame: in Red Dead Redemption gameplay it hits 0 to 6% of 120k to 130k lookups per 10 s and spends the time inserting and evicting entries (131k inserts and 300k to 730k evictions per 10 s).Count the lookups in windows of 2,048. When fewer than 5% of a window hit, draws skip the cache (no register key, no lookup, no insert, the same path as
APS5_NO_DRAW_SRT_ENTRIES) for the next 16,384 draws, then the cache is probed again. Scenes that hit (menus and cutscenes, 98 to 100%) are not bypassed.APS5_NO_DRAW_CACHE_BYPASS=1restores the previous behaviour, and[draw-cache] bypassed N drawsis printed withAPS5_PROFILE_DRAW.Related: #5345 (report), #5364 (miss breakdown; independent, may need a rebase in
Draw.cpp).Tested
Windows 11, RTX 4070 SUPER (driver 616.64), Ryzen 7 7800X3D, 3840x2160. PPSA30528, Armadillo after the intro,
APS5_TRACE_SECONDS=100:5, caches warm, same session. The base isAPS5_NO_DRAW_CACHE_BYPASS=1on the same binary.Two earlier rounds on the same machine: 2.63 / 2.61 FPS off, 2.80 / 2.83 FPS on. The queue worker stays at 98.8% busy; the gain is per-draw cost, not a different bottleneck.
trace_droppedis true in these captures (the worker buffer fills within 5 s).Summary lines (off, then on):
python3 tools/check_conventions.py --base origin/main: passed. Not built or run on Linux or macOS.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T19:27:03Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppL172Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-13T19:57:52Z.
Data point from another title: Diablo II: Resurrected (PPSA03912, 01.039.000), Linux, RTX 3080 Ti (NVIDIA 615.71.09), in game in the Rogue Encampment.
Without this PR the draw cache almost never hits there:
[draw-cache] 46087 lookups (10 s): 46044 no entry, 43 validated, and53897 lookups: 53845 no entry, 52 validatedin the next window (about 0.1%). The queue worker is pinned at about 90% of a core.With this PR (merged on top of #5216 and #4947 on main of 2026-10-13, so the effect of this one alone is not isolated) the bypass fires from the first window (
bypassed 16384 draws, then 65536 and 81920 per 10 s), no abort. The window-title FPS in the same area went from about 2.4 to about 3.6 on average (readings 4.4, 5.6, 4.4, 2.2, 0.2, 4.9). That is noisy: memory is near full and the run swaps, and the scene differed between the two runs, so treat it as a direction and not a measurement. The queue worker is still at about 79% of a core, so the per-draw evaluation and descriptor work is the remaining cost.AI-assisted; the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-13T22:49:22Z.
Closing: #5216 merged and covers this problem with per-key admission instead of a global bypass; it measured at least as well on my RDR runs (isolated and on top of #494). Thanks @mrfelek for the Diablo II data.
Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-13T23:06:38Z.
Besiege (PPSA20313),
mainata0f5916a2againstmainplus this commit, Windows 11, RTX 4070 SUPER, 1080p, three runs each:On this title the draw cache hits 2.5% of its lookups (about 80,000 lookups in 10 s, 95% with no entry), so it is exactly the case the bypass targets.
Pull request closed