fix(agc): bound the draw cache by bytes #9129

Merged
EagleBearerYS merged 2 commits from upstream-pr/9129 into main 2026-10-28 07:07:43 +00:00
EagleBearerYS commented 2026-10-21 12:45:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T12:45:39Z.


What

The dispatch cache evicts by entry count or by bytes: past APS5_DISPATCH_CACHE_BYTES (256 MiB by default) it drops its least recently used entries. The draw cache evicts only by entry count, at 4,096 entries, so it holds whatever those entries capture.

When a draw's SRT walk captures a large table of guest addresses, each variant keeps a copy of it. In Resident Evil Village (PPSA01556)'s main menu, on a local tree of main plus our open PRs, the draw cache's own [draw-cache] profile line went from ~21 MiB to ~2,149 MiB of variants (4,096 entries, ~16,000 variants) at a ~4% hit rate.

The change:

  • insertDrawEntry evicts from the LRU end while size > drawCacheEntries() || (size > 1 && drawCacheVariantBytes > DrawCacheBytes()), the dispatch cache's condition. size > 1 keeps the entry just inserted, as the dispatch cache does.
  • APS5_DRAW_CACHE_BYTES sets the budget: 256 MiB by default, 0 keeps the default, read once. Its row is in ENVIRONMENT.md.
  • Evictions over the byte budget are counted separately and shown in both [draw-cache] lines, e.g. 126 entries (252 variants, ~254.3 MiB of a 256.0 MiB budget), 1473 evictions in total (1473 over the byte budget).
  • Driver::DrawCacheSize() returns entries and bytes under the cache's lock, the twin of DispatchCacheSize().

What the count covers. variantBytes, shared by both caches, counted the sizes of four vectors. It now counts the capacities of every vector a variant owns (runs, words, shared, data positions and slots, run bases, shader data patches, captured words and spans), plus a ShaderMemory's pages for the stamp-validated dispatch variants that keep one. Draw variants keep none. Measured per draw variant:

  • a 2 MiB table read back to back: +0.4%;
  • a stride-48 table of 32-byte records: the old count covered 75% (1,579,408 of 2,106,272 bytes), since words grows without a reserve.

No variant changes size after its insert, so the add and the remove compute the same number.

Two budgets, not one shared. The caches have their own locks and LRU lists. A shared budget would need a victim policy and a lock across both, and a phase heavy in one kind of work would evict the other's entries. The worst case is 512 MiB, and each budget can be tuned.

Limits:

  • Relocation aliases held shared_ptrs to entries, so an entry evicted while an alias named it stayed alive outside the count: @hugodearaujo measured about 2 GB held that way at 14 minutes in 007 First Light (PPSA11386) on main 11e8ad2934 (see Tested). Since #9396, on main since 2026-10-24, an alias names a cached key and a lookup drops it once its entry is evicted, so this no longer applies when this PR merges: his rerun on main f95acfc948 keeps tagVariantRuns at about 253 MiB with this PR (see Tested).
  • DrawEntry, its decode and recipes stay outside the budget, as before.

