Closed usuyuki closed 1 year ago
no-text-wasi.wasm 81779byte
wasm-opt -Oz使用後 no-text-wasi-oz.wasm 72552byte
Ozはsuper-focusing on code size
なので一番サイズ小さくなる.
wasm-strip 使用後 no-text-wasi-oz-strip.wasm 12660byte←!?
当たり前だがメモリの使用量は変わらない.(O4のように変更しても)
wasm-opt --help
Optimization options:
---------------------
-O execute default optimization
passes (equivalent to -Os)
-O0 execute no optimization passes
-O1 execute -O1 optimization passes
(quick&useful opts, useful for
iteration builds)
-O2 execute -O2 optimization passes
(most opts, generally gets most
perf)
-O3 execute -O3 optimization passes
(spends potentially a lot of
time optimizing)
-O4 execute -O4 optimization passes
(also flatten the IR, which can
take a lot more time and memory,
but is useful on more nested /
complex / less-optimized input)
-Os execute default optimization
passes, focusing on code size
-Oz execute default optimization
passes, super-focusing on code
size
wasm-stripはcustom sectionを消すことで削減しているらしい.
❯ wasm-strip --help
usage: wasm-strip [options] filename
Remove sections of a WebAssembly binary file.
examples:
# Remove all custom sections from test.wasm
$ wasm-strip test.wasm
options:
--help Print this help message
--version Print version information
-o, --output=FILE output wasm binary file
-k, --keep-section=SECTION NAME Section name to keep in the final output
-R, --remove-section=SECTION NAME Section to specifically remove, including all the rest
✨ 概要
wabtで最適化してサイズやメモリ使用量削減できないかを見てみる
なぜ必要
備考
https://github.com/wasm3/wasm3-arduino/blob/main/examples_pio/Wasm_Advanced/wasm_apps/tinygo/build.sh