-
Notifications
You must be signed in to change notification settings - Fork 191
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
Size optimisation #163
Comments
We are always open to ideas on how to shrink the output binaries. If you want to help with that effort there are tools out there such as https://github.com/rustwasm/twiggy and https://github.com/google/bloaty which can help you figure where the space is going. One thing you can try is building with |
Most likely the majority the space is the overhead of using C++ streams which I believe transitively bring in a lot of stuff. |
How does the code size change when adding |
Adding that drops from 606Kb to 604Kb |
The other major factor here is static linking, since WASI doesn't yet support dynamic linking -- though it is planned. For comparison, on a native toolchain, |
Those two are definitely valid issues, but I suspect there is some big low-hanging fruit here, though. 209Kb for an optimized build is still pretty high. For comparison, unoptimized It's possible this could be improved either in the compiled libraries here, or perhaps we can find interesting new optimizations for wasm-opt to do on wasi-sdk output specifically. |
Another thing that might help is LTO; #89 implements LTO in wasi-sdk in a way that includes libcxx and libc, which should enable more aggressive dead-code elimination. That PR is a little out of date at the moment, but hopefully I'll have time to get back to it soon. |
Hello , |
I do hope to finish #89 at some point, but don't have a specific timeline. |
Something literally just broke for me this week. For some reason But Github Actions is still on Which I was ignoring an enjoying a <1MB file size for Quake3e-WASM. Awesome! Last week however, Binaryen in MacOS stopped shrinking my files. Now it doesn't do anything. Let me guess! Someone added some obscure, nuanced, command line option, that I have to dig through 6 months of changelogs to figure out! This file size problem: This problem is the most ridiculous nuisance I have dealt with the entire time using WASI. This entire platform is held back from becoming mainstream because of this horrible problem. I mean, no developer in their right mind, is going to use WebAssembly in production, when the default compile settings output files with huge amounts of zeros. Meanwhile, with an older version of wasm-opt: YES!
Incredible. It appears the assumption is, hardly anyone is compiling directly to WASM without Emscripten. I hope this becomes more mainstream. |
One issue I've noticed recently is that the debug and DWARF custom sections can be quite large; not sure if posters above found this to be an issue but I typically resolve this with |
I'm using this toolchain in order to create a simple wasm module for use with wagi. The wasm module size has a significant impact on the time it takes to respond to a request - as per deislabs/wagi#3
With this simple example:
Compiled as follows:
The
test.wasm
output is 606 KBytes.If I optimise with
wasm-opt
:It drops to 209 KBytes, which is still a lot larger than I'd expect.
The text was updated successfully, but these errors were encountered: