gpu: a compiler crash spends the rest of the frame's pipeline budget #318

Closed
ShadyUnderLight wants to merge 2 commits from upstream-pr/318 into main
ShadyUnderLight commented 2026-11-27 11:15:15 +00:00 (Migrated from github.com)

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


Refs #181

What and why

Issue #181: Metal's compiler service crashes on a few world pipelines, and each crash costs the frame about 0.85 s while Metal retries. #263 fixes the cause for the mesh and pixel pairs it dumped (invalid IR from the export order). This is the safety net the issue asks for on top of that fix: a crash must not be paid for again and again inside one frame.

Measured on one run of main (commit 38786fd, macOS 27.2.1, M5 Max, series-x, cold crash cache): nine XPC_ERROR_CONNECTION_INTERRUPTED refusals all landed in frame~2259, from 05:19:27.027 to 05:19:34.304 — 7.3 s of one frame, about 0.85 s each, all of it spent waiting for compiles that died. The frame cannot advance meanwhile, and the title's own watchdog is 30 s.

What changed

  • victory_metal::is_compiler_crash is public. It is the predicate the crash cache already used (XPC_ERROR_CONNECTION_INTERRUPTED, Compiler encountered an internal error): Metal's compiler dying on the pipeline, not a shader the host cannot run.
  • prewarm::FrameBudget gains spend() and spent_by_crash(). A frame can now be spent before its 10 s of wall time: left() is zero for the rest of it, and the next frame starts whole.
  • glue::compile_failed(name, error): when a compile ends in a compiler crash it spends the rest of the frame's budget and warns once a frame (a compile crashed Metal's compiler; no new pipelines this frame).
  • glue::compile_wait: a frame that a crash spent returns zero — it does not hand out the 20 ms ARCHIVED window that a frame merely past its time still gets. The compiler service is usually down for the rest of such a frame, and that window let 12 pipelines of one frame be refused within 0.22 s, each cached as refused and remembered by remember_crash as a crash of its own.
  • Both Err arms of Title::make_render and Title::make_compute call it.
  • docs/native-host.md: the compiler-crash section says so, with the numbers.

Nothing else changes: FIRST_BIND_BUDGET (10 s), COMPILE_DEADLINE (60 s) and the wait that a frame past its time gets are untouched, and a pipeline whose compile failed with a host error is refused exactly as before.

Tests

  • prewarm::tests::a_spent_frame_starts_the_next_one_whole: a crash-spent frame reports zero for the rest of it and spent_by_crash(); a frame merely past its time does not; the next frame clears both.
  • native::glue::a_compiler_crash_spends_the_frame_budget: the real XPC text spends the frame; a non-crash refusal (a target format the host does not know) does not.

Both fail without the change: the spend was removed and then the classification was removed, each time the relevant assertion failed, then both were restored.

Verification on a real run

Same machine, headless, series-x, cold crash cache, 230 s:

  • Before (38786fd): 9 crashes in one frame over 7.304 s, as above.
  • After (this branch): the first crash of frame 2347 (vertex a1785729710c22b3 pixel 80b896aafd2ec5f4, after a 677 ms mesh compile) spends the budget, and the frame's next pipelines are put off within 22 ms (put_off=1, 2, 4 in the log). The 16 frames that logged the warning had no second paid crash. Refusals that follow a crash in the same frame, once the service is down, come back instantly (11 of them in 47 ms) instead of waiting about 0.85 s each.

That run also ended with no GPU error and no watchdog line, but it was killed by the timer at 230 s and reached frame 2103 against 2334 in the run it is compared with, so I am not claiming that as an effect of this change.

cargo test -p victory-gpu -p victory-metal -p victory-shader (native arm64): 321 / 33 / 12 / 14 / 332 passed, 0 failed. cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings: clean. cargo xtask policy: 371 files ok. main at ce2b7860 is merged in, and the checks above are on the merged tree.

