Skip to content

avoid pathological wasm optimization - #2796

Merged
alixander merged 1 commit into
masterfrom
agent/fix-wasm-opt-memory
Aug 3, 2026
Merged

avoid pathological wasm optimization#2796
alixander merged 1 commit into
masterfrom
agent/fix-wasm-opt-memory

Conversation

@alixander

@alixander alixander commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • use Binaryen -O2 instead of -Oz for the large Go WASM package
  • cap the manual npm staging job at 30 minutes

Why

The stage-only run spent more than 26 minutes inside wasm-opt -Oz without reaching npm. An exact local reproduction remained CPU-active with about 2.36 GiB RSS and rising after 4m54s, with no output file. This matches WebAssembly/binaryen#7644: -O3/-Os/-Oz can have quadratic memory growth on large Go WASM modules, and the maintainer recommends -O2. D2 currently includes the same goldmark code implicated by that issue.

No staged npm artifact was created before the run was cancelled.

Validation

  • sh -n d2js/js/ci/build.sh
  • workflow YAML parses successfully
  • git diff --check
  • exact Binaryen 123 -O2 --enable-bulk-memory-opt benchmark completed in 14.83s with ~1.11 GiB peak RSS
  • output validated successfully with Binaryen and was 432,564 bytes smaller (1.746%) than the input

@alixander
alixander merged commit 8a438bf into master Aug 3, 2026
2 of 6 checks passed
@alixander
alixander deleted the agent/fix-wasm-opt-memory branch August 3, 2026 14:55
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.

1 participant