Skip to content

Reuse pipeline archives across shader-chain updates on macOS and iOS - #895

Closed
thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/pipeline-archive-reuse
Closed

thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/pipeline-archive-reuse

Conversation

@thehobbit85

@thehobbit85 thehobbit85 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Rebuilding an unchanged NSP after a shader-chain update can spend several minutes recompiling the offline pipeline archive even when its shader libraries and pipeline settings are identical. The old cache key included the chain label, profile stamp, whole builder source, and absolute library paths.

Key the shared macOS/iOS archive builder by its compiler inputs: the complete generated pipeline configuration with library paths normalized to stable labels, referenced library names and bytes, GPU architecture, target platform, minimum OS, and Metal translator version. Reflection-chain validation still runs before reuse; runtime stamps and remainder lists refresh on a hit. Changed compiler inputs and missing archives still rebuild. Existing keys require one warm-up rebuild.

The PR contains only archive reuse, tests, and documentation. It preserves upstream's disk-space checks and temporary-file cleanup. See the mechanism and LegendsZA measurements.

Benchmark

Pokémon Legends: Z-A 2.0.2 (v393216), title ID 0100F43008C44000; Apple M2 Max, macOS 26.6, Xcode 27.0 / AIR-TT 32023.921, native arm64 Python. Measured on 8dfa9c6d8b0e plus this cache change, before rebasing the PR onto upstream main.

Measurement (one run each) Elapsed
Legacy archive builder after the chain update 462.78 s (7m43s)
Content-based reuse, same post-update compiler inputs 10.10 s
Archive-stage saving 452.68 s (7m33s), 97.8%
Complete Mac app rebuild using reuse 785.62 s (13m06s)

The controlled update was a temporary comment in a chain tool, changing chain a7dbbce711c3 to 5b1637c7f097 while leaving shader output unchanged. Both archive commands consumed the same 26,029 bases and referenced library bytes. The legacy key changed; the content key did not. The cached 1,217 MB archive retained its SHA-256 and modification time. The temporary source edit and chain header were restored.

Warm-up is excluded. The legacy comparison was primed with the verified warm archive and the exact old-format key, and a real legacy invocation confirmed a hit before the update. After the update, the legacy builder actually recompiled its archive. The full app run spent 4m59s extracting shaders, 5m10s preparing shaders (all 28,603 restored from cache), 16s in the archive stage, and 2m02s packaging/signing. These are stage measurements and one complete new-builder run, not a paired total-build speedup or a promise of these savings when shader output changes.

The build used --platform mac-app --allow-other-metal because the installed Xcode 27.0 differs from the locked 27.2. Commands, hashes, logs, and results remain beside the local game under <build>/performance-research/pipeline-archive-reuse/.

Checked

  • Publication checks on b4880a9d83bf: all 116 Python test files in dm/tools/tests, dm/ios/tests, and dm/gfx/tests passed (1,063 tests, 13 skipped), using native arm64 Python, CI's DM_GAME/translator settings, and access to the Metal tools. lint_python.py --against origin/main: 391 baseline findings, zero new or stale findings. make -C dm/gfx/tests GAME=0100F43008C44000 check_t_pso_bundle: 52 checks, zero failures. git diff --check passed.
  • Behavioral coverage checks reuse and metadata refresh on both macOS and iOS, library/entry/descriptor/target/compiler invalidation, legacy keys, missing archives, and stale reflection rejection.
  • macOS build: the full LegendsZA app rebuild above completed successfully. The native archive test exercises real archives and runtime rejection of incompatible depth/GPU metadata and malformed archives.
  • iOS: real synthetic libraries and an archive compiled using the iPhoneOS Metal tools and --platform ios --gpu g18p. Cold archive creation took 4.445 s; reuse after a chain-folder/reflection move took 0.234 s, preserving inode/mtime and refreshing the runtime stamp. This is host-side iOS archive validation. No LegendsZA IPA or device run was timed; no iOS signing or installation occurred. LegendsZA's current profile does not enable pso_mtl4, so its default iOS build does not request this archive stage and receives no default IPA speedup from this change.
  • Game regression: LegendsZA was selected because it is the reported workload and the only discovered local Mac build. Its 28,603-shader comparison passed, with no changed MSL or new interface failures. It has no smoke.tsv, so the harness did not run gameplay. Other games and the complete graphics test suite remain unchecked. This regression and the benchmark were recorded before the publication rebase; publication checks above validate the rebased code separately.
  • regress.py impact origin/main..HEAD maps the change to present:pipeline_prebuild for Mac/iPhone offline archives. Its manifests report no affected known game and 120 unknown profiles; that is incomplete coverage, not evidence that other games are unaffected.
