본문으로 건너뛰기
cccskills
무료GitHub에 공개

wasm-opt

Run binaryen's wasm-opt over the core Wasm that Wado generates, and read what it changes. Use for any question about wasm-opt or binaryen, or to find where Wado's codegen leaves size or speed on the table.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado스타 119(GitHub 119 + cccskills 0)

실행 점수 미검증

설치 방법 보기

포함된 파일(1)

  • SKILL.md7.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

wasm-opt over Wado output

wasm-opt reads a core module, not a component. jco splits a Wado component and hands back its core module, so the pipeline runs through jco. What wasm-opt then removes shows what Wado's own codegen could remove.

Setup

binaryen is not in the mise registry, and mise's github: backend gets a 403 from the GitHub API in a cloud session. Download the release tarball instead:

curl -sSL https://github.com/WebAssembly/binaryen/releases/download/version_133/binaryen-version_133-x86_64-linux.tar.gz | tar xz -C scratchpad

wasm-tools comes from mise. Where its shim reports no version set, call the binary under ~/.local/share/mise/installs/wasm-tools/latest/ directly.

Pipeline

B=scratchpad/binaryen-version_133/bin
S=scratchpad/wasm-opt
FEATURES=(--mvp-features --enable-sign-ext --enable-mutable-globals
  --enable-nontrapping-float-to-int --enable-simd --enable-relaxed-simd
  --enable-bulk-memory --enable-bulk-memory-opt --enable-call-indirect-overlong
  --enable-exception-handling --enable-tail-call --enable-reference-types
  --enable-multivalue --enable-gc --enable-extended-const --enable-multimemory)
mkdir -p $S
wado compile -Os -f no-wide-arithmetic prog.wado -o $S/prog.wasm
node scripts/jco/transpile-released.mjs $S/prog.wasm $S/jco   # → $S/jco/prog.core.wasm
$B/wasm-opt "${FEATURES[@]}" $S/jco/prog.core.wasm -o $S/none.wasm
$B/wasm-opt "${FEATURES[@]}" -O3 $S/jco/prog.core.wasm -o $S/O3.wasm
  • Make -Os the baseline. It is -O2 with the name section stripped and assert messages dropped. An -O2 baseline counts about 9KB of names that wasm-opt drops by default.
  • -f no-wide-arithmetic is required, since the module is run on V8 (see the jco skill).
  • Name the features explicitly, as an array because zsh does not word-split a string. Never pass -all: it lets wasm-opt emit proposals V8 cannot load, compact imports among them.
  • The run with no pass (none.wasm) re-encodes the module and nothing more, so it separates encoding waste from optimization.
  • Add -g to keep function names for a diff. Measure size without it.

Reading the difference

  • wasm-tools objdump gives the size and count of each section.
  • wasm-tools dump annotates every byte. Use it for encoding questions, such as how the local declarations are grouped.
  • wasm-tools print gives WAT to diff. A whole-module diff is too large to read, so compare per-function instruction counts and opcode histograms with a small Node script instead.
  • -O2 --skip-pass=NAME measures what one pass is worth: the bytes -O2 grows by without it. Passes overlap, so these do not add up to the whole gap. Running a pass alone misleads for the -optimizing variants, which rerun the whole function pipeline on what they touch.

To run the result, copy the jco output directory and replace its <name>.core.wasm. Then run it as the jco skill describes. Keep a median of at least 7 runs per variant, since the spread on a cloud VM is ±15%.

Findings: zlib benchmark (binaryen 133, 2026-10)

Sizes of the zlib benchmark's core module:

VariantBytes
Wado -Os76,476
wasm-opt, no pass76,943
wasm-opt -O270,073
wasm-opt -O367,979
wasm-opt -Oz67,853

Re-encoding alone makes this module 467 bytes larger, so binaryen's encoding finds nothing to save in Wado's.

In 2026-09, on Node 26, decompression ran faster under wasm-opt -O2 and -Os: the median rose 10–40% across two sessions. Compression, and everything under -O3, stayed within the noise.

What each -O2 pass is worth, by --skip-pass:

