**Andy Wingo: Ahead-of-Time WASM GC in Wastrel**
Today marks an exciting milestone for the WebAssembly (WASM) community as Andy Wingo has successfully integrated managed memory via garbage collection into his ahead-of-time (AOT) compiler, Wastrel. This development brings us one step closer to unleashing the full potential of WASM on the web.
To experience this innovation firsthand, simply check out and build Wastrel from its repository. Once built, you can run a simple "Hello, World!" test by executing `./wastrel/wastrel hello.wat`. For a more comprehensive evaluation, try running the popular GC micro-benchmark, gcbench. To access detailed statistics, set the environment variable `WASTREL_PRINT_STATS=1` before execution.
Let's dive into the numbers: the gcbench test completes in just 138 milliseconds with a tiny heap size of 26.7 MB. Over 30 garbage collection cycles are performed during this time, indicating efficient memory management by Wastrel's GC. For comparison, V8, another well-established WASM engine, takes longer to complete (230ms vs 209ms) and uses more managed memory (48 MB vs 26.7 MB), as well as overall process memory (88 MB vs 34 MB).
But how does Wastrel perform with a larger active heap size? Let's try compiling a binary using quads, which produces a significant increase in performance for Wastrel compared to V8. With Wastrel, the compilation time drops from 2460ms (V8) to 849ms, while memory usage decreases from 383MB (V8) to 141 MB.
It's essential to note that these results include the compilation time for the WASM module on the fly in V8. The author acknowledges potential factors contributing to this performance edge, such as tiering and impedance-matching with regards to strings. However, the primary advantage of Wastrel lies in its ability to statically allocate type checks, object shapes, and other optimizations that become apparent only after ahead-of-time compilation.
With Wastrel's GC demo-quality, we can expect significant improvements in WASM application performance and efficiency. For those interested in learning more about the development process and background behind Wastrel, refer to Andy Wingo's introductory article from October or his recent FOSDEM talk (slides available for download).
Stay tuned for further updates on this innovative project! Happy hacking, and have a wonderful weekend.
---
**Postscript**
As an aside, the author shares a personal anecdote about their own journey with C# and WASM during their autumn parental leave. What initially seemed like a daunting task ultimately turned out to be a valuable learning experience – a testament to the power of curiosity-driven exploration in the tech community.