Speed, from a scratch bench on Linux with lavapipe (fork commit 413c412595's VillageDrawCost, with each draw's T# offset taken from a lane value so every variant captures ~1 MiB; 850 draws per frame over 6,800 keys, single runs):

draw cache µs per draw, median peak resident memory
main 5,215 MiB counted after 12 frames, still growing 20,176 10,789 MiB
this PR 254 MiB of 256 6,812 5,379 MiB
no draw cache (APS5_NO_DRAW_SRT_ENTRIES=1) none 3,755 4,142 MiB
  • Without such captures the bench's variants are ~1 KiB and the budget is never reached: 723 against 569 µs per draw, inside the bench's spread.
  • At its 0% hit rate the bench still pays 6.8 against 3.75 ms per draw for caching. #5404 bypasses lookups at low hit rates, which is that case.
  • On Linux, part of the remaining gap to the no-cache run is glibc keeping freed ~1 MiB blocks (4,329 MiB with a fixed mmap threshold). Windows builds use mimalloc.

Overlap: checked with git merge-tree against the 24 open PRs touching Draw/DrawCache.cpp, Draw/Draw.cpp or Draw/DrawCacheStatistics.cpp. This PR adds conflicts only with these:

  • #5404 bypasses lookups when hits are rare, and this bounds what its probe windows insert, so the two compose. The only shared text is one Driver.hpp member line; keep both sets of fields.
  • #6188 moves eviction into evictDrawEntries, so the byte clause and its counters would move there.
  • Our #6947 and #7642, and #6946, edit the same [draw-cache] append line. Whichever merges second keeps both insertions.

The rest conflict with main already or merge cleanly.

Follow-up, not in this PR: tagVariantRuns could reserve its total word count first, as the dispatch insert does: −25% of words capacity on the stride-48 table.

Tested

  • New case SrtMovingPerDraw in the existing agc_driver_image_table_cache_bounds, beside SrtMovingPerDispatch. 64 keys, each drawn twice (a key is inserted on its second sighting), each capturing its own ~2 MiB of a 2 MiB image table, under a 16 MiB test budget. It checks after every draw that the cache stays within the budget, that the color comes from the table's T#, that evictions happen and are all byte evictions, and that an evicted key is looked up absent, inserted again and then hit with updated records.

    • Red, with only the loop condition put back and the test unchanged: "after draw 15 the draw cache kept 8 entries holding 16580 KiB, over its budget of 16384 KiB".
    • Green: "64 inserts, 57 evictions, 57 over the byte budget, at most 7 entries holding 14521 KiB".
  • Linux (Ubuntu 24.04, GCC 13.3, lavapipe, CI's flags), on the same diff before its rebase onto main fce8ecf162:

    • the draw cache, image table, recipe and relocation tests: 20 of 20 (2 skips), as on main;
    • ^agc three times: 860, 862 and 860 of 862, against 861, 861 and 862 on main. The failures are agc_driver_pipelined_fill, agc_driver_storage_write_back_no_window and agc_driver_sgpr_pattern_fill_keys, timing tests that fail on main too and don't touch the draw cache;
    • the full CI ctest: 1,796 of 1,802 against 1,795 on main, the same six network failures (no IPv6 on that machine);
    • registration matches.
  • GitHub's runners (run, same diff before the rebase):

    • Linux: the case passes ×10, and the libc and libkernel suites pass.
    • Windows: it builds and the suites pass; the case skips there, as the Vulkan tests do on that runner.
    • With main's code the case doesn't build, because it uses the new DrawCacheSize().
  • Windows with an NVIDIA GPU, where the case runs instead of skipping, by @gdols (comment): GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, main 80565c594 (with #8310 to build) and this PR at f2c368b24, with ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1.

    • agc_driver_image_table_cache_bounds under VK_LAYER_KHRONOS_validation (SDK 1.4.363.0): 3 of 3 with no validation messages. SrtMovingPerDraw reports the green line above.
    • With only the loop condition put back, it fails 3 of 3 with the red line above.
    • ^agc_: 870 passed, 3 skipped and 3 failed, the same as on main. They name the three as agc_driver_sample_order*, which they say #9056 fixes.
    • Not run in a title.
  • MinGW -fsyntax-only on the five changed sources: no errors.

  • check_conventions.py passes, with no comment lines added.

  • Resident Evil Village (PPSA01556), static main menu, 11 min without input.

    • Both arms: Windows, RTX 3070, the same warm shader cache, and the same environment (APS5_LAZY_SHADER_PREPARE=1, APS5_NO_GPL=1, APS5_HOST_IMPORT_MIB=6400, APS5_PROFILE_DRAW=1).
    • Arm A is main 1ff5c8ac5c with #8926. Arm B adds this change. The PR itself is on current main.
    • GPU clocks weren't held, so the frame times are rough.
    • Each arm's last [draw-cache] profile line, from its entry count on:
      • A: 4096 entries (18017 variants, ~2596.3 MiB), 3655 evictions in total, 18 LRU moves
      • B: 282 entries (564 variants, ~255.0 MiB of a 256.0 MiB budget), 25447 evictions in total (25447 over the byte budget), 0 LRU moves
    A: without B: with this change
    [draw-cache] at the end 4,096 entries, 18,017 variants, ~2,596 MiB 282 entries, 564 variants, ~255.0 MiB of the 256 MiB budget, every eviction over the byte budget
    hits, menu +1 to +10 min 2.65% (4,342 of 163,617) 0% (0 of 184,094)
    private bytes, +1 to +10 min (rate: least-squares fit over the ~13 s samples) 19,314 → 25,087 MB, +654 MB/min 18,904 → 21,078 MB, +223 MB/min
    present interval over the same window, median / p90 ~2.73 s / ~3.27 s ~2.32 s / ~2.86 s
    • The budget cuts the menu's private-memory growth by about two thirds, from 654 to 223 MB/min, and keeps the cache at its budget.
    • The cost: the hit rate at that menu drops from 2.65% to ~0%. This pair was no slower with it. With clocks not held and ~200 presents per arm, I claim nothing stronger.
    • The remaining ~220 MB/min grows outside the draw cache, so this doesn't fix the menu's growth on its own. Its holder isn't found yet; that's for a separate change.
  • Merged with main 0db47b263d (73ec16a36f). One conflict, in the [draw-cache] line in DrawCacheStatistics.cpp: the merged line keeps #6946's shape-update count and this PR's byte budget and byte-budget evictions (format and arguments checked, 30 and 30). On GitHub's runners (run), agc_driver_image_table_cache_bounds and the seven agc_driver_draw_cache_* tests pass 10 runs in a row on Linux, none skipped; on Windows all 8 build and skip, as the runner has no Vulkan device. The libc and libkernel suites pass on both, run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

  • Ghost of Tsushima Director's Cut (PPSA02225), by @milescoviello (comment): Linux, RTX 4070 Ti, warm cache, a 20 GiB cap, on a stack with #8115, #8121, #8213, #8608 and #9318, with and without this PR at f2c368b242.

    • Without it, the draw cache reached 3,657 entries and ~156 MiB by main's count within 10 minutes of the opening. A jemalloc profile of the same phase, at 1,158 s, put 1,011 MiB live under Driver::tagVariantRuns (from cacheDrawStages), so main's count undercounts these variants.
    • With it, the cache reached 3,696 entries and ~184 MiB by 10 minutes, then held between ~247 and ~256 MiB of the 256 MiB budget, keeping 264 to 659 entries of about 0.6 MB each.
    • The title still reaches its memory cap in the opening, from other growth (the NVIDIA driver, specialized modules, materialized results). The draw cache is no longer part of it.
  • 007 First Light (PPSA11386) 01.018.000, on Linux with an RX 9070 XT (RADV, Mesa 26.2.5, Release), by @hugodearaujo on main 11e8ad2934 with this PR's code (comment), 15 minutes on the First Launch Options screen per run: [draw-cache] holds the cache at its budget (688 entries (1447 variants, ~255.6 MiB of a 256.0 MiB budget)), with 47,412 byte-budget evictions in 12 minutes. Estimated live heap at 14 minutes: 11,351 MiB on main, 7,272 MiB with this PR, and 5,294 MiB with this PR and APS5_NO_DRAW_RELOCATION=1. hugodearaujo reads the difference between the last two as evicted entries that relocation aliases still named, the case in Limits; his rerun below, on a main with #9396, no longer shows it.

  • 007 First Light (PPSA11386) 01.018.000, rerun by @hugodearaujo on main f95acfc948, which has #9396, alone and with this PR's head fa02afeb47 merged (clean), one run each, set up as before, 15 minutes from launch with X pressed every 30 s (comment). Estimated live heap at 14 minutes: 12,170 MiB on main and 7,329 MiB with this PR; allocated in tagVariantRuns: 3,004 MiB and 253 MiB. With this PR, tagVariantRuns holds 251-254 MiB from 3 minutes to the end, where on 11e8ad2934 it climbed to 1,213 MiB, so with #9396 relocation aliases no longer keep evicted entries alive in this title. Graphics::Draw under commitDraw: 1,227 MiB on main, 172 MiB with this PR. RSS at 14 minutes: 14.6 GB on main, 9.2 GB with this PR. He observes that most of what remains with this PR is storage-texture upload buffers, about 4.9 GB in both runs.

  • 332b5f3d28, a merge of main f1f1737371 (run), as oneandonlydean asked. The one conflict was in Draw/DrawCacheStatistics.cpp, where main added Driver::OverlayCounters() at the place this PR adds Driver::DrawCacheSize(); the merge keeps both functions, and this PR's own added and removed lines are the same. agc_driver_image_table_cache_bounds, agc_driver_pipelined_fill, agc_driver_sgpr_pattern_fill_keys, agc_driver_storage_write_back_no_window, agc_performance_overlay and agc_performance_overlay_statistics pass 10 runs in a row. Linux: 6 run, 6 pass, 0 skip, 0 fail. Windows: 6 run, 1 pass, 5 skip (the Vulkan tests, with no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (161 and 264). On Windows libc passes (189) and libkernel passes 283 of 286: exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), and pass in main's own Windows job at 1829def9bf (job). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

  • Windows with a Vulkan device, by @milescoviello (comment): a Windows 11 VM with a GeForce GT 1030 (driver 582.78), WinLibs GCC 15.2.0, Release. 332b5f3d28 and its merge base, main f1f1737371, each ran the six tests above 3 times, and all six pass in every run on both. The Vulkan ones run there instead of skipping, at 1 to 7 s each.

Checklist

  • Based on current main fce8ecf162; 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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Related: #5404, #6188
  • Unblocks: none claimed (in Resident Evil Village (PPSA01556) it cuts the menu's private-memory growth by about two thirds, 654 → 223 MB/min; the rest grows outside the draw cache)
  • GPUs tested: lavapipe only so far; the change is CPU-side cache accounting
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4951767997 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9129). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T12:45:39Z. --- ### What The dispatch cache evicts by entry count or by bytes: past `APS5_DISPATCH_CACHE_BYTES` (256 MiB by default) it drops its least recently used entries. The draw cache evicts only by entry count, at 4,096 entries, so it holds whatever those entries capture. When a draw's SRT walk captures a large table of guest addresses, each variant keeps a copy of it. In Resident Evil Village (PPSA01556)'s main menu, on a local tree of `main` plus our open PRs, the draw cache's own `[draw-cache]` profile line went from ~21 MiB to ~2,149 MiB of variants (4,096 entries, ~16,000 variants) at a ~4% hit rate. **The change:** - `insertDrawEntry` evicts from the LRU end while `size > drawCacheEntries() || (size > 1 && drawCacheVariantBytes > DrawCacheBytes())`, the dispatch cache's condition. `size > 1` keeps the entry just inserted, as the dispatch cache does. - `APS5_DRAW_CACHE_BYTES` sets the budget: 256 MiB by default, 0 keeps the default, read once. Its row is in `ENVIRONMENT.md`. - Evictions over the byte budget are counted separately and shown in both `[draw-cache]` lines, e.g. `126 entries (252 variants, ~254.3 MiB of a 256.0 MiB budget), 1473 evictions in total (1473 over the byte budget)`. - `Driver::DrawCacheSize()` returns entries and bytes under the cache's lock, the twin of `DispatchCacheSize()`. **What the count covers.** `variantBytes`, shared by both caches, counted the sizes of four vectors. It now counts the capacities of every vector a variant owns (runs, words, shared, data positions and slots, run bases, shader data patches, captured words and spans), plus a `ShaderMemory`'s pages for the stamp-validated dispatch variants that keep one. Draw variants keep none. Measured per draw variant: - a 2 MiB table read back to back: +0.4%; - a stride-48 table of 32-byte records: the old count covered 75% (1,579,408 of 2,106,272 bytes), since `words` grows without a `reserve`. No variant changes size after its insert, so the add and the remove compute the same number. **Two budgets, not one shared.** The caches have their own locks and LRU lists. A shared budget would need a victim policy and a lock across both, and a phase heavy in one kind of work would evict the other's entries. The worst case is 512 MiB, and each budget can be tuned. **Limits:** - Relocation aliases held `shared_ptr`s to entries, so an entry evicted while an alias named it stayed alive outside the count: @hugodearaujo measured about 2 GB held that way at 14 minutes in 007 First Light (PPSA11386) on `main` 11e8ad2934 (see Tested). Since #9396, on `main` since 2026-10-24, an alias names a cached key and a lookup drops it once its entry is evicted, so this no longer applies when this PR merges: his rerun on `main` f95acfc948 keeps `tagVariantRuns` at about 253 MiB with this PR (see Tested). - `DrawEntry`, its decode and recipes stay outside the budget, as before. **Speed, from a scratch bench on Linux with lavapipe** (fork commit 413c412595's `VillageDrawCost`, with each draw's T# offset taken from a lane value so every variant captures ~1 MiB; 850 draws per frame over 6,800 keys, single runs): | | draw cache | µs per draw, median | peak resident memory | |---|---|---|---| | `main` | 5,215 MiB counted after 12 frames, still growing | 20,176 | 10,789 MiB | | this PR | 254 MiB of 256 | 6,812 | 5,379 MiB | | no draw cache (`APS5_NO_DRAW_SRT_ENTRIES=1`) | none | 3,755 | 4,142 MiB | - Without such captures the bench's variants are ~1 KiB and the budget is never reached: 723 against 569 µs per draw, inside the bench's spread. - At its 0% hit rate the bench still pays 6.8 against 3.75 ms per draw for caching. #5404 bypasses lookups at low hit rates, which is that case. - On Linux, part of the remaining gap to the no-cache run is glibc keeping freed ~1 MiB blocks (4,329 MiB with a fixed mmap threshold). Windows builds use mimalloc. **Overlap:** checked with `git merge-tree` against the 24 open PRs touching `Draw/DrawCache.cpp`, `Draw/Draw.cpp` or `Draw/DrawCacheStatistics.cpp`. This PR adds conflicts only with these: - #5404 bypasses lookups when hits are rare, and this bounds what its probe windows insert, so the two compose. The only shared text is one `Driver.hpp` member line; keep both sets of fields. - #6188 moves eviction into `evictDrawEntries`, so the byte clause and its counters would move there. - Our #6947 and #7642, and #6946, edit the same `[draw-cache]` append line. Whichever merges second keeps both insertions. The rest conflict with `main` already or merge cleanly. **Follow-up, not in this PR:** `tagVariantRuns` could reserve its total word count first, as the dispatch insert does: −25% of `words` capacity on the stride-48 table. ### Tested - **New case `SrtMovingPerDraw`** in the existing `agc_driver_image_table_cache_bounds`, beside `SrtMovingPerDispatch`. 64 keys, each drawn twice (a key is inserted on its second sighting), each capturing its own ~2 MiB of a 2 MiB image table, under a 16 MiB test budget. It checks after every draw that the cache stays within the budget, that the color comes from the table's T#, that evictions happen and are all byte evictions, and that an evicted key is looked up absent, inserted again and then hit with updated records. - Red, with only the loop condition put back and the test unchanged: "after draw 15 the draw cache kept 8 entries holding 16580 KiB, over its budget of 16384 KiB". - Green: "64 inserts, 57 evictions, 57 over the byte budget, at most 7 entries holding 14521 KiB". - **Linux** (Ubuntu 24.04, GCC 13.3, lavapipe, CI's flags), on the same diff before its rebase onto `main` fce8ecf162: - the draw cache, image table, recipe and relocation tests: 20 of 20 (2 skips), as on `main`; - `^agc` three times: 860, 862 and 860 of 862, against 861, 861 and 862 on `main`. The failures are `agc_driver_pipelined_fill`, `agc_driver_storage_write_back_no_window` and `agc_driver_sgpr_pattern_fill_keys`, timing tests that fail on `main` too and don't touch the draw cache; - the full CI ctest: 1,796 of 1,802 against 1,795 on `main`, the same six network failures (no IPv6 on that machine); - registration matches. - **GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39598710337), same diff before the rebase): - Linux: the case passes ×10, and the libc and libkernel suites pass. - Windows: it builds and the suites pass; the case skips there, as the Vulkan tests do on that runner. - With `main`'s code the case doesn't build, because it uses the new `DrawCacheSize()`. - **Windows with an NVIDIA GPU**, where the case runs instead of skipping, by @gdols ([comment](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6318520226)): GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, `main` 80565c594 (with #8310 to build) and this PR at f2c368b24, with `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`. - `agc_driver_image_table_cache_bounds` under `VK_LAYER_KHRONOS_validation` (SDK 1.4.363.0): 3 of 3 with no validation messages. `SrtMovingPerDraw` reports the green line above. - With only the loop condition put back, it fails 3 of 3 with the red line above. - `^agc_`: 870 passed, 3 skipped and 3 failed, the same as on `main`. They name the three as `agc_driver_sample_order*`, which they say #9056 fixes. - Not run in a title. - **MinGW** `-fsyntax-only` on the five changed sources: no errors. - `check_conventions.py` passes, with no comment lines added. - **Resident Evil Village (PPSA01556), static main menu, 11 min without input.** - Both arms: Windows, RTX 3070, the same warm shader cache, and the same environment (`APS5_LAZY_SHADER_PREPARE=1`, `APS5_NO_GPL=1`, `APS5_HOST_IMPORT_MIB=6400`, `APS5_PROFILE_DRAW=1`). - Arm A is `main` 1ff5c8ac5c with #8926. Arm B adds this change. The PR itself is on current `main`. - GPU clocks weren't held, so the frame times are rough. - Each arm's last `[draw-cache]` profile line, from its entry count on: - A: `4096 entries (18017 variants, ~2596.3 MiB), 3655 evictions in total, 18 LRU moves` - B: `282 entries (564 variants, ~255.0 MiB of a 256.0 MiB budget), 25447 evictions in total (25447 over the byte budget), 0 LRU moves` | | A: without | B: with this change | |---|---|---| | `[draw-cache]` at the end | 4,096 entries, 18,017 variants, ~2,596 MiB | 282 entries, 564 variants, ~255.0 MiB of the 256 MiB budget, every eviction over the byte budget | | hits, menu +1 to +10 min | 2.65% (4,342 of 163,617) | 0% (0 of 184,094) | | private bytes, +1 to +10 min (rate: least-squares fit over the ~13 s samples) | 19,314 → 25,087 MB, **+654 MB/min** | 18,904 → 21,078 MB, **+223 MB/min** | | present interval over the same window, median / p90 | ~2.73 s / ~3.27 s | ~2.32 s / ~2.86 s | - The budget cuts the menu's private-memory growth by about two thirds, from 654 to 223 MB/min, and keeps the cache at its budget. - The cost: the hit rate at that menu drops from 2.65% to ~0%. This pair was no slower with it. With clocks not held and ~200 presents per arm, I claim nothing stronger. - The remaining ~220 MB/min grows outside the draw cache, so this doesn't fix the menu's growth on its own. Its holder isn't found yet; that's for a separate change. - **Merged with `main` 0db47b263d** (73ec16a36f). One conflict, in the `[draw-cache]` line in `DrawCacheStatistics.cpp`: the merged line keeps #6946's shape-update count and this PR's byte budget and byte-budget evictions (format and arguments checked, 30 and 30). On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39907520800)), `agc_driver_image_table_cache_bounds` and the seven `agc_driver_draw_cache_*` tests pass 10 runs in a row on Linux, none skipped; on Windows all 8 build and skip, as the runner has no Vulkan device. The libc and libkernel suites pass on both, run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Ghost of Tsushima Director's Cut (PPSA02225)**, by @milescoviello ([comment](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6357929132)): Linux, RTX 4070 Ti, warm cache, a 20 GiB cap, on a stack with #8115, #8121, #8213, #8608 and #9318, with and without this PR at f2c368b242. - Without it, the draw cache reached 3,657 entries and ~156 MiB by `main`'s count within 10 minutes of the opening. A jemalloc profile of the same phase, at 1,158 s, put 1,011 MiB live under `Driver::tagVariantRuns` (from `cacheDrawStages`), so `main`'s count undercounts these variants. - With it, the cache reached 3,696 entries and ~184 MiB by 10 minutes, then held between ~247 and ~256 MiB of the 256 MiB budget, keeping 264 to 659 entries of about 0.6 MB each. - The title still reaches its memory cap in the opening, from other growth (the NVIDIA driver, specialized modules, materialized results). The draw cache is no longer part of it. - **007 First Light (PPSA11386)** 01.018.000, on Linux with an RX 9070 XT (RADV, Mesa 26.2.5, Release), by @hugodearaujo on `main` 11e8ad2934 with this PR's code ([comment](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6423201424)), 15 minutes on the First Launch Options screen per run: `[draw-cache]` holds the cache at its budget (`688 entries (1447 variants, ~255.6 MiB of a 256.0 MiB budget)`), with 47,412 byte-budget evictions in 12 minutes. Estimated live heap at 14 minutes: 11,351 MiB on `main`, 7,272 MiB with this PR, and 5,294 MiB with this PR and `APS5_NO_DRAW_RELOCATION=1`. hugodearaujo reads the difference between the last two as evicted entries that relocation aliases still named, the case in Limits; his rerun below, on a `main` with #9396, no longer shows it. - **007 First Light (PPSA11386)** 01.018.000, rerun by @hugodearaujo on `main` f95acfc948, which has #9396, alone and with this PR's head fa02afeb47 merged (clean), one run each, set up as before, 15 minutes from launch with X pressed every 30 s ([comment](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6425761111)). Estimated live heap at 14 minutes: 12,170 MiB on `main` and 7,329 MiB with this PR; allocated in `tagVariantRuns`: 3,004 MiB and 253 MiB. With this PR, `tagVariantRuns` holds 251-254 MiB from 3 minutes to the end, where on 11e8ad2934 it climbed to 1,213 MiB, so with #9396 relocation aliases no longer keep evicted entries alive in this title. `Graphics::Draw` under `commitDraw`: 1,227 MiB on `main`, 172 MiB with this PR. RSS at 14 minutes: 14.6 GB on `main`, 9.2 GB with this PR. He observes that most of what remains with this PR is storage-texture upload buffers, about 4.9 GB in both runs. - **332b5f3d28, a merge of `main` f1f1737371** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40625059040)), as oneandonlydean asked. The one conflict was in `Draw/DrawCacheStatistics.cpp`, where `main` added `Driver::OverlayCounters()` at the place this PR adds `Driver::DrawCacheSize()`; the merge keeps both functions, and this PR's own added and removed lines are the same. `agc_driver_image_table_cache_bounds`, `agc_driver_pipelined_fill`, `agc_driver_sgpr_pattern_fill_keys`, `agc_driver_storage_write_back_no_window`, `agc_performance_overlay` and `agc_performance_overlay_statistics` pass 10 runs in a row. Linux: 6 run, 6 pass, 0 skip, 0 fail. Windows: 6 run, 1 pass, 5 skip (the Vulkan tests, with no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (161 and 264). On Windows libc passes (189) and libkernel passes 283 of 286: `exec_arguments`, `guest_timed_join_import_libkernel_sys` and `guest_timed_join_import_libkernel_web` fail at their setup in the verify's Windows build (`FileNotFoundError` starting the title, or copying the libraries they load), and pass in `main`'s own Windows job at 1829def9bf ([job](https://github.com/boykopovar/AnyPS5/actions/runs/40627345977/job/122615375186)). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Windows with a Vulkan device**, by @milescoviello ([comment](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6460599446)): a Windows 11 VM with a GeForce GT 1030 (driver 582.78), WinLibs GCC 15.2.0, Release. 332b5f3d28 and its merge base, `main` f1f1737371, each ran the six tests above 3 times, and all six pass in every run on both. The Vulkan ones run there instead of skipping, at 1 to 7 s each. ### Checklist - [x] Based on current `main` fce8ecf162; 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Related: #5404, #6188 - [x] Unblocks: none claimed (in Resident Evil Village (PPSA01556) it cuts the menu's private-memory growth by about two thirds, 654 → 223 MB/min; the rest grows outside the draw cache) - [x] GPUs tested: lavapipe only so far; the change is CPU-side cache accounting - [x] AI-assisted: yes
gdols commented 2026-10-21 14:26:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gdols on 2026-10-21T14:26:33Z.


NVIDIA, Windows, where the new case runs instead of skipping. GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, main 80565c594 (+ #8310 to build), this PR at f2c368b24, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1.

  • agc_driver_image_table_cache_bounds under VK_LAYER_KHRONOS_validation (SDK 1.4.363.0, inserted per VK_LOADER_DEBUG=layer): passes 3 of 3 with no validation messages. SrtMovingPerDraw reports "64 inserts, 57 evictions, 57 over the byte budget, at most 7 entries holding 14521 KiB", the numbers in the description.
  • With only the loop condition put back, it fails 3 of 3: "after draw 15 the draw cache kept 8 entries holding 16580 KiB, over its budget of 16384 KiB".
  • ^agc_: 870 passed, 3 skipped and 3 failed, the same as main; the three are agc_driver_sample_order*, fixed by #9056.

Not run in a title.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318520226 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6318520226). Originally posted by [gdols](https://github.com/gdols) on 2026-10-21T14:26:33Z. --- NVIDIA, Windows, where the new case runs instead of skipping. GeForce RTX 3080, driver 616.92, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, `main` 80565c594 (+ #8310 to build), this PR at f2c368b24, `ANYPS5_REQUIRE_VULKAN=1` and `ANYPS5_NO_SHADER_CACHE=1`. - `agc_driver_image_table_cache_bounds` under `VK_LAYER_KHRONOS_validation` (SDK 1.4.363.0, inserted per `VK_LOADER_DEBUG=layer`): passes 3 of 3 with no validation messages. `SrtMovingPerDraw` reports "64 inserts, 57 evictions, 57 over the byte budget, at most 7 entries holding 14521 KiB", the numbers in the description. - With only the loop condition put back, it fails 3 of 3: "after draw 15 the draw cache kept 8 entries holding 16580 KiB, over its budget of 16384 KiB". - `^agc_`: 870 passed, 3 skipped and 3 failed, the same as `main`; the three are `agc_driver_sample_order*`, fixed by #9056. Not run in a title. AI-assisted: yes
EagleBearerYS commented 2026-10-21 14:32:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T14:32:39Z.


@gdols, thank you for running the new case on a GPU under the validation layer, with the revert check. It's now in Tested.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318625654 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9129#issuecomment-6318625654). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T14:32:39Z. --- @gdols, thank you for running the new case on a GPU under the validation layer, with the revert check. It's now in Tested.
MarcZX10 commented 2026-10-23 05:17:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:17:36Z.

Review: DISMISSED


I reviewed the scope and current evidence: the PR adds a byte budget alongside the entry limit, expands per-variant accounting, and includes a focused over-budget regression. The report now includes a Windows validation-layer run with an over-budget negative control and an independent Ghost of Tsushima measurement; hosted policy checks pass, while product jobs are skipped. Local diff whitespace, conventions, and registration checks pass. I could not run Vulkan tests in this host.

I cannot complete an integration review against the published branch yet: tools/check_main_sync.py --base upstream/main --head <head> reports it is 2 commits ahead / 1257 behind current upstream/main (merge base fce8ecf16), with a clean merge. Driver.hpp and ENVIRONMENT.md also changed on main since that base (#7233 and #9026). Please merge current main, preserve those current changes and the declared overlaps, and rerun the focused cache-bound test plus conventions on the resulting head. This is based on the repository's current-main branch rule, not on the open-PR count.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624196596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9129#pullrequestreview-5624196596). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T05:17:36Z. **Review:** DISMISSED --- I reviewed the scope and current evidence: the PR adds a byte budget alongside the entry limit, expands per-variant accounting, and includes a focused over-budget regression. The report now includes a Windows validation-layer run with an over-budget negative control and an independent Ghost of Tsushima measurement; hosted policy checks pass, while product jobs are skipped. Local diff whitespace, conventions, and registration checks pass. I could not run Vulkan tests in this host. I cannot complete an integration review against the published branch yet: `tools/check_main_sync.py --base upstream/main --head <head>` reports it is 2 commits ahead / 1257 behind current `upstream/main` (merge base `fce8ecf16`), with a clean merge. `Driver.hpp` and `ENVIRONMENT.md` also changed on main since that base (#7233 and #9026). Please merge current main, preserve those current changes and the declared overlaps, and rerun the focused cache-bound test plus conventions on the resulting head. This is based on the repository's current-main branch rule, not on the open-PR count.
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!9129
No description provided.