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

Manually merged
github merged 1 commit from github-bot/gh-243 into gh-pr/243/base 2026-11-27 04:27:17 +00:00 AGit
Owner

@⁠Sheffy007 on GitHub · 2026-11-27 03:57 UTC · original
Sheffy007:fix/compute-pipeline-deadline-and-archive-flush → main · +185 −53 · 6 files · 1 commits · merged 2026-11-27 04:26 UTC

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.
**@⁠Sheffy007** on GitHub · 2026-11-27 03:57 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/243) `Sheffy007:fix/compute-pipeline-deadline-and-archive-flush` → `main` · +185 −53 · 6 files · 1 commits · merged 2026-11-27 04:26 UTC ## 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`.
Compile compute and mesh pipelines with the 10 s COMPILE_DEADLINE and compiler-crash persistence (archive::compile_compute, compile_mesh, disk::crashed), matching vertex render pipelines so slow or crashing Metal compiler runs cannot hold the TITLE lock past the title's watchdog.

Flush the Metal binary archive immediately after slow compiles (>= 200 ms) and at submission once SAVE_EVERY has elapsed with pending additions (Archive::flush_due), since Title lives in a static and never runs Drop.

Put off unready thread-count compute translations in glue::thread_pipe once the frame's FIRST_BIND_BUDGET is spent.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 04:00:48 +00:00
github-bot force-pushed github-bot/gh-243 from decd2ae03c to ecc323f35d 2026-11-27 04:11:29 +00:00 Compare
github-bot changed target branch from main to gh-pr/243/base 2026-11-27 04:27:15 +00:00
github manually merged commit ecc323f35d into gh-pr/243/base 2026-11-27 04:27:17 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 04:26 UTC · original · approved these changes

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.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 04:26 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/243#pullrequestreview-6083480128) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.