Impressive WebAssembly Performance gains in Firefox

Martin Brinkmann
Jan 18, 2018
Updated • Jan 18, 2018
Firefox
|
29

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.

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.

Summary
Impressive WebAssembly Performance gains in Firefox
Article Name
Impressive WebAssembly Performance gains in Firefox
Description
Mozilla engineer Lin Clark revealed yesterday that the upcoming Firefox 58 web browser would feature two new WebAssemblyfeatures that improve performance significantly.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. ShintoPlasm said on January 21, 2018 at 11:17 am
    Reply

    Update: FF58 is out now on Mozilla’s FTP server. Its energy/battery impact on Mac still suck; to some extent even worse than FF57. Way to go, Mozilla.

  2. Sigmar said on January 18, 2018 at 5:36 pm
    Reply

    This is great. Now to wait for true multi-threading support (this year ?) and SIMD (also this year ?), both available to JavaScript as well.

    With these, browsers will really be able to run desktop AAA games and apps.

    1. Sigmar said on January 18, 2018 at 5:51 pm
      Reply

      When this work is done and as companies leverage it, the “Web 3.0” will be born

  3. archie said on January 18, 2018 at 4:39 pm
    Reply

    nightly:

    Finished downloading 12.4 MB
    WebAssembly.instantiate took 219.8 ms (56.3 MB/s)

    1. archie said on January 18, 2018 at 4:51 pm
      Reply

      Side notes:
      – This is a decent i5 (5675C) with 16GB RAM, W1064. Connection is 4G/LTE. Large bandwidth but latency as well.
      – FF59 literally crushes FF ESR (52) performance-wise. To the point that I have been running nightly more and more since 59, when I would stay in ESR until now, due to legacy extensions. The benefits in FF development trends are really starting to show for me, justifying the hassle of reconfiguring worskspace and switching extensions when it can be done..

  4. ShintoPlasm said on January 18, 2018 at 3:24 pm
    Reply

    Yet Firefox 57 on Mac still sucks when it comes Energy Impact and battery life… I just wish that the Mozilla guys would make power usage on *all* platforms a high-priority issue.

    For the time being, I constantly switch between Opera (low energy impact but feels less ‘robust’) and Firefox (stable and quick but massive battery impact on my latest MacBook Pro).

    1. Sigmar said on January 18, 2018 at 5:31 pm
      Reply

      >>> “Yet Firefox 57 on Mac still sucks when it comes Energy Impact and battery life”

      This is not true: https://youtu.be/wREO8eA8_rE?t=76

      Battery consumption patterns vary wildly from one machine to the next, unlike other metrics we are used to, so generalities are not very meaningful.

      1. Mike said on January 18, 2018 at 6:39 pm
        Reply

        I agree, but I would also not that on the Firefox Reddit page, Firefox developers have noted that they are aware that Firefox Quantum is using more energy consumption that they would like and that subsequent updates (58, 59, etc.) should address this problem. While I agree it is difficult to do a “one size fits all” assumption regarding battery life, Firefox 57 is poorly optimized (battery wise) for Mac OS.

    2. Richard Allen said on January 18, 2018 at 4:51 pm
      Reply

      Just out of curiosity, have you tried reducing the “Content process limit” from the default of 4 to maybe 1 or 2? I use the default of 4 with 57+ but if I use only 1, I can’t really perceive any difference in performance but then I seldom have more than a dozen tabs open, and even when just using 1 content process FF will still show 4 processes in the Windows Task Manager. Fact is I have FF 56 and Waterfox installed and I have them set to use one content process and they both work very well. Just wondering what kind of impact reducing the process count would have on battery life. Might be worth a shot.

      1. ShintoPlasm said on January 18, 2018 at 10:16 pm
        Reply

        @ Richard Allen: I have tried to play around with the number of content processes, but it doesn’t seem to make much difference.

        @ Sigmar: The test video you’ve linked to was performed on a desktop iMac, and is not at all representative of what happens on a battery-run MacBook Pro. My point about Energy Impact is that FF57 has a much larger number of CPU spikes which significantly reduces battery life compared to Safari or even Opera. This is often translated into Average Energy Impacts in the three figures.

        @ Mike: I’ve read some of those Reddit discussions, and they make me hopeful that some day FF may be on equal battery footing with Chrome, though probably not with Safari. Still, it is incredibly frustrating that one’s favourite browser – with all these shiny new Quantum improvements – drains your battery liked a milked cow.

      2. Mike said on January 19, 2018 at 7:16 pm
        Reply

        @ ShintoPlasm: I agree that it is frustrating that Firefox suffers from such poor battery life at times, because Quantum is extremely snappy and a pleasure to use. Opera is still my go-to Chromium browser due to its battery optimizations (on both Windows and Mac), but I am hopeful that the Firefox devs will put a greater emphasis on battery/power consumption optimization in 2018 (along with mobile, where Firefox is terrible on Android for page loading performance). Now that Quantum has been released and the next couple updates (58, 59) will include bug fixes and performance optimizations to the Quantum engine, hopefully emphasis will switch over the improving battery life. Battery life struggles have long been an issue for Firefox, so hopefully it is on the radar of the organization’s developers.

  5. Richard Allen said on January 18, 2018 at 2:12 pm
    Reply

    I thought my little Core i5 desktop was doing good until I saw the numbers compared to what’s posted in the article. I’m glad I didn’t use my old laptop! ;)

    Nightly: 209.4 ms (59.1 MB/s)
    FF v56: 1975.7 ms (6.3 MB/s)
    FF v57: 1817 ms (6.8 MB/s)
    Waterfox v56.0.3: 1874.3 ms (6.6 MB/s)

    Chrome: 4076.4 ms (3 MB/s)
    Chrome Dev: 4216.8 ms (2.9 MB/s)
    Vivaldi 1.14: 3886.2 ms (3.2 MB/s)

    Just saw an old article on medium about WebAssembly:
    “https://medium.com/mozilla-tech/why-webassembly-is-a-game-changer-for-the-web-and-a-source-of-pride-for-mozilla-and-firefox-dda80e4c43cb”

  6. Appster said on January 18, 2018 at 2:12 pm
    Reply

    Well, then. Safari 11 is still a little bit faster than FF Quantum on my MacBook. The deciding factors when it comes to speed are your bandwidth as well as your hardware, anyway. FF Quantum will be no good on an Intel Atom with 20 kbit/s download speeds.

    1. Richard Allen said on January 19, 2018 at 2:30 am
      Reply

      Where do you live that being able to surf the web on a 2G cell network is a concern? Is surfing the web on 2G a thing now? I don’t remember it being a thing 10 years ago, much less now. Hell, everybody I’ve heard of is shutting down their 2G networks. Dial up? I feel for you.

      1. Appster said on January 19, 2018 at 12:52 pm
        Reply

        @Richard Allen:

        Uhm, Richie… That’s not MY connection speed. It was just an example, one that I used to illustrate how the browser is not the deciding factor when it comes to speed. Hardware and bandwith are far more important. So I don’t see the point in saying “Wow, Quantum is so fast!” when this is in fact only determined by bandwith speed and hardware. It’s a pointless sentence. Even if it was faster than FF56 on decent hardware and decent bandwith, it would hardly be visible for the human eye. Unless you are a cyborg, of course.

      2. Richard Allen said on January 19, 2018 at 3:41 pm
        Reply

        ;)

  7. Russell Mollot said on January 18, 2018 at 1:19 pm
    Reply

    This article got me pretty excited. This is a “teaser”, though, and I’m dying for more details on WebAssembly — will have to search for more material. That’s okay … it’s all good … no … Great!

  8. Duckeenie said on January 18, 2018 at 8:51 am
    Reply

    All that is well and good but if I have to mess around just to get something that should work out of the box like spellcheck then I’ll save myself far more time by using another browser.

    1. Anon said on January 18, 2018 at 1:37 pm
      Reply

      > News about performance improvements
      > Still being negative

      I wonder what miserable lives you guys must live.

      1. Appster said on January 18, 2018 at 2:09 pm
        Reply

        @Anon: He is probably still negative about the product because the small benefits pouring in very, very slowly are not outweighing the negatives, at all.

        As for myself, I appreciate the performance improvements. However, I see no point in putting others down the way you do. If you are dead-set on putting others down, do it with facts at least. Ad hominem stuff is way too obvious and an embarrassment to begin with.

      2. Anonymous said on January 18, 2018 at 5:27 pm
        Reply

        > As for myself, I appreciate the performance improvements. However, I see no point in putting others down the way you do.

        Your track record here says the polar opposite but okay

      3. Appster said on January 18, 2018 at 8:28 pm
        Reply

        @Anonymous:

        > Your track record here says the polar opposite but okay

        My arguments were always based on facts. Not just “ad hominem / I don’t like your face / You must be sad or stupid” stuff. People are free to disagree with me. And I am free to disagree with them. People who insult me will be dealt with accordingly.

        Just for your information.

      4. Anonymous said on January 19, 2018 at 1:15 am
        Reply

        > My arguments were always based on facts.

        That’s the thing, they often are not. But let’s gloss over the topic, I don’t want Ghacks to be spammed because I reply to stuff

      5. Appster said on January 19, 2018 at 12:55 pm
        Reply

        @Anonymous:

        > That’s the thing, they often are not.

        They are. Read again. If they aren’t, present us with proof.

        > But let’s gloss over the topic, I don’t want Ghacks to be spammed because I reply to stuff

        That’s funny considering how your original reply was spam to begin with, IMHO.

        Let it be, pal. The blackmailing won’t work out the way you want it to.

      6. Anon said on January 18, 2018 at 4:03 pm
        Reply

        @Appster Honestly, my bad. It’s just that this site is filled with so much negativity that it gets to a point of ridiculousness. Everything Mozilla does it’s like the end of the world for some users.

        They could make the best browser in the world with the best performance, dev tools, UI/UX, etc., and these guys would still bitch and moan or threaten to go to another browser because they changed a button or some insignificant detail.

        It’s pretty much a thankless job to the guys at Mozilla. Nothing is ever good enough.
        I’m not excusing some of their decisions and I do not agree with everything they do. And when that happens, I voice my opinion in a constructive matter as we all should.

        But still i’m thankfull for their work since it’s the only good independent browser we have and to be perfectly honest, they don’t owe us a damn thing.

        P.S
        Do not work at Mozilla, use 3 different browsers so i’m not a fanboy.

      7. Global Surveillance said on January 20, 2018 at 4:45 am
        Reply

        Mozilla is not the enemy, Google is the enemy.

      8. John Fenderson said on January 22, 2018 at 5:52 pm
        Reply

        “Mozilla is not the enemy”

        No, Mozilla is more like the old friend who has lost his mind and, despite increasingly erratic and risky behavior, you tolerate just because, well, it’s an old friend.

      9. Earl said on January 19, 2018 at 7:09 pm
        Reply

        @Anon said on January 18, 2018 at 4:03 pm:
        Mozilla *had* the best browser, and browser community–of developers especially. They threw it all away–literally–for the sake of being Chrome-compatible. Our sentiments have nothing to do with Australis and Fx29. It’s about XUL and everything else Mozilla tossed along with it. The [former] long-time users of Firefox felt betrayed by Mozilla… and they had the right to. Nothing about that has changed, nor should one expect that it will. Certainly not with regard to something like WebAssembly, which all of the “leading” browsers are in the process of adopting.

      10. John Fenderson said on January 18, 2018 at 5:58 pm
        Reply

        @Anon: “But still i’m thankfull for their work since it’s the only good independent browser we have”

        Well, I don’t agree that it’s the only good independent browser we have. It’s not even one of the better ones, in my opinion — but what’s “good” or “bad’ in this sort of thing boils down to whether or not it meets my needs. It’s necessarily a subjective assessment.

        You’re right, Mozilla owes us nothing. But I’ve been using FF since the beginning (and have been financially contributing), and so I have a deep emotional connection both to Mozilla and FF.

        That’s why I find the release of Quantum so painful — it has become a browser that no longer meets my needs. I’m clearly no longer part of Firefox’s intended customer base, and that reality is a bitter pill to swallow.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.