Paul Krill
Editor at Large

Firefox speeds up WebAssembly through streaming compilation

news
Jan 19, 20182 mins

Firefox 58 begins compiling WebAssembly code as it downloads, and taps multiple threads for both compiling and optimization

sprint competition fast speed start
Credit: Thinkstock

Mozilla’s Firefox 58 browser, to be released January 23, features a compilation technology designed to make the WebAssembly portable code format run even faster.

This performance boost is enabled by streaming compilation, in which the browser compiles WebAssembly code even as it is being downloaded. Code begins compiling sooner and thus finishes executing sooner. Firefox 58 also features a new two-tiered compiler, with a new baseline compiler that compiles code 10 to 15 faster than the optimizing compiler.

The combination of streamed and two-tiered compilation results in WebAssembly code being compiled faster than it can be delivered by the network. Mozilla notes that, on a desktop computer, it has been able to compile 30 to 60 megabytes of WebAssembly code per second. On an “average” mobile device, WebAssembly code compiles at 8 megabytes per second, which is still faster than the download speed for just about any mobile network, said Lin Clark, Mozilla senior evangelist.

Clark explained that decoding WebAssembly is simpler and faster than parsing JavaScript. This decoding and compilation could be divided across multiple threads, making baseline compilation quicker. Baseline-compiled code can start executing on the main thread without pausing for compilation. Other threads, meanwhile, work on a more optimized version of the code, which then can be swapped in so code is faster. 

Future plans call for decoding and compiling on the first page load and caching resulting machine code in the HTTP cache. When that URL is requested, precompiled machine code is sent, eliminating load times for subsequent page loads. While JavaScript bytecode is being cached in this manner in Firefox 58, work still needs to be done in order to cache machine code for WebAssembly files

Developers who use Firefox Nightly or beta can try out the technology on their own device at this link.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author