Analyzing the WebAssembly module with Twiggy
The Rust-to-WebAssembly binaries are more likely to create a bloated binary. Proper care should be taken when creating WebAssembly binaries. The trade-off between the level of optimization, the time to compile, and various other factors should be considered while producing binaries. But most of the preceding work is done by the compiler by default. Either Emscripten or the rustc
compiler ensures the elimination of dead code along with various options on the optimization level (-O0
to z
). We can choose the one that fits us.
Twiggy is a code size profiler. It uses the call graph to determine the origins of a function and provides meta-information about the function. The meta-information includes the size of each function in binary and its cost. Twiggy provides an overview of what is in the binary. With that information, we can optimize the binary further Let's install and use Twiggy to optimize the binary:.
- Install Twiggy by...