gpu: size the shader prewarm pool by the performance cores (smooth cold boots) #335

Manually merged
github merged 1 commit from github-bot/gh-335 into main 2026-11-27 16:23:13 +00:00 AGit
Owner

@⁠derz92 on GitHub · 2026-11-27 12:26 UTC · original
derz92:fix/prewarm-performance-cores → main · +52 −9 · 3 files · 1 commits · merged 2026-11-27 16:14 UTC

What this changes

Refs #332.

prewarm::pool_size sizes the shader prewarm pool from the performance cores (hw.perflevel0.physicalcpu) minus two, at least two, instead of all cores minus two. On an 18-core M5 Max (6 performance cores) that is 4 workers instead of 16. Where the kinds of core aren't known it stays all cores minus two. VICTORY_PREWARM_WORKERS=<n> overrides the number, for checking other Macs. The workers keep the lowest priority of the default QoS class. docs/native-host.md says so now: it still said "utility QoS class", which the code no longer uses.

Why: on a cold cache the 16 workers take the cores the title's own threads need, and the boot movie and first menus stutter all through the first ~50 s.

How it was tested

Apple M5 Max (6 + 12 cores), 36 GB, macOS 26.5, --console series-s, VICTORY_METAL_RESIDENCY_SETS=heap. Every cold run used a fresh, empty VICTORY_CACHE_DIR. Pacing comes from VICTORY_COUNT_GREEN=1 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, 16 workers (main) 39 of 52 ~216 1.9 s
Cold, 4 workers (this PR) 7 of 43 ~50 0.85 s
Warm, 16 workers (main), for reference 10 of 47 ~70 1.7 s
  • The world still loads. In a cold 4-worker run into the story load, the title reached frame 2538 at 170 s with no watchdog fault. The first world frame's late shaders were put off as on main (1024 put off). About 5,200 shaders were still queued at the end, and the pool works through them in the background.
  • The remaining sub-second hitch at the start of the intro movie is the same warm or cold. Thread dumps during it show ~12 title threads in title code (image+0x500a5bb) and the main thread waiting on them: the title's own work.
  • Tried and rejected: 4 workers in the default class plus 12 in QOS_CLASS_UTILITY. That was much worse, with freezes of up to 7 s, and it never reached the story load. A title thread that needs a shader a starved utility worker is translating waits on that worker's OnceLock.

Checks:

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: all pass except host_posix::ucrt::tests::dlls_that_are_not_the_c_runtime_are_left_alone, which fails the same way on main at 86786a72 without this change.
  • cargo test -p victory-gpu --lib prewarm (arm64): 4 passed. the_pool_leaves_two_cores becomes the_pool_is_the_performance_cores_but_two, on a pure pool_for(cores, performance) so it doesn't depend on the machine it runs on.
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • cargo xtask policy
  • Ran the game: cold and warm boots, and one cold run into the world, as above.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none: this is host scheduling)
  • New diagnostics are behind a VICTORY_* variable and documented (VICTORY_PREWARM_WORKERS, in docs/native-host.md)
**@⁠derz92** on GitHub · 2026-11-27 12:26 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/335) `derz92:fix/prewarm-performance-cores` → `main` · +52 −9 · 3 files · 1 commits · merged 2026-11-27 16:14 UTC ## What this changes Refs #332. `prewarm::pool_size` sizes the shader prewarm pool from the **performance cores** (`hw.perflevel0.physicalcpu`) minus two, at least two, instead of all cores minus two. On an 18-core M5 Max (6 performance cores) that is 4 workers instead of 16. Where the kinds of core aren't known it stays all cores minus two. `VICTORY_PREWARM_WORKERS=<n>` overrides the number, for checking other Macs. The workers keep the lowest priority of the default QoS class. docs/native-host.md says so now: it still said "utility QoS class", which the code no longer uses. **Why:** on a cold cache the 16 workers take the cores the title's own threads need, and the boot movie and first menus stutter all through the first ~50 s. ## How it was tested Apple M5 Max (6 + 12 cores), 36 GB, macOS 26.5, `--console series-s`, `VICTORY_METAL_RESIDENCY_SETS=heap`. Every cold run used a fresh, empty `VICTORY_CACHE_DIR`. Pacing comes from `VICTORY_COUNT_GREEN=1` 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, 16 workers (main) | 39 of 52 | ~216 | 1.9 s | | **Cold, 4 workers (this PR)** | **7 of 43** | **~50** | **0.85 s** | | Warm, 16 workers (main), for reference | 10 of 47 | ~70 | 1.7 s | - **The world still loads.** In a cold 4-worker run into the story load, the title reached frame 2538 at 170 s with no watchdog fault. The first world frame's late shaders were put off as on main (1024 put off). About 5,200 shaders were still queued at the end, and the pool works through them in the background. - **The remaining sub-second hitch** at the start of the intro movie is the same warm or cold. Thread dumps during it show ~12 title threads in title code (`image+0x500a5bb`) and the main thread waiting on them: the title's own work. - **Tried and rejected:** 4 workers in the default class plus 12 in `QOS_CLASS_UTILITY`. That was much worse, with freezes of up to 7 s, and it never reached the story load. A title thread that needs a shader a starved utility worker is translating waits on that worker's `OnceLock`. Checks: - [x] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory`: all pass except `host_posix::ucrt::tests::dlls_that_are_not_the_c_runtime_are_left_alone`, which fails the same way on main at 86786a72 without this change. - [x] `cargo test -p victory-gpu --lib prewarm` (arm64): 4 passed. `the_pool_leaves_two_cores` becomes `the_pool_is_the_performance_cores_but_two`, on a pure `pool_for(cores, performance)` so it doesn't depend on the machine it runs on. - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - [x] `cargo xtask policy` - [x] Ran the game: cold and warm boots, and one cold run into the world, as above. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md (none: this is host scheduling) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (`VICTORY_PREWARM_WORKERS`, in docs/native-host.md)
On a cold shader cache the pool of all cores but two (16 on an 18-core
M5 Max) took the cores the title's own threads need, and the boot movie
and menus dropped about 216 frames in their first 50 s. The pool is now
the performance cores (hw.perflevel0.physicalcpu) but two, at least two:
4 on an M5 Max, where the same cold start dropped about 50 and the world
still loaded. VICTORY_PREWARM_WORKERS=<n> sets the number.

Refs #332
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:27:00 +00:00
github-bot force-pushed github-bot/gh-335 from a9e39aa02b to 50b8ff5a5b 2026-11-27 13:54:51 +00:00 Compare
github-bot referenced this pull request from a commit 2026-11-27 16:23:10 +00:00
github manually merged commit 1aa62d96ef into main 2026-11-27 16:23:13 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 16:15 UTC · original

Merged in 4cf84c83. Before pushing I ran the tests (native arm64), Windows clippy, the policy check, a release build, and one headless game run of the exact tree (170 s, Series S): menus at 30 fps, the world entered at about 81 s and kept presenting to the end at about 1 frame a second, 0 GPU errors, no crash. Thanks.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 16:15 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/335#issuecomment-7223041396) Merged in 4cf84c83. Before pushing I ran the tests (native arm64), Windows clippy, the policy check, a release build, and one headless game run of the exact tree (170 s, Series S): menus at 30 fps, the world entered at about 81 s and kept presenting to the end at about 1 frame a second, 0 GPU errors, no crash. Thanks.
This discussion has been locked. Commenting is limited to contributors.
No description provided.