Recorded regress.py check report

regress.py check (full): PASS

Baseline 8dfa9c6d8b0e20f5a9563d7034773eda5755ca49 8dfa9c6d8b0e, candidate worktree 8dfa9c6d8b0e (+ uncommitted changes); Apple M2 Max, macOS 26.6, Xcode 27.0; 485 s

game status shaders (base → cand) newly failing newly building changed MSL interface (new / known) boot fps p50 frame p99 ms peak MB prepare s new RED
LegendsZA 0100F43008C44000 PASS 28603/28603 → 28603/28603 0 0 0 0 / 0 – – – – – –

LegendsZA 0100F43008C44000: PASS

  • time: chain 484.7 s

Docs

  • Finding recorded in the game note and shader reference; generated symptom index updated.
  • No permanent shader-chain change; benchmark-only chain edits restored.
  • No game files, keys, or extracted game data in the change or attachments.

Current published head b4880a9d83bfc17379af8dd3c9e00c7ab87ff2c0 has all 7 applicable CI checks successful, including every applicable workflow and job. Verified on 2026-11-01 against exact head/run/job provenance and recorded main cd859c38a8f8890ddbb57a23d6f45e23ba9e6651. Historical results and local limitations above remain separate. Workflows: lint-python, tests.

seedds added a commit that referenced this pull request Nov 2, 2026
…unchanged (#895)

The offline archive's key held the chain label, the profile stamp, the
builder's source and the libraries' absolute paths, so a chain update
recompiled an archive from the same inputs. The key is now what metal-tt
compiles from: the pipeline script without library locations, the referenced
libraries' names and bytes, the architecture, the platform, the minimum OS and
metal-tt's version. The reflection is still checked against the current chain
first, and prebuilt.tsv and the other metadata are written on every run.

Measured on Pokemon Legends: Z-A after a comment-only chain edit: 462.78 s
with the old key, 10.10 s with the new one. An update that changes a library
in the archive still rebuilds it. Existing keys rebuild once.

Co-authored-by: Eliran Zach <[email protected]>
@seedds

seedds commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Landed on main as 80eb5a3, with you as co-author. Thanks: the fix to the key is the right one and your code is in nearly as it was.

Changes on the way in:

  • Removed docs/superpowers/: the repository doesn't keep agent plans or progress logs. Please leave them out of future PRs.
  • Trimmed the Z-A note to the finding and the timing table, and moved its link into the list under "Found on this game". The validation details belong in the PR.
  • Updated docs/development.md, which still described the old archive key.

I didn't re-run a real archive for this one, and no game has booted on a reused archive yet.

@seedds seedds closed this Nov 2, 2026
@thehobbit85
thehobbit85 deleted the codex/pipeline-archive-reuse branch November 2, 2026 05:34
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…unchanged (seedds#895)

The offline archive's key held the chain label, the profile stamp, the
builder's source and the libraries' absolute paths, so a chain update
recompiled an archive from the same inputs. The key is now what metal-tt
compiles from: the pipeline script without library locations, the referenced
libraries' names and bytes, the architecture, the platform, the minimum OS and
metal-tt's version. The reflection is still checked against the current chain
first, and prebuilt.tsv and the other metadata are written on every run.

Measured on Pokemon Legends: Z-A after a comment-only chain edit: 462.78 s
with the old key, 10.10 s with the new one. An update that changes a library
in the archive still rebuilds it. Existing keys rebuild once.

Co-authored-by: Eliran Zach <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants