perf: draw cache entry limit thrashes Snoopy (PPSA28795), but a larger limit slows Another Crab's Treasure #26586

Closed
opened 2026-11-24 06:36:24 +00:00 by JJenkx · 0 comments
JJenkx commented 2026-11-24 06:36:24 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-24T06:36:24Z.


What happens

Snoopy and the Great Mystery Club (PPSA28795) runs at about 11 FPS in the backyard. The draw cache is full at its 65,536-entry limit and keeps evicting entries that would be hit again. Raising only the entry count (APS5_DRAW_CACHE_ENTRIES=262144, byte budget unchanged) gives +39 % presents on this title. But the same setting is about 3 % slower on Another Crab's Treasure (PPSA20423), so a flat default raise like #21467's (4096 → 65536) trades one title against another here. This looks like an admission/replacement question rather than a size question, so I'm filing measurements, not a PR.

System

Windows 11 Enterprise 22621, Ryzen 9 5950X, RX 6700 XT (AMD 26.11.2), WinLibs GCC 15.2 UCRT r7, Release. Snoopy: the runtime's main 2ef49858bb libraries. Crab: main 678b294c89. Arms differ only in the environment variable, which is cleared before every run.

Snoopy: why lookups miss

APS5_TRACE_DRAW_CACHE=1, backyard, steady 10 s lines:

Lookups Hits No entry: user words/pointers only No entry: evicted Seen but never inserted / new registers
248,546 5.5 % 122,737 108,570 ~1,000
251,583 4.9 % 124,068 111,411 ~1,000
250,403 6.2 % 122,855 108,583 ~1,000
259,261 9.7 % 119,595 110,373 ~1,000

