BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News With Firefox Version 58, WebAssembly Gets 10X Faster

With Firefox Version 58, WebAssembly Gets 10X Faster

Bookmarks

With Firefox 58, Mozilla is shipping a 2-tiered compilation system for WebAssembly (WASM) that they claim allows them to parse and compile WASM code at 30-60 MB/s, or as fast as it comes in over the wire. Benchmarks indicate around a 10X speedup from previous versions of Firefox, and over 10X faster than Chrome.

In a Mozilla Hacks blog post, Lin Clark states some of the performance numbers they’re seeing:

On a desktop, we compile 30-60 megabytes of WebAssembly code per second. That’s faster than the network delivers the packets.

If you use Firefox Nightly or Beta, you can give it a try on your own device. Even on a pretty average mobile device, we can compile at 8 megabytes per second —which is faster than the average download speed for pretty much any mobile network.

Independent testers report being able to replicate these results. Reddit user a_potato_is_missing reported testing on Luke Wagner’s tanks compile time test with results on an Android Huawei P10 Lite going from 1.7MB/s in Firefox v57 to 11.8 MB/s in Firefox v58. Windows 10 desktop tests showed speedups from 9 MB/s on v57 to 52.8MB/s on v58. By comparison, Chrome lagged behind at 1MB/s on the Android and 4.1 MB/s on the desktop.

The speed gains come on top of already observed performance gains of WebAssembly over JavaScript. Earlier reports include a case study by Figma showing 3X load-time improvements by switching to WebAssembly and benchmarks published on Hackernoon showing 30% execution time speedups for computationally intensive graphical programs.

In a the blog post, Lin Clark details how the compiler leverages Firefox’s parallel architecture to split the compilation process into two independent processes. The first starts execution immediately and compiles a baseline version of the code as fast as it comes in over the wire. The second compiles the code to an optimized version in a background thread. When the optimized version is complete, they swap it into place to make the code run even faster.

The new improvements mean that WebAssembly can be compiled as quickly as they come off the network. Yehuda Katz highlighted the implications of this for web development:

JavaScript code is much more expensive, byte for byte, than an image, because of the time spent parsing and compiling it.


It's possible to parse and compile wasm as fast as it comes over the network, which makes it much more like an image than JavaScript code.

Game changer!

Rate this Article

Adoption
Style

BT