fix(metal,gpu): guard compute/mesh pipeline compiles, flush archive, and budget thread_pipe #243

Merged
Sheffy007 merged 1 commit from upstream-pr/243 into main 2026-11-27 04:26:20 +00:00
Sheffy007 commented 2026-11-27 03:57:14 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T03:57:14Z.


Summary

Closes three gaps where compute and mesh pipelines could block the TITLE lock for multiple seconds or lose compiled pipeline states across runs (#15, #180, #181):

  1. 10 s compile deadline and crash memory for compute & mesh pipelines (victory-metal):
    • Extends COMPILE_DEADLINE and disk::crashed / remember_crash from vertex render pipelines to compute pipelines (archive::compile_compute, Metal::create_compute_pipeline*) and mesh render pipelines (archive::compile_mesh), preventing slow or crashing MTLCompilerService runs from holding TITLE past the 30 s watchdog.
  2. Reliable MTLBinaryArchive persistence without Drop (victory_metal::archive):
    • Because Title lives inside static TITLE, Archive::drop never runs when the process exits or is ended by the watchdog, and added_one only saved when a subsequent pipeline arrived >= 5 s after the previous save.
    • Flushes immediately after any single compile taking >= 200 ms (SAVE_SLOW_COMPILE) so multi-second world compute pipelines are persisted right away, and adds Archive::flush_due at command-buffer commit so trailing additions flush once SAVE_EVERY elapses even if no further pipelines compile.
  3. Frame-budget deferral for glue::thread_pipe (victory-gpu):
    • Applies FIRST_BIND_BUDGET + put_off to Options::thread_counts compute translations (Shader::threads_ready, Shader::native_threads_shader), matching pipe and guess.

Tests

  • archive::tests::compute_archive_hits_after_flush_across_reloaded_libraries (verifies FailOnBinaryArchiveMiss hits across separate load_library temp URLs after flush_due)
  • Existing victory-metal, victory-gpu, victory-shader, victory-hle, victory, and xtask test suites pass, along with Windows clippy (--all-targets and --all-features) and cargo xtask policy.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5520922691 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/243). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-27T03:57:14Z. --- ## Summary Closes three gaps where compute and mesh pipelines could block the `TITLE` lock for multiple seconds or lose compiled pipeline states across runs (#15, #180, #181): 1. **10 s compile deadline and crash memory for compute & mesh pipelines (`victory-metal`):** - Extends `COMPILE_DEADLINE` and `disk::crashed` / `remember_crash` from vertex render pipelines to compute pipelines (`archive::compile_compute`, `Metal::create_compute_pipeline*`) and mesh render pipelines (`archive::compile_mesh`), preventing slow or crashing `MTLCompilerService` runs from holding `TITLE` past the 30 s watchdog. 2. **Reliable `MTLBinaryArchive` persistence without `Drop` (`victory_metal::archive`):** - Because `Title` lives inside `static TITLE`, `Archive::drop` never runs when the process exits or is ended by the watchdog, and `added_one` only saved when a *subsequent* pipeline arrived >= 5 s after the previous save. - Flushes immediately after any single compile taking `>= 200 ms` (`SAVE_SLOW_COMPILE`) so multi-second world compute pipelines are persisted right away, and adds `Archive::flush_due` at command-buffer commit so trailing additions flush once `SAVE_EVERY` elapses even if no further pipelines compile. 3. **Frame-budget deferral for `glue::thread_pipe` (`victory-gpu`):** - Applies `FIRST_BIND_BUDGET` + `put_off` to `Options::thread_counts` compute translations (`Shader::threads_ready`, `Shader::native_threads_shader`), matching `pipe` and `guess`. ## Tests - `archive::tests::compute_archive_hits_after_flush_across_reloaded_libraries` (verifies `FailOnBinaryArchiveMiss` hits across separate `load_library` temp URLs after `flush_due`) - Existing `victory-metal`, `victory-gpu`, `victory-shader`, `victory-hle`, `victory`, and `xtask` test suites pass, along with Windows clippy (`--all-targets` and `--all-features`) and `cargo xtask policy`.
LakshanSivakumar commented 2026-11-27 04:26:17 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T04:26:17Z.

Review: APPROVED


Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). The deadline path and the thread_pipe budget match the render path. Thanks!

One thing to watch, not blocking: added_one now serializes the whole binary archive synchronously after every compile of 200 ms or more. On a cold first world frame with many slow compiles, that is repeated full-archive writes on the frame thread inside the title's 30 s watchdog window. If it shows up in a cold run, raising SAVE_SLOW_COMPILE or limiting the save to once a second would cover it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6083480128 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/243#pullrequestreview-6083480128). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T04:26:17Z. **Review:** APPROVED --- Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). The deadline path and the thread_pipe budget match the render path. Thanks! One thing to watch, not blocking: `added_one` now serializes the whole binary archive synchronously after every compile of 200 ms or more. On a cold first world frame with many slow compiles, that is repeated full-archive writes on the frame thread inside the title's 30 s watchdog window. If it shows up in a cold run, raising `SAVE_SLOW_COMPILE` or limiting the save to once a second would cover it.
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!243
No description provided.