You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building the default provided project in release mode without the console panic hook, the size of the output .wasm file is 13KB, more than I would expect for such logic and much more than the 172 byte add example.
🤔 Expected Behavior
Much smaller wasm file is generated.
👟 Steps to reproduce
Create a new project with wasm-pack new wasm.
Comment out the console_error_panic_hook feature in Cargo.toml (after which the compiler correctly points out that set_panic_hook() is never used).
Build with wasm-pack build --release.
Check code size with ls -l pkg/wasm_bg.wasm (13294 bytes).
Note: Enabling LTO and setting opt-level = "z" in Cargo.toml didn't alter the size of the generated code, and stdout indicates that wasm-opt was found and used for optimization.
Alternatively:
Replace code in src/lib.rs with the basic add example.
Compile as above, check code size (13226 bytes).
🌍 Your environment
Include the relevant details of your environment.
wasm-pack version: 0.13.0
rustc version: 1.80.0
Arch Linux 6.10.3, wasm-bindgen installed through Cargo, wasm-opt installed through system binaryen package.
I first noticed this when analyzing the code size of some basic functions I'd implemented in another project and found there was 13KB I just couldn't drop, even trying to avoid allocating memory, possible panics and string formatting. When compiling with --dev and passing the output to twiggy I see plenty of space taken up by these sorts of functions, but that hasn't been passed through wasm-opt so that may not mean anything (when I do optimize it the names provided by twiggy are meaningless to me e.g. code[0] at 4650 bytes, data[3] at 1982 bytes, etc.).
I've also included the output from cargo rustc --release -- --emit llvm-ir: llvm-ir.txt
The text was updated successfully, but these errors were encountered:
🐛 Bug description
When building the default provided project in release mode without the console panic hook, the size of the output
.wasm
file is 13KB, more than I would expect for such logic and much more than the 172 byte add example.🤔 Expected Behavior
Much smaller wasm file is generated.
👟 Steps to reproduce
Create a new project with
wasm-pack new wasm
.Comment out the
console_error_panic_hook
feature inCargo.toml
(after which the compiler correctly points out thatset_panic_hook()
is never used).Build with
wasm-pack build --release
.Check code size with
ls -l pkg/wasm_bg.wasm
(13294 bytes).Note: Enabling LTO and setting
opt-level = "z"
inCargo.toml
didn't alter the size of the generated code, and stdout indicates thatwasm-opt
was found and used for optimization.Alternatively:
Replace code in
src/lib.rs
with the basic add example.Compile as above, check code size (13226 bytes).
🌍 Your environment
Include the relevant details of your environment.
wasm-pack version: 0.13.0
rustc version: 1.80.0
Arch Linux 6.10.3,
wasm-bindgen
installed through Cargo,wasm-opt
installed through systembinaryen
package.I first noticed this when analyzing the code size of some basic functions I'd implemented in another project and found there was 13KB I just couldn't drop, even trying to avoid allocating memory, possible panics and string formatting. When compiling with
--dev
and passing the output totwiggy
I see plenty of space taken up by these sorts of functions, but that hasn't been passed throughwasm-opt
so that may not mean anything (when I do optimize it the names provided bytwiggy
are meaningless to me e.g.code[0]
at 4650 bytes,data[3]
at 1982 bytes, etc.).I've also included the output from
cargo rustc --release -- --emit llvm-ir
: llvm-ir.txtThe text was updated successfully, but these errors were encountered: