Use -O2 instead of -O3 when linking libGD.js/wasm to speed up CI builds#8630
Open
4ian wants to merge 1 commit into
Open
Use -O2 instead of -O3 when linking libGD.js/wasm to speed up CI builds#86304ian wants to merge 1 commit into
4ian wants to merge 1 commit into
Conversation
The final link step is dominated by Emscripten's wasm-opt pass on the ~3.4 MB output. Lowering it from -O3 to -O2 makes the link step ~3 min -> ~15 s on a 4-vCPU machine (similar speedup expected on CircleCI's medium+ runner), while the gzipped wasm only grows by ~0.2% and the GDevelop.js test suite runtime is unchanged.
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.
Summary
Lower the optimization level applied during the final Emscripten link of
libGD.js/libGD.wasmfrom-O3to-O2. The link step (specifically thewasm-optpass over the ~3.4 MB wasm output) is the bottleneck of thebuild-gdevelop_js-wasm-onlyCircleCI job — even with ccache speeding up the compile phase, linking still takes 3–4 minutes.Benchmarks
Measured on a 4-vCPU Linux box with emsdk 3.1.21 (same version as CI),
emmake make -j 8,releasevariant. The CI runner (medium+, 3 vCPU) should see a comparable speedup.Link / build time
-O3(current)-O2(this PR)libGD.*, re-make)The wasm-opt
-O3pass over the ~3.4 MB wasm dominates link cost.-O2skips the most expensive passes (aggressive inlining, full code-flow optimizations) and finishes in ~15 s instead of ~170 s.Output size
-O3(current)-O2(this PR)libGD.jslibGD.wasmlibGD.js(gzip -9)libGD.wasm(gzip -9)Uncompressed grows ~7%, but the gzipped wasm (what actually goes over the wire) is essentially unchanged (+0.2%). Gzipped JS is +3.5% (~6 KB).
npm testruntime (3 runs each,--runInBand)-O3(current)-O2(this PR)1162 tests pass. Test runtime is unchanged (slight noise if anything favors
-O2).Notes
-Olevel is changed. Compile-time-O3 -fltois kept, so all.cppfiles are still compiled with full optimizations.dev,debug,debug-assertions,debug-sanitizers) are unaffected.-fltodoes almost nothing here (only the 4Bindings/*.cppfiles are scoped to it via theGDevelop.js/CMakeLists.txt-localadd_compile_options;GDCore,GDJS, and Extensions are not), so it's left in place for now — the meaningful win is the link-time-Olevel.Test plan
build-gdevelop_js-wasm-onlyjob completes noticeably faster (look at the "Build GDevelop.js" step duration)npm teststep still passes (1162 tests)libGD.js/libGD.wasmand confirm no perceptible perf regressionGenerated by Claude Code