Not addressed

  • A single crash still costs the frame what Metal spends on it, up to what is left of the frame's budget (about 10 s on macOS 15). Bounding the first crash of a frame would need a per-pipeline cap, which is a different trade: it would also put off slow compiles that would have landed.
  • Pipelines attempted while the service is down are still refused and recorded by remember_crash as if they had crashed on their own. That is existing behaviour on main; this change only reduces how many are attempted. Skipping the record when the frame was already spent by a crash would be a separate change.
  • Crash-affected frames put more pipelines off (8192 in this run against 2048 in the compared one). They are made on later frames, as the put-off path already does.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5525691809 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/318). Originally posted by [ShadyUnderLight](https://github.com/ShadyUnderLight) on 2026-11-27T11:15:15Z. --- Refs #181 ## What and why Issue #181: Metal's compiler service crashes on a few world pipelines, and each crash costs the frame about 0.85 s while Metal retries. #263 fixes the cause for the mesh and pixel pairs it dumped (invalid IR from the export order). This is the safety net the issue asks for on top of that fix: a crash must not be paid for again and again inside one frame. Measured on one run of `main` (commit 38786fd, macOS 27.2.1, M5 Max, series-x, cold crash cache): nine `XPC_ERROR_CONNECTION_INTERRUPTED` refusals all landed in `frame~2259`, from 05:19:27.027 to 05:19:34.304 — 7.3 s of one frame, about 0.85 s each, all of it spent waiting for compiles that died. The frame cannot advance meanwhile, and the title's own watchdog is 30 s. ## What changed - `victory_metal::is_compiler_crash` is public. It is the predicate the crash cache already used (`XPC_ERROR_CONNECTION_INTERRUPTED`, `Compiler encountered an internal error`): Metal's compiler dying on the pipeline, not a shader the host cannot run. - `prewarm::FrameBudget` gains `spend()` and `spent_by_crash()`. A frame can now be spent before its 10 s of wall time: `left()` is zero for the rest of it, and the next frame starts whole. - `glue::compile_failed(name, error)`: when a compile ends in a compiler crash it spends the rest of the frame's budget and warns once a frame (`a compile crashed Metal's compiler; no new pipelines this frame`). - `glue::compile_wait`: a frame that a crash spent returns zero — it does not hand out the 20 ms `ARCHIVED` window that a frame merely past its time still gets. The compiler service is usually down for the rest of such a frame, and that window let 12 pipelines of one frame be refused within 0.22 s, each cached as refused and remembered by `remember_crash` as a crash of its own. - Both `Err` arms of `Title::make_render` and `Title::make_compute` call it. - `docs/native-host.md`: the compiler-crash section says so, with the numbers. Nothing else changes: `FIRST_BIND_BUDGET` (10 s), `COMPILE_DEADLINE` (60 s) and the wait that a frame past its time gets are untouched, and a pipeline whose compile failed with a host error is refused exactly as before. ## Tests - `prewarm::tests::a_spent_frame_starts_the_next_one_whole`: a crash-spent frame reports zero for the rest of it and `spent_by_crash()`; a frame merely past its time does not; the next frame clears both. - `native::glue::a_compiler_crash_spends_the_frame_budget`: the real XPC text spends the frame; a non-crash refusal (`a target format the host does not know`) does not. Both fail without the change: the spend was removed and then the classification was removed, each time the relevant assertion failed, then both were restored. ## Verification on a real run Same machine, headless, `series-x`, cold crash cache, 230 s: - Before (38786fd): 9 crashes in one frame over 7.304 s, as above. - After (this branch): the first crash of `frame 2347` (`vertex a1785729710c22b3 pixel 80b896aafd2ec5f4`, after a 677 ms mesh compile) spends the budget, and the frame's next pipelines are put off within 22 ms (`put_off=1`, `2`, `4` in the log). The 16 frames that logged the warning had no second paid crash. Refusals that follow a crash in the same frame, once the service is down, come back instantly (11 of them in 47 ms) instead of waiting about 0.85 s each. That run also ended with no GPU error and no watchdog line, but it was killed by the timer at 230 s and reached frame 2103 against 2334 in the run it is compared with, so I am not claiming that as an effect of this change. `cargo test -p victory-gpu -p victory-metal -p victory-shader` (native arm64): 321 / 33 / 12 / 14 / 332 passed, 0 failed. `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings`: clean. `cargo xtask policy`: 371 files ok. `main` at `ce2b7860` is merged in, and the checks above are on the merged tree. ## Not addressed - A single crash still costs the frame what Metal spends on it, up to what is left of the frame's budget (about 10 s on macOS 15). Bounding the first crash of a frame would need a per-pipeline cap, which is a different trade: it would also put off slow compiles that would have landed. - Pipelines attempted while the service is down are still refused and recorded by `remember_crash` as if they had crashed on their own. That is existing behaviour on `main`; this change only reduces how many are attempted. Skipping the record when the frame was already spent by a crash would be a separate change. - Crash-affected frames put more pipelines off (8192 in this run against 2048 in the compared one). They are made on later frames, as the put-off path already does.
LakshanSivakumar commented 2026-11-27 11:54:14 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:14Z.


Thank you for taking the second half of #181 and for writing down what the change does not fix.

Two questions before it leaves draft.

  1. After a crash the rest of the frame's new pipelines are put off, including ones that would have compiled. If a pipeline that crashes is needed in every frame, do the others ever get their turn? Please show the number of pipelines put off and made, by frame, over a longer run on current main (with #263 if you can).
  2. Your run used an older main. Please repeat it on ce2b7860 and post the same two numbers (crashes in one frame and time spent).

I have not run it. Counts and ids only, as before.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7217608210 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/318#issuecomment-7217608210). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T11:54:14Z. --- Thank you for taking the second half of #181 and for writing down what the change does not fix. Two questions before it leaves draft. 1. After a crash the rest of the frame's new pipelines are put off, including ones that would have compiled. If a pipeline that crashes is needed in every frame, do the others ever get their turn? Please show the number of pipelines put off and made, by frame, over a longer run on current main (with #263 if you can). 2. Your run used an older main. Please repeat it on `ce2b7860` and post the same two numbers (crashes in one frame and time spent). I have not run it. Counts and ids only, as before.
LakshanSivakumar commented 2026-11-27 13:36:27 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T13:36:27Z.


This is on main as of b639c175, merged from the head before your latest push, so GitHub still shows the PR open. Your commits are in the history under your name. Checked as part of a batch of nine PRs on main 60baf130: tests, Windows clippy, policy, a full-corpus comparison and one world run (240 s, no crash, no GPU errors, scene colour lit).

If your new head has changes beyond a rebase, please rebase it onto main so only those remain; otherwise please close this. Thank you.

On my question about whether other pipelines ever get their turn: a remembered crash is refused with a message that is not counted as a crash, so it does not take the frame's budget again. That answers it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7219707619 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/318#issuecomment-7219707619). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T13:36:27Z. --- This is on main as of b639c175, merged from the head before your latest push, so GitHub still shows the PR open. Your commits are in the history under your name. Checked as part of a batch of nine PRs on main 60baf130: tests, Windows clippy, policy, a full-corpus comparison and one world run (240 s, no crash, no GPU errors, scene colour lit). If your new head has changes beyond a rebase, please rebase it onto main so only those remain; otherwise please close this. Thank you. On my question about whether other pipelines ever get their turn: a remembered crash is refused with a message that is not counted as a crash, so it does not take the frame's budget again. That answers it.
ShadyUnderLight commented 2026-11-27 13:43:25 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ShadyUnderLight on 2026-11-27T13:43:25Z.


Thank you — I see 3a03e6ed in main (merged as 5cdb9e05), so the fix is in and there is nothing left to review here.

The only thing in this head beyond that merge is the diagnostic line I added while working on your put-off/made question: the frame log had no pipeline counters. I have split that out as its own change against current main: #350. Nothing else remains, so I am closing this one.

On the remembered crash: agreed, and thank you for checking it. That refusal comes from the crash memory, its message is not one of the two a crash is recognised by, so it does not spend the frame budget again and the frame.s other pipelines get their turn.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7219864380 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/318#issuecomment-7219864380). Originally posted by [ShadyUnderLight](https://github.com/ShadyUnderLight) on 2026-11-27T13:43:25Z. --- Thank you — I see `3a03e6ed` in `main` (merged as `5cdb9e05`), so the fix is in and there is nothing left to review here. The only thing in this head beyond that merge is the diagnostic line I added while working on your put-off/made question: the frame log had no pipeline counters. I have split that out as its own change against current `main`: #350. Nothing else remains, so I am closing this one. On the remembered crash: agreed, and thank you for checking it. That refusal comes from the crash memory, its message is not one of the two a crash is recognised by, so it does not spend the frame budget again and the frame.s other pipelines get their turn.

Pull request closed

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!318
No description provided.