wgpu
wgpu copied to clipboard
Reduce the binary size
See https://twitter.com/batmansmk/status/1346479574465433613 A simple app got compiled to an 1.3Mb executable. I'm sure we can do better!
This is espcially important on wasm/webgl, where the blob has to be shipped over the wire. Currently our examples, built in release, sit at about 5-6MB uncompressed.
I can confirm this for WebGL builds. Not for builds which use WebGPU. I'm currently at 1.6Mb uncompressed (Gziped its 571k.). The reason for this could also be that winit, web-sys or js-sys introduces this issue. I haven't debugged the root cause so far.
Steps I've completed so far:
- Build in release profile
- Enable optimizations for release profile:
[profile.release] lto = true codegen-units = 1 opt-level = 's' - Run wasm-opt
- Disabling unused features like
"x11", "wayland"forwinit
Further ideas: https://rustwasm.github.io/book/reference/code-size.html
I think that the uncompressed size should be below 1Mb, else the compilation on the client side could be a real bottleneck (CPU fans spin up etc.). In comparison for WebGPU my build size is already 708k without compression (compressed its down to 222k).
@kvark did you use the WebGL backend or WebGPU?
I didn't measure either, just linked to a tweet.
I didn't measure either, just linked to a tweet.
I might do some better reproducible measurements soon :) Something that would be awesome would be a CI step which validates that WASM builds are not exploding in size. If the size of the wasm file doubles for example with the introduction of a commit then there is a serious problem.
This has no particular actionability, so I'm going to close.