Mozilla’s Firefox has been praised for its dramatic speed increase with Firefox Quantum. The firm is aiming to make its browser app even better with Firefox 58 (via Neowin).
The firm will be adding a new 2-tiered compiler to the browser, compiling code with a baseline compiler compiling code 10 times faster than the optimising compiler. This is to take advantage of the WebAssembly streaming API, and let the browser compile code on the fly.
Mozilla’s Lin Clark explains just how the new compiler works in tandem with the WebAssembly streaming API to make Firefox faster overall.
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 JS 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.
Mozilla isn’t the only one improving their browser, Microsoft and Google are also adding improvements to their Edge and Chrome browsers respectively. Microsoft’s Edge will gain a much nicer fluent inspired design, as well as better support for auto-fill credit cards and e-books. Google’s Chrome will make it much harder for intrusive ads to clutter up your browser windows this year.
While Mozilla’s changes will roll out from next week, expect Google and Microsoft’s roll outs to be staggered throughout the year.