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

Merged
derz92 merged 1 commit from upstream-pr/335 into main 2026-11-27 16:14:20 +00:00
derz92 commented 2026-11-27 12:26:43 +00:00 (Migrated from github.com)

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


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)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5526606391 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/335). Originally posted by [derz92](https://github.com/derz92) on 2026-11-27T12:26:43Z. --- ## 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)
LakshanSivakumar commented 2026-11-27 16:15:18 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:15:18Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7223041396 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/335#issuecomment-7223041396). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T16:15:18Z. --- 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.
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
LakshanSivakumar/Native-Victory-macOS!335
No description provided.