Skip to content

fix(build): full rebuilds skip unchanged asset work (~15 min → ~24 s on Windows, faster on Linux too), and dist/ keeps its asset cache - #218

Merged
999sian merged 2 commits into
999sian:masterfrom
Strikeborn:perf/asset-cache
Oct 20, 2026

Conversation

@Strikeborn

Copy link
Copy Markdown

Depends on #212 (stacked on it: until #212 merges, this diff also shows #212's commit). This PR's own changes are the second commit.

Files: build.py, xmake.lua

What this helps with

Anyone running the full (non-slim) build.py more than once: contributors iterating on code, testing a packaged dist/ build, or checking asset or mod changes against a real install. Today each full build repeats about 15 minutes of asset work on Windows, then the next launch of dist/ repeats the runtime extraction too. After this PR, a code-change full build takes 24 s and dist/ launches straight into the game. The skip check is broken on every platform, so Linux full builds also stop redoing the whole extract/convert/build pass. Slim builds and release CI are unaffected.

Cause

  1. The skip never fires. build_version() requires build/<version>/assets_src, which none of the asset tasks create, so every run redoes ~21k extractions and ~10k conversions.
  2. Staging wipes the runtime cache. It rmtrees dist/<version>/assets, deleting tmc_pc's assets/<region>/ cache, so the next launch re-extracts.

Change

  1. Fingerprint the asset tasks' inputs (region + expected ROM SHA1, assets/*.json, sources of asset_processor and its converters) into build/<version>/.assets_fingerprint after Build assets succeeds, and skip the tasks when it matches.
  2. When the fingerprint doesn't match, re-extract every file (TMC_ASSET_FORCE_EXTRACT=1 → asset_processor -f). Extraction otherwise skips files that already exist, so a stale or corrupted file (like the dungeon maps from fix(asset tools, Windows): write dungeon maps in binary mode ("w" → "wb"); Windows text mode shifted 462 map offsets #214's bug) would survive. With perf(asset tools): full asset pass ~23 min → ~17 s on Windows (all cores, no cmd.exe, in-process gbagfx/aif2pcm) #216 a forced extract takes ~4 s.
  3. Staging keeps assets/<region>/ and assets_src/<region>/, the way it already keeps assets/rando/.

Why it's safe

  • Game code isn't an asset input. Any asset JSON or tool change re-runs the tasks, and a failed run never leaves a matching stamp.
  • Kept runtime caches are still validated by tmc_pc's .asset_build_state.json.
  • Force a re-extract by deleting .assets_fingerprint (build) or dist/<version>/assets/<region>/ (runtime).

Note on #210

#210 also adds a function to build.py at the same spot (stage_voxel_shapes, after stage_rando_logic). Whichever merges second gets a trivial conflict: keep both functions. Everything else in this PR merges cleanly with #210.

Tested (Windows, USA)

  • Second full build: Assets up to date ... skipping, ~15 min → 24–27 s.
  • Old Windows build tree with corrupted dungeon maps + changed inputs: full build forces re-extraction and the result matches a clean from-scratch build exactly (21,848 files).
  • After staging, dist/USA/assets/usa/.asset_build_state.json keeps its timestamp, and launch goes straight to paks mounted.
  • Linux (Ubuntu 26.04): second full build skips assets (8 s).
  • Smoke run reaches Entering AgbMain.... Play-tested to the Picori Festival (early game only).

Developed with assistance from Claude Code (Opus 5.5). I reviewed and tested the changes as described above.

Strikeborn and others added 2 commits October 7, 2026 18:17
…finishes

The asset tasks exec'd tools/bin/asset_processor without .exe and by a relative path xmake doesn't resolve on Windows; use an absolute path with the .exe suffix. build.py no longer raises UnicodeEncodeError when stdout is redirected (cp1252).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sset cache

Fingerprint the asset tasks' inputs (ROM SHA1, assets/*.json, asset tool sources) so code-only full builds skip extract/convert/build; force re-extraction when inputs change; keep assets/<region>/ caches when staging dist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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