perf(libSceAgcDriver): bypass the draw cache while its hit rate is under 5% #5404

Closed
bcortezf wants to merge 1 commit from upstream-pr/5404 into main
bcortezf commented 2026-10-13 19:00:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-13T19:00:51Z.


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=1 restores the previous behaviour, and [draw-cache] bypassed N draws is printed with APS5_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 is APS5_NO_DRAW_CACHE_BYPASS=1 on the same binary.

frame p50 FPS
bypass off (main behaviour) 392 ms 2.55
bypass on 362 ms 2.76

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_dropped is true in these captures (the worker buffer fills within 5 s).

Summary lines (off, then on):

{"commit": "981acf21ed70", "dirty": true, "env": {"APS5_NO_DRAW_CACHE_BYPASS": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_SECONDS": "100:5"}, "gpu": "NVIDIA GeForce RTX 4070 SUPER", "driver": "NVIDIA 616.64", "os": "Windows 10.0.26200", "resolution": "3840x2160", "window": {"spec": "seconds 100:5", "first_present": 1791, "ms": 5097.913}, "presents": 13, "frame_ms": {"p50": 392.154, "p90": 406.612, "p99": 413.368, "max": 413.368}, "gpu_busy_ms_per_present": 133.99, "worker_busy_pct": {"queue worker 0x0": 98.886}, "top_phases_ms_per_frame": {"Driver.Packet": 387.509, "Driver.Packet.draw": 360.408, "Driver.Draw": 358.815, "Driver.Draw.draw_and_resource_release": 181.247, "Graphics.Draw": 179.59, "Graphics.Draw.draw_and_resource_release": 154.663, "Driver.Draw.shader_compile_and_link": 126.894, "Shader.DrawStage": 95.646}, "trace_dropped": true, "trace": "aps5-trace-981acf21ed70-20260.json.gz"}
{"commit": "981acf21ed70", "dirty": true, "env": {"APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_SECONDS": "100:5"}, "gpu": "NVIDIA GeForce RTX 4070 SUPER", "driver": "NVIDIA 616.64", "os": "Windows 10.0.26200", "resolution": "3840x2160", "window": {"spec": "seconds 100:5", "first_present": 1673, "ms": 5053.279}, "presents": 14, "frame_ms": {"p50": 362.483, "p90": 371.102, "p99": 373.611, "max": 373.611}, "gpu_busy_ms_per_present": 145.365, "worker_busy_pct": {"queue worker 0x0": 98.813}, "top_phases_ms_per_frame": {"Driver.Packet": 356.413, "Driver.Packet.draw": 329.475, "Driver.Draw": 327.91, "Driver.Draw.draw_and_resource_release": 174.267, "Graphics.Draw": 172.722, "Graphics.Draw.draw_and_resource_release": 148.854, "Driver.Draw.shader_compile_and_link": 106.221, "Shader.DrawStage": 91.167}, "trace_dropped": true, "trace": "aps5-trace-981acf21ed70-6036.json.gz"}

python3 tools/check_conventions.py --base origin/main: passed. Not built or run on Linux or macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4848061102 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5404). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-13T19:00:51Z. --- ### 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=1` restores the previous behaviour, and `[draw-cache] bypassed N draws` is printed with `APS5_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 is `APS5_NO_DRAW_CACHE_BYPASS=1` on the same binary. | | frame p50 | FPS | |---|---|---| | bypass off (main behaviour) | 392 ms | 2.55 | | bypass on | 362 ms | 2.76 | 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_dropped` is true in these captures (the worker buffer fills within 5 s). Summary lines (off, then on): ```json {"commit": "981acf21ed70", "dirty": true, "env": {"APS5_NO_DRAW_CACHE_BYPASS": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_SECONDS": "100:5"}, "gpu": "NVIDIA GeForce RTX 4070 SUPER", "driver": "NVIDIA 616.64", "os": "Windows 10.0.26200", "resolution": "3840x2160", "window": {"spec": "seconds 100:5", "first_present": 1791, "ms": 5097.913}, "presents": 13, "frame_ms": {"p50": 392.154, "p90": 406.612, "p99": 413.368, "max": 413.368}, "gpu_busy_ms_per_present": 133.99, "worker_busy_pct": {"queue worker 0x0": 98.886}, "top_phases_ms_per_frame": {"Driver.Packet": 387.509, "Driver.Packet.draw": 360.408, "Driver.Draw": 358.815, "Driver.Draw.draw_and_resource_release": 181.247, "Graphics.Draw": 179.59, "Graphics.Draw.draw_and_resource_release": 154.663, "Driver.Draw.shader_compile_and_link": 126.894, "Shader.DrawStage": 95.646}, "trace_dropped": true, "trace": "aps5-trace-981acf21ed70-20260.json.gz"} {"commit": "981acf21ed70", "dirty": true, "env": {"APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_SECONDS": "100:5"}, "gpu": "NVIDIA GeForce RTX 4070 SUPER", "driver": "NVIDIA 616.64", "os": "Windows 10.0.26200", "resolution": "3840x2160", "window": {"spec": "seconds 100:5", "first_present": 1673, "ms": 5053.279}, "presents": 14, "frame_ms": {"p50": 362.483, "p90": 371.102, "p99": 373.611, "max": 373.611}, "gpu_busy_ms_per_present": 145.365, "worker_busy_pct": {"queue worker 0x0": 98.813}, "top_phases_ms_per_frame": {"Driver.Packet": 356.413, "Driver.Packet.draw": 329.475, "Driver.Draw": 327.91, "Driver.Draw.draw_and_resource_release": 174.267, "Graphics.Draw": 172.722, "Graphics.Draw.draw_and_resource_release": 148.854, "Driver.Draw.shader_compile_and_link": 106.221, "Shader.DrawStage": 91.167}, "trace_dropped": true, "trace": "aps5-trace-981acf21ed70-6036.json.gz"} ``` `python3 tools/check_conventions.py --base origin/main`: passed. Not built or run on Linux or macOS. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-13 19:01:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T19:01:10Z.


Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152971097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5404#issuecomment-6152971097). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T19:01:10Z. --- Thank you for your contribution! Authors with no pull requests merged into `main` can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.
bcortezf commented 2026-10-17 23:23:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-17T23:23:59Z.


Need me to update this branch? @oneandonlydean

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243031336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5404#issuecomment-6243031336). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-17T23:23:59Z. --- Need me to update this branch? @oneandonlydean
github-actions[bot] commented 2026-10-17 23:25:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T23:25:44Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1896 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 5431 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6501 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6539 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
PR 6612 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6639 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6801 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 6946 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp
PR 7201 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 7233 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7275 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7307 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7369 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
PR 7371 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7446 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp
PR 7644 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7691 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 7930 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 7978 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 8083 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 8339 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 8372 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 8740 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 9129 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp
PR 9177 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 9243 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
PR 9248 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp
PR 9335 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 9396 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 9424 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243046885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5404#issuecomment-6243046885). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T23:25:44Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1896](https://www.github.com/boykopovar/AnyPS5/pull/1896) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 5441](https://www.github.com/boykopovar/AnyPS5/pull/5441) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6501](https://www.github.com/boykopovar/AnyPS5/pull/6501) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp` | | [PR 6612](https://www.github.com/boykopovar/AnyPS5/pull/6612) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 6639](https://www.github.com/boykopovar/AnyPS5/pull/6639) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 6801](https://www.github.com/boykopovar/AnyPS5/pull/6801) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 6804](https://www.github.com/boykopovar/AnyPS5/pull/6804) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 7233](https://www.github.com/boykopovar/AnyPS5/pull/7233) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 7275](https://www.github.com/boykopovar/AnyPS5/pull/7275) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 7307](https://www.github.com/boykopovar/AnyPS5/pull/7307) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 7369](https://www.github.com/boykopovar/AnyPS5/pull/7369) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp` | | [PR 7371](https://www.github.com/boykopovar/AnyPS5/pull/7371) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 7446](https://www.github.com/boykopovar/AnyPS5/pull/7446) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp` | | [PR 7644](https://www.github.com/boykopovar/AnyPS5/pull/7644) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 7691](https://www.github.com/boykopovar/AnyPS5/pull/7691) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 7930](https://www.github.com/boykopovar/AnyPS5/pull/7930) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 7978](https://www.github.com/boykopovar/AnyPS5/pull/7978) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 8083](https://www.github.com/boykopovar/AnyPS5/pull/8083) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 8339](https://www.github.com/boykopovar/AnyPS5/pull/8339) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 8372](https://www.github.com/boykopovar/AnyPS5/pull/8372) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 8740](https://www.github.com/boykopovar/AnyPS5/pull/8740) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 9129](https://www.github.com/boykopovar/AnyPS5/pull/9129) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp` | | [PR 9177](https://www.github.com/boykopovar/AnyPS5/pull/9177) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 9243](https://www.github.com/boykopovar/AnyPS5/pull/9243) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp` | | [PR 9248](https://www.github.com/boykopovar/AnyPS5/pull/9248) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp` | | [PR 9335](https://www.github.com/boykopovar/AnyPS5/pull/9335) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 9387](https://www.github.com/boykopovar/AnyPS5/pull/9387) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 9396](https://www.github.com/boykopovar/AnyPS5/pull/9396) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp` | | [PR 9424](https://www.github.com/boykopovar/AnyPS5/pull/9424) | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp` | | [PR 9508](https://www.github.com/boykopovar/AnyPS5/pull/9508) | `core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCache.cpp`<br>`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCacheStatistics.cpp` |
oneandonlydean commented 2026-10-17 23:57:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T23:57:58Z.


Thanks for the measurements and the opt-out switch. Before this can merge it needs a rebase and a fresh measurement, because the draw cache it works around has changed a lot since this branch was cut (it is about 2,600 commits behind main, and all four files conflict).

Why the current numbers no longer carry over. Since your base, main has added several changes aimed at exactly the low hit rate you measured in RDR:

  • 0adbdcf45c: a draw key is cached the second time it is seen;
  • 94ea410c9e: a key is admitted at first sight when its shape is known;
  • 58b6ddf729: draws that differ only in user data reuse their shape's decode and stages;
  • 56bb6377d2: pure data words of a cached stage are refreshed instead of recaptured;
  • f9cacfadc9 and #4943: cached draws are found across moved user-data pointers.

What the rebase needs to account for. useDrawEntries also gates stage caching. On main it gates stageEntries (Draw.cpp, const bool stageEntries = useDrawEntries && …), and stage-level reuse now hits in cases where the whole-draw key misses. The bypass counts only whole-draw drawHit, so a scene whose whole-draw keys miss but whose stages hit would be measured as under 5% and would lose the stage reuse that is working. Please either measure what the bypass switches off (whole-draw plus stage hits), or bypass only the whole-draw lookup and insert and keep stage entries on.

Minor: the window counters (fetch_add, then exchange and store) can race between queue workers. For a heuristic that's acceptable, but a single CAS on a packed counter, or a note, would make it explicit.

Measurements we need on the rebased head:

  1. RDR (PPSA30528) on current main: the [draw-cache] profile lines (lookups, hits, stage hits), showing the low hit rate still occurs.
  2. FPS with the bypass off (APS5_NO_DRAW_CACHE_BYPASS=1) and on, same binary and scene, several rounds as before.
  3. One or two titles where the cache does pay (menus, cutscenes or a typical gameplay scene): the [draw-cache] bypassed N draws count, ideally 0, and FPS unchanged.

With those, this is a straightforward review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6243432597 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5404#issuecomment-6243432597). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T23:57:58Z. --- Thanks for the measurements and the opt-out switch. Before this can merge it needs a rebase and a fresh measurement, because the draw cache it works around has changed a lot since this branch was cut (it is about 2,600 commits behind `main`, and all four files conflict). **Why the current numbers no longer carry over.** Since your base, `main` has added several changes aimed at exactly the low hit rate you measured in RDR: - 0adbdcf45c0: a draw key is cached the second time it is seen; - 94ea410c9e4: a key is admitted at first sight when its shape is known; - 58b6ddf7297: draws that differ only in user data reuse their shape's decode and stages; - 56bb6377d29: pure data words of a cached stage are refreshed instead of recaptured; - f9cacfadc95 and #4943: cached draws are found across moved user-data pointers. **What the rebase needs to account for.** `useDrawEntries` also gates stage caching. On `main` it gates `stageEntries` (`Draw.cpp`, `const bool stageEntries = useDrawEntries && …`), and stage-level reuse now hits in cases where the whole-draw key misses. The bypass counts only whole-draw `drawHit`, so a scene whose whole-draw keys miss but whose stages hit would be measured as under 5% and would lose the stage reuse that is working. Please either measure what the bypass switches off (whole-draw plus stage hits), or bypass only the whole-draw lookup and insert and keep stage entries on. Minor: the window counters (`fetch_add`, then `exchange` and `store`) can race between queue workers. For a heuristic that's acceptable, but a single CAS on a packed counter, or a note, would make it explicit. **Measurements we need on the rebased head:** 1. RDR (PPSA30528) on current `main`: the `[draw-cache]` profile lines (lookups, hits, stage hits), showing the low hit rate still occurs. 2. FPS with the bypass off (`APS5_NO_DRAW_CACHE_BYPASS=1`) and on, same binary and scene, several rounds as before. 3. One or two titles where the cache does pay (menus, cutscenes or a typical gameplay scene): the `[draw-cache] bypassed N draws` count, ideally 0, and FPS unchanged. With those, this is a straightforward review.
bcortezf commented 2026-10-22 01:21:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bcortezf on 2026-10-22T01:21:14Z.


@oneandonlydean Closing: main has since landed the draw-cache admission and reuse changes listed above, which target the same low hit rate, and on the earlier stack (#494, #1193, #1202) this bypass was already neutral (~-3%, within noise). Thanks for the review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330362802 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5404#issuecomment-6330362802). Originally posted by [bcortezf](https://github.com/bcortezf) on 2026-10-22T01:21:14Z. --- @oneandonlydean Closing: main has since landed the draw-cache admission and reuse changes listed above, which target the same low hit rate, and on the earlier stack (#494, #1193, #1202) this bypass was already neutral (~-3%, within noise). Thanks for the review.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5404
No description provided.