Cold shader cache: the prewarm pool takes the cores the boot needs (boot movie and menus stutter) #332

Closed
opened 2026-11-27 12:23:19 +00:00 by derz92 · 3 comments
derz92 commented 2026-11-27 12:23:19 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T12:23:19Z.


Summary

On a cold shader cache (the first launch, or any launch after the cache key changes), the boot movie and the first menus stutter badly. The shader prewarm pool runs one worker per core but two (16 on an 18-core M5 Max). Even at the lowest priority of the default QoS class, those workers take the cores the title's own threads need, so frames are dropped every second for the first ~50 s.

If the pool is the performance cores minus two (4 on an M5 Max), a cold first launch is smoother than a warm launch was before, and the world still loads.

Numbers

Apple M5 Max (6 + 12 cores), 36 GB, macOS 26.5, --console series-s, VICTORY_METAL_RESIDENCY_SETS=heap. Each cold run uses a fresh, empty VICTORY_CACHE_DIR. Pacing comes from VICTORY_COUNT_GREEN=1 (present pacing ... longest_ms) over the first 45–50 s: boot movie, start screen, first menus.

Run Seconds with a gap > 50 ms Frames dropped (vs 30/s) Longest gap
Cold cache, 16 workers (main) 39 of 52 ~216 1.9 s
Cold cache, 4 workers 7 of 43–50 ~50–65 0.85–1.3 s
Warm cache, 16 workers (main), for reference 10 of 47 ~70 1.7 s

The remaining sub-second hitch at the start of the intro movie is the title's own parallel job: thread dumps during it show about 12 title threads in title code at image+0x500a5bb, with the main thread waiting on them. It is the same with the cache warm.

The world still loads with 4 workers. In a cold run into the story load, the title reached frame 2538 at 170 s with no watchdog fault. Shaders the first world frame needs before the pool reaches them are put off (glue::put_off, 1024 put off in that run), as on main. The pool had about 5,200 shaders left at the end.

What did not work: keeping 4 workers in the default class and moving the other 12 to QOS_CLASS_UTILITY was much worse: freezes of up to 7 s, and the run never reached the story load. A title thread that needs a shader a starved utility worker is translating waits on that worker's OnceLock (priority inversion). The comment on lower_priority already warned against the utility class.

Proposed change

prewarm::pool_size: the performance cores (hw.perflevel0.physicalcpu) minus two, at least two; all cores minus two where the kinds of core are not known. Plus VICTORY_PREWARM_WORKERS=<n> to override it, for testing on other Macs. I'd like to take this one and will send a PR.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6646353230 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/332). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T12:23:19Z. --- ## Summary On a cold shader cache (the first launch, or any launch after the cache key changes), the boot movie and the first menus stutter badly. The shader prewarm pool runs one worker per core but two (16 on an 18-core M5 Max). Even at the lowest priority of the default QoS class, those workers take the cores the title's own threads need, so frames are dropped every second for the first ~50 s. If the pool is the **performance cores minus two** (4 on an M5 Max), a cold first launch is smoother than a warm launch was before, and the world still loads. ## Numbers Apple M5 Max (6 + 12 cores), 36 GB, macOS 26.5, `--console series-s`, `VICTORY_METAL_RESIDENCY_SETS=heap`. Each cold run uses a fresh, empty `VICTORY_CACHE_DIR`. Pacing comes from `VICTORY_COUNT_GREEN=1` (`present pacing ... longest_ms`) over the first 45–50 s: boot movie, start screen, first menus. | Run | Seconds with a gap > 50 ms | Frames dropped (vs 30/s) | Longest gap | |---|---|---|---| | Cold cache, 16 workers (main) | 39 of 52 | ~216 | 1.9 s | | Cold cache, 4 workers | 7 of 43–50 | ~50–65 | 0.85–1.3 s | | Warm cache, 16 workers (main), for reference | 10 of 47 | ~70 | 1.7 s | The remaining sub-second hitch at the start of the intro movie is the title's own parallel job: thread dumps during it show about 12 title threads in title code at `image+0x500a5bb`, with the main thread waiting on them. It is the same with the cache warm. **The world still loads with 4 workers.** In a cold run into the story load, the title reached frame 2538 at 170 s with no watchdog fault. Shaders the first world frame needs before the pool reaches them are put off (`glue::put_off`, 1024 put off in that run), as on main. The pool had about 5,200 shaders left at the end. **What did not work:** keeping 4 workers in the default class and moving the other 12 to `QOS_CLASS_UTILITY` was much worse: freezes of up to 7 s, and the run never reached the story load. A title thread that needs a shader a starved utility worker is translating waits on that worker's `OnceLock` (priority inversion). The comment on `lower_priority` already warned against the utility class. ## Proposed change `prewarm::pool_size`: the performance cores (`hw.perflevel0.physicalcpu`) minus two, at least two; all cores minus two where the kinds of core are not known. Plus `VICTORY_PREWARM_WORKERS=<n>` to override it, for testing on other Macs. I'd like to take this one and will send a PR.
derz92 commented 2026-11-27 12:23:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-27T12:23:23Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7218184199 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/332#issuecomment-7218184199). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T12:23:23Z. --- /claim
github-actions[bot] commented 2026-11-27 12:23:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-27T12:23:35Z.


Claimed by @derz92. Open a draft pull request with Refs #332 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7218188268 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/332#issuecomment-7218188268). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T12:23:35Z. --- Claimed by @derz92. Open a draft pull request with `Refs #332` in its description within 24 hours, or the claim expires.
LakshanSivakumar commented 2026-11-28 00:35:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-28T00:35:48Z.


Thank you for the numbers. The prewarm pool is now the performance cores minus two (at least two), so 4 on an M5 Max, and VICTORY_PREWARM_WORKERS=<n> sets it by hand (#335, on main). You measured about 216 dropped frames in the first 50 s before and about 50 after. I did not measure it myself. Closing. Please retest a cold first launch on a6a58361 and tell me if the boot movie and menus are smooth. Reopen if not.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231038294 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/332#issuecomment-7231038294). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T00:35:48Z. --- Thank you for the numbers. The prewarm pool is now the performance cores minus two (at least two), so 4 on an M5 Max, and `VICTORY_PREWARM_WORKERS=<n>` sets it by hand (#335, on main). You measured about 216 dropped frames in the first 50 s before and about 50 after. I did not measure it myself. Closing. Please retest a cold first launch on a6a58361 and tell me if the boot movie and menus are smooth. Reopen if not.
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
LakshanSivakumar/Native-Victory-macOS#332
No description provided.