An earlier profiling run (APS5_PROFILE_DRAW=1, main f784587f30 + #26360, same scene) shows the cache pinned at 65,536 entries holding ~149 MiB of its 256 MiB budget. It made 179,541 inserts per 10 s, 0 shape updates, 1,931,876 evictions in total and 0 over the byte budget, so the entry count binds, not memory. In a trace-only capture on main f784587f30, about half of all draws (33,062 of 70,267 in a 20 s window) pay Driver.Draw.shader_compile_and_link at ~29 µs each, ~34 ms per frame, on a 99 % busy queue worker 0.

The user-words half is #9755's case (and #20130's). The evicted half is the new part: on FAR (PPSA03766) evictions were only 6,600–14,600 per 10 s, while here they are about 110,000.

Snoopy: entry count A/B

Trace-only (APS5_TRACE_SECONDS=100:20), standard 180 s route, two jobs:

Setting Runs Presents per 20 s Frame p50 (ms) GPU busy per present (ms)
default (65,536 entries, 256 MiB) 3 236, 234, 224 83.9, 84.7, 91.5 43.8, 47.7, 55.4
APS5_DRAW_CACHE_ENTRIES=262144 only 2 319, 324 61.9, 60.9 33.0, 31.6
262,144 entries + APS5_DRAW_CACHE_BYTES=1073741824 2 319, 321 60.8, 61.1 35.9, 34.5

The entry count alone gives the whole gain (+39 % presents, about −25 ms p50); the larger byte budget adds nothing. One further default arm aborted at 13.7 s on an unrelated presentation error and is not counted.

Crab: the same setting

Beach, 420 s runs, APS5_TRACE_SECONDS=330:10 only, main 678b294c89, two jobs, order default, entries, entries, default, entries, default, default, entries:

Setting Runs Presents per 10 s Frame p50 (ms) Mean p50 / p90 (ms)
default 4 116, 112, 114, 111 84.9, 89.3, 87.8, 89.6 87.9 / 96.6
APS5_DRAW_CACHE_ENTRIES=262144 4 107, 115, 113, 104 93.2, 86.6, 86.6, 95.7 90.5 / 101.1

Two of the four 262,144 runs are slower than every default run, and the mean p50 is 2.6 ms (3 %) worse. That is not decisive with this spread, but it is enough not to propose 262,144 as a flat default. Crab's misses are dominated by moved user-data pointers (#25535), so a larger LRU mostly keeps more one-shot entries there.

Where I'd look

  • cacheDrawStages (DrawCapture.cpp) uses replaceShape only when the key is not admitted. On Snoopy the profile reports 0 shape updates against 179,541 inserts, so same-shape draws with a new key add entries instead of replacing their predecessor. If those are the one-shot entries, they would be what evicts the reusable ones.
  • An admission or segmented policy (keep entries that have hit apart from never-hit ones) would let Snoopy's reusable entries survive without growing the cache for titles like Crab.

I haven't confirmed the first point beyond the counters. If useful, I can run any candidate policy on both titles with the same setup.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6576150679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/26586). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-24T06:36:24Z. --- ### What happens Snoopy and the Great Mystery Club (PPSA28795) runs at about 11 FPS in the backyard. The draw cache is full at its 65,536-entry limit and keeps evicting entries that would be hit again. Raising only the entry count (`APS5_DRAW_CACHE_ENTRIES=262144`, byte budget unchanged) gives **+39 % presents** on this title. But the same setting is about **3 % slower** on Another Crab's Treasure (PPSA20423), so a flat default raise like #21467's (4096 → 65536) trades one title against another here. This looks like an admission/replacement question rather than a size question, so I'm filing measurements, not a PR. ### System Windows 11 Enterprise 22621, Ryzen 9 5950X, RX 6700 XT (AMD 26.11.2), WinLibs GCC 15.2 UCRT r7, Release. Snoopy: the runtime's `main` `2ef49858bb` libraries. Crab: `main` `678b294c89`. Arms differ only in the environment variable, which is cleared before every run. ### Snoopy: why lookups miss `APS5_TRACE_DRAW_CACHE=1`, backyard, steady 10 s lines: | Lookups | Hits | No entry: user words/pointers only | No entry: evicted | Seen but never inserted / new registers | |---|---|---|---|---| | 248,546 | 5.5 % | 122,737 | 108,570 | ~1,000 | | 251,583 | 4.9 % | 124,068 | 111,411 | ~1,000 | | 250,403 | 6.2 % | 122,855 | 108,583 | ~1,000 | | 259,261 | 9.7 % | 119,595 | 110,373 | ~1,000 | An earlier profiling run (`APS5_PROFILE_DRAW=1`, `main` `f784587f30` + #26360, same scene) shows the cache pinned at 65,536 entries holding ~149 MiB of its 256 MiB budget. It made 179,541 inserts per 10 s, **0 shape updates**, 1,931,876 evictions in total and **0 over the byte budget**, so the entry count binds, not memory. In a trace-only capture on `main` `f784587f30`, about half of all draws (33,062 of 70,267 in a 20 s window) pay `Driver.Draw.shader_compile_and_link` at ~29 µs each, ~34 ms per frame, on a 99 % busy queue worker 0. The user-words half is #9755's case (and #20130's). The evicted half is the new part: on FAR (PPSA03766) evictions were only 6,600–14,600 per 10 s, while here they are about 110,000. ### Snoopy: entry count A/B Trace-only (`APS5_TRACE_SECONDS=100:20`), standard 180 s route, two jobs: | Setting | Runs | Presents per 20 s | Frame p50 (ms) | GPU busy per present (ms) | |---|---|---|---|---| | default (65,536 entries, 256 MiB) | 3 | 236, 234, 224 | 83.9, 84.7, 91.5 | 43.8, 47.7, 55.4 | | `APS5_DRAW_CACHE_ENTRIES=262144` only | 2 | 319, 324 | 61.9, 60.9 | 33.0, 31.6 | | 262,144 entries + `APS5_DRAW_CACHE_BYTES=1073741824` | 2 | 319, 321 | 60.8, 61.1 | 35.9, 34.5 | The entry count alone gives the whole gain (+39 % presents, about −25 ms p50); the larger byte budget adds nothing. One further default arm aborted at 13.7 s on an unrelated presentation error and is not counted. ### Crab: the same setting Beach, 420 s runs, `APS5_TRACE_SECONDS=330:10` only, `main` `678b294c89`, two jobs, order default, entries, entries, default, entries, default, default, entries: | Setting | Runs | Presents per 10 s | Frame p50 (ms) | Mean p50 / p90 (ms) | |---|---|---|---|---| | default | 4 | 116, 112, 114, 111 | 84.9, 89.3, 87.8, 89.6 | 87.9 / 96.6 | | `APS5_DRAW_CACHE_ENTRIES=262144` | 4 | 107, 115, 113, 104 | 93.2, 86.6, 86.6, 95.7 | 90.5 / 101.1 | Two of the four 262,144 runs are slower than every default run, and the mean p50 is 2.6 ms (3 %) worse. That is not decisive with this spread, but it is enough not to propose 262,144 as a flat default. Crab's misses are dominated by moved user-data pointers (#25535), so a larger LRU mostly keeps more one-shot entries there. ### Where I'd look - `cacheDrawStages` (`DrawCapture.cpp`) uses `replaceShape` only when the key is not admitted. On Snoopy the profile reports 0 shape updates against 179,541 inserts, so same-shape draws with a new key add entries instead of replacing their predecessor. If those are the one-shot entries, they would be what evicts the reusable ones. - An admission or segmented policy (keep entries that have hit apart from never-hit ones) would let Snoopy's reusable entries survive without growing the cache for titles like Crab. I haven't confirmed the first point beyond the counters. If useful, I can run any candidate policy on both titles with the same setup. AI-assisted: yes.
Sign in to join this conversation.
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#26586
No description provided.