Analyzing the WebAssembly Module with Twiggy
Learn how to analyze the WebAssembly module using Twiggy.
We'll cover the following
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 when producing binaries. But most of the preceding work is done by the compiler by default. Either Emscripten or the rustc
compiler will ensure 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.
Note: If you want to install
twiggy
on your local system, see the Appendix.
Let’s use Twiggy to optimize the binary.
Create a folder to
twiggy-world
Twiggy:
Get hands-on with 1400+ tech skills courses.