Skip to content

perf(first launch): asset extraction ~22 s → ~6 s on Windows - #217

Merged
999sian merged 1 commit into
999sian:masterfrom
Strikeborn:perf/first-launch-extraction
Oct 20, 2026
Merged

999sian merged 1 commit into
999sian:masterfrom
Strikeborn:perf/first-launch-extraction

Conversation

@Strikeborn

Copy link
Copy Markdown

Result: a player's first launch, and the first launch after an extractor update, waits ~6 s instead of ~22 s on Windows. Release builds self-extract on first launch, so every player benefits. The extracted assets are unchanged.

Files: port/port_asset_pipeline.cpp/.hpp, port/port_asset_log.cpp/.hpp, port/port_asset_bootstrap.cpp, tools/src/assets_extractor/assets_extractor_api.cpp/.hpp

Cause

Extraction itself takes ~5.7 s. Most of the rest went to bookkeeping on the ~24k-file editable tree, which tmc_pc (runtime_only) writes and then deletes:

Step (cold launch, Windows) Before After
Extraction phases 5.7 s 5.7 s
Build-state stamp of the editable tree 12.0 s 0.03 s
Deleting the editable tree 4.5 s 0.03 s (deleted in the background)
Total 21.8 s 5.7 s

Change

  1. BuildSourceState uses lexically_relative instead of std::filesystem::relative. The latter resolves both paths on disk for every file, single-threaded, ~0.5 ms each on Windows. Paths are identical (verified: same 24,127-entry list).
  2. In runtime_only mode the build state records no source manifest (WriteBuildStateFile(..., listSources=false)). The tree is deleted right after, and with no editable tree the game already trusts the state file. A later editable tree triggers the same rebuild as today.
  3. Options::background_cleanup (set by tmc_pc): rename assets_src/<region> to <region>.deleting (instant) and delete it on a background thread. A leftover from an interrupted run is removed in the background at the next launch. The standalone extractor still deletes before returning, now in parallel.
  4. The runtime_only comment said it skips writing the tree and "saves ~150 ms"; it writes then deletes it, so the comment now says that.
  5. Diagnostics: phase lines print elapsed ms, and TMC_EXTRACT_TIMING=1 prints the top-level steps.

Tested (Windows, USA)

  • Cold launch 21.8 s → 5.7 s; warm launch unchanged; reaches Entering AgbMain....
  • Background delete finishes during the session. A planted leftover .deleting tree is removed at the next launch. asset_extractor --runtime-only still leaves no tree.
  • USA, EU and JP retail ROMs all boot, with identical caches across repeated cold launches.
  • Linux (Ubuntu 26.04): cold launch extracts in 2.9 s, the editable tree is cleaned up, 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.

Use lexically_relative for the build-state manifest, skip the manifest in runtime-only mode, and delete the discarded editable tree in the background. Adds per-phase timing and TMC_EXTRACT_TIMING.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@999sian
999sian merged commit 769f1fc into 999sian:master Oct 20, 2026
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