Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease WASM build size #37

Open
lgarron opened this issue Oct 18, 2023 · 1 comment
Open

Decrease WASM build size #37

lgarron opened this issue Oct 18, 2023 · 1 comment
Labels
bug Something isn't working rs

Comments

@lgarron
Copy link
Member

lgarron commented Oct 18, 2023

The current size (1.4MB) comes from a few things.

  • Way more of the codebase being included than necessary (including the entire web server?)
    • Note that package.metadata.wasm-pack.lib is currently being ignored (it might need to go into the workspace Cargo.toml) and has the wrong path, but I haven't been able to fix this even by specifying the WASM entry as the main lib path.
  • Use of the standard library without tree shaking (https://doc.rust-lang.org/cargo/reference/unstable.html#build-std)
  • Large .text section?
  • Embedded symbols?

Potentially useful command:

rustup component add rust-src --toolchain nightly
cargo install cargo-bloat

cargo +nightly bloat --release -Z build-std --target aarch64-apple-darwin -n 1000

Also:

@lgarron lgarron added bug Something isn't working rs labels Oct 18, 2023
@lgarron
Copy link
Member Author

lgarron commented Oct 26, 2023

This is now significantly better. It was down to ≈240KiB, but is back up to ≈310KiB due to big cube definitions.

I was to change the WASM build to get the KPuzzleDefinition JSON from JS instead of embedding it, which should allow us to get back down in size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rs
Projects
None yet
Development

No branches or pull requests

1 participant