PassBytesWhat it does to Wado's output
coalesce-locals2,230Mostly cleans up after inlining: 337 run alone
inlining-optimizing1,799Takes 114 functions to 53
optimize-instructions1,164Peepholes, ref.as_non_null among them
remove-unused-brs1,062Turns block/br_if/return into if/else
precompute-propagate782Constant propagation
dae-optimizing758Drops unused and always-constant parameters
heap2local664Turns non-escaping structs into locals
vacuum, merge-blocks824Removes the blocks the passes above leave behind

What wasm-opt removes, as open codegen targets:

  • Local declarations: the emitter wrote one entry per local, 2,942 entries and 7.1KB in all. Grouped by type, they take 346 entries and 1.0KB. wir_optimize/local_layout.rs groups them, and puts the most used first.
  • Duplicate function types: 136 types, of which -O2 keeps 69. Most of the rest go with the functions it inlines.
  • ref.as_non_null: -O2 takes the count from 388 to 16. Codegen added most of them, after reads of nullable global slots. A global promoted to a non-null constant now has a non-null slot (wir_optimize/const_global.rs). The object of a GC access, which traps on null by itself, is not narrowed (wir_optimize/cleanup.rs). The -Os build keeps 17.
  • Set-then-get: a local.set X followed at once by local.get X occurred 1,191 times. wasm-opt turns it into a local.tee or removes it. The last WIR pass fuses each pair into a tee (fuse_remaining_local_tees), and copy propagation removes a copy of a tee'd local. The -Os build keeps 39 pairs.
  • Set sinking: simplify-locals moves a local.set into the one read of it, so the value stays on the stack. -O2 removes 565 local.set and 725 local.get, and adds 188 local.tee.
  • Local coalescing: wasm-opt merges locals whose live ranges never overlap, as a register allocator would. wir_optimize/local_coalesce.rs does the same per Wasm type. On the -Os build it takes 2,752 locals to 1,020.
  • Control-flow shape: -O2 takes block from 229 to 57, br_if from 191 to 54, and return from 184 to 44, while if grows from 1,278 to 1,385.
  • Single-caller inlining: -O2 inlines functions with one caller whatever their size, inflate_fast among them.
  • Identical functions: the -Os build has none. The -O2 build keeps 9 copies of the outlined $cold0 bounds-check path of List<T>::index_value and index_assign, one per element type, and i32's Display::fmt equals its Inspect::inspect. --duplicate-function-elimination saves 4,722 bytes there. Two param_spec clones whose bindings differ can fold to one body (fmt_float_special$spec0 and $spec1 in json_twitter).
  • Empty functions: a module whose globals all become constants keeps an empty $initialize_module. wir_optimize/empty_work.rs removes the calls to it and the once-flag that guarded them, and DCE drops both.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

benchmark

무료

Measure Wado's performance or the size of the Wasm it generates, and refresh the benchmark/ and wasm-size/ README files. Use for any benchmarking or size-measurement request, whichever benchmark it names.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado1192026년 10월 26일 업데이트

ci-timing

무료

Measure how long GitHub Actions jobs and steps took across past runs, and find the pull request that made CI slower. Use for any question about CI duration, a slow job, or when CI got slow.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado1192026년 10월 26일 업데이트

How to answer code review feedback — a human reviewer, CodeRabbit, or any review bot. Verify the findings, report the classes they are instances of to the user before fixing, then fix the class rather than the sites named. Put design decisions to the user, then run /distill. Invoke when responding to review comments on a pull request, or to the findings of a /code-review run.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado1192026년 10월 26일 업데이트

Investigate and improve code coverage for the wado-compiler crate. Use for any question about what the tests do and do not reach, dead code included.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado1192026년 10월 26일 업데이트

cr

무료

Review the branch with /code-review at high, then answer the findings with /code-review-response.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado1192026년 10월 26일 업데이트

debugger

무료

Use rust-gdb to inspect variables and step through code without modifying it. Prefer it over print debugging for any investigation into what the compiler is actually doing (lldb is unavailable on Claude Code Web).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

wado-lang/wado1192026년 10월 26일 업데이트

wado-lang의 스킬 모두 보기

이 스킬의 문제 신고