Not too long back, Mozilla introduced Firefox Quantum (version 57) which saw the browser get an interface and speed overhaul. With Firefox 58, Mozilla wants to continue boosting the speed, this time with streaming compilation and a new two-tiered WebAssembly compiler. With these two changes, the browser will be able to compile code faster than the network could otherwise deliver it.
Mozilla explains how the new feature works:
“If you start compiling the code earlier, you’ll finish compiling it earlier. That’s what streaming compilation does… makes it possible to start compiling the .wasm file as soon as possible. When you download a file, it doesn’t come down in one piece. Instead, it comes down in a series of packets. Before, as each packet in the .wasm file was being downloaded, the browser network layer would put it into an ArrayBuffer. Then, once that was done, it would move that ArrayBuffer over to the Web VM (aka the [JavaScript] engine). That’s when the WebAssembly compiler would start compiling. But there’s no good reason to keep the compiler waiting. It’s technically possible to compile WebAssembly line by line. This means you should be able to start as soon as the first chunk comes in. So that’s what our new compiler does. It takes advantage of WebAssembly’s streaming API.”
Overall, the performance gains from the changes are pretty impressive. On the desktop, Firefox will compile 30-60 megabytes of WebAssembly code per second, and on mobile will compile eight megabytes per second. No matter whether you’re on desktop or mobile you should still see a big increase in the speed of the web; the company says the new compiler is 10 to 15 times faster than the existing optimising compiler.
Firefox 58 is due for release on the stable channel on the 23rd of January, however, the new two-tiered compiler can already be tried on the beta or nightly channels.
Source: Mozilla Hacks | Image via Mozilla
35 Comments - Add comment