Repository navigation
perf(asset tools): full asset pass ~23 min → ~17 s on Windows (all cores, no cmd.exe, in-process gbagfx/aif2pcm) - #216
Merged
Conversation
… gbagfx/aif2pcm Run per-asset work on all cores (TMC_ASSET_JOBS), launch converters with CreateProcess/posix_spawnp instead of system(), and link gbagfx and aif2pcm in-process. Output is byte-identical; a full asset pass drops from ~23 min to ~17 s on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Result: extract + convert + build together drop from about 23 minutes to about 17 seconds on a 16-core Windows machine (~80×), with byte-identical output. Linux and macOS get the parallel and in-process gains too.
Files:
xmake.lua,tools/src/asset_processor/main.cpp,main.h,util.cppCause
Every asset was handled one at a time, and every conversion went through
system(). On Windows that's acmd.exeplus the converter, about 20k process launches per pass, mostlygbagfx. Convert and build also have no up-to-date check (return true; // TODO), so each pass redoes everything.Change
runJobs): jobs run on all cores (TMC_ASSET_JOBS=Ncaps it;1= the old behaviour). Assets that share any file (raw, editable or built path, e.g. 15 duplicate animation entries) run in order on one thread. Offsets are still recorded afterwards in config order, so generated headers can't change.check_callstarts converters withCreateProcess/posix_spawnpinstead ofsystem(). On Windows the child gets the identical command line, so argument parsing is unchanged; elsewhere one level of quotes is stripped, asshdid.gbagfxandaif2pcm: linked intoasset_processor(mainrenamed togbagfx_main/aif2pcm_main) and called directly. Neither keeps global state, and both free their buffers; on error they exit, as a failed launch did.mid2agb/agb2mid(songs) still launch as processes: both keep per-run globals initialised once at startup, so in-process calls would leak settings between songs.TMC_ASSET_TIMING=1prints time per asset group. Linux linkspthread(needed before glibc 2.34).Measured (Windows 10, 16 cores, USA)
gbagfxaif2pcmCold extract is 4 s. At every stage, all 21,848 output files were byte-identical to the single-threaded run (SHA-1 per file), and the generated offset headers matched the committed ones.
About 9 s of what's left is the 507 songs. On the test machine, process launches run at ~170/s system-wide no matter how many threads ask (16, 32 and 64 threads all took the same time), so only fewer launches would help, which would mean refactoring the two song tools' globals.
Tested
Entering AgbMain.... Play-tested to the Picori Festival (early game only).corrupted size vs. prev_sizeafter a successful full rebuild. It does this with the originalxmake.luaas well, so it's unrelated to this PR.Developed with assistance from Claude Code (Opus 5.5). I reviewed and tested the changes as described above.