Skip to main content

Impressive WebAssembly Performance gains in Firefox

Mozilla has been on the forefront of WebAssembly development, a relatively new technology that offers better performance on the Web than JavaScript in many cases.

WebAssembly offers several advantages over JavaScript. It takes less time to fetch, decode and compile WebAssembly code compared to JavaScript. You can check out this overview on Mozilla Hacks for a detailed article on the differences between WebAssembly and JavaScript.

Mozilla engineer Lin Clark revealed yesterday that the upcoming Firefox 58 web browser would feature two new WebAssemblyfeatures that improve performance significantly.

Streaming compilation enables the browser to compile code while it is downloaded and the new 2-tiered baseline compiler compiles code up to 15 times faster than the optimizing compiler.

Clark notes that Firefox can compile code faster than it comes from the (average) network with these changes.

A basic benchmark that Mozilla created shows impressive gains.

webassembly benchmark

I ran it using different browsers and here are the results:

  • Firefox 57: 1400 ms (8.8 MB/s)
  • Firefox Nightly: 176.7 ms (70.1 MB/s)
  • Google Chrome 63: 2492 ms (5 MB/s)
  • Google Chrome Canary 65: 7854.5 ms (1.6 MB/s)
  • Microsoft Edge: 86 ms (143.9 MB/s)
  • Opera 50: 4373.1 ms (2.8 MB/s)
  • Vivaldi 1.14: 2036.7 ms (6.1 MB/s)

Edge's performance looks impressive on first glance but if you read this article on the MS Edge Development blog you will notice that Edge defers parsing WebAssembly functions until they are called.

Under the hood, Chakra defers parsing WebAssembly functions until called, unlike other engines that parse and JIT functions at startup time.

Lin notes that the optimizations allow Firefox on the desktop to compile 30 to 60 Megabytes of WebAssembly code per second. On "a pretty average" mobile, Firefox manages to compile 8 Megabytes per second.

Mozilla plans to launch the WebAssembly improvements in Firefox 58. Firefox 58's release date is January 23, 2018.

Firefox users who run Beta or Nightly versions of the web browser can test the functionality already. You can run the basic benchmark that I linked above to see the difference, or run real-world applications or games that use WebAssembly instead. (via gHacks)

 

This article was first seen on ComTek's "TekBits" Technology News

HOME