Jump to content

asm.js in Firefox Nightly


Bu7ch

Recommended Posts

I’m happy to announce that OdinMonkey, an asm.js optimization module for Firefox’s JavaScript engine, is now in Nightly builds and will ship with Firefox 22 in June.

What is asm.js? Why are we doing it, and how are we getting to within 2x of native performance? This post won’t be able to go into too much detail since we’re hard at work preparing for Mozilla’s upcoming GDC session, which you should definitely come see (Wednesday 11am, Room 3024, West Hall). After GDC, expect full coverage of these topics by Alon, Dave, myself and surely others. For now, allow me to point you at the asm.js FAQ, Alon’s mloc.js slides, a nice Badass JavaScript post and a more in-depth post by Axel Rauschmayer.

Want to see it in action? Download a new Firefox Nightly build and try out BananaBench. (Note: BananaBench runs with a fixed time step to make JS execution deterministic, so game speed will run fast/slow, depending on your hardware/browser.) Or, check out a demo of the Emscripten-compiled Bullet engine simulating a ton of falling boxes.

At the moment, we have x86/x64 support on desktop Windows/Mac/Linux and support for mobile Firefox on ARM is almost done. Since we intend to continue to iterate on the asm.js spec in cooperation with other JS engines, we’ve put OdinMonkey behind the flag javascript.options.​experimental_asmjs in about:config. This flag is currently enabled by default on Nightly and Aurora, and if nothing changes over the next 12 weeks, will be automatically disabled in Beta and Release. By then, we hope to be happy with a stable “asm.js v.1″, we’ll enable it everywhere and ship with it enabled in our final builds.

If you want to start experimenting with asm.js right now, you can:

  • Get Emscripten and start compiling C/C++ code. (Don’t forget the -O2 -s ASM_JS=1.)
  • Check out the draft spec and start writing asm.js by hand.

In the future, we’d like to see a rich third option of generating asm.js using a more ergonomic front-end language (e.g., a derivative of LLJS).

How do you know if you are generating valid asm.js and taking full advantage of OdinMonkey? In the old days, this was a frustrating question for developers. Maybe you were doing something wrong, maybe the code, as written, was just slow. One cool thing about asm.js is that the "use asm" directive makes the programmer’s intention quite clear: they want to compile asm.js. Thus, if there is an asm.js validation error, OdinMonkey will print a warning on the JavaScript console. (OdinMonkey emits a warning, instead of throwing an error, since asm.js is just JavaScript and thus cannot change JavaScript semantics.) In fact, since silence is ambiguous, OdinMonkey also prints a message on successful compilation of asm.js. (There is currently a bug preventing asm.js optimization and warnings in Scratchpad and the Web Console, so for now experiment in regular content.)

For those who are itching to do some performance experiments: go for it, we’ve been pretty happy with the results so far when asm.js is applied to new codes, but we’ve also seen plenty of cases where the C++ compiler is doing important backend optimizations that we haven’t taught our IonMonkey backend yet. We expect continuous incremental improvement as we measure and implement new optimizations to close this gap. Second: one performance fault that we already know trips up people trying to benchmark asm.js is that calling from non-asm.js into asm.js and vice versa is much slower than normal calls due to general-purpose enter/exit routines. We plan to fix this in the next few months but, in the meantime, for benchmarking purposes, try to keep the whole computation happening inside a single asm.js module, not calling in and out.

84b36df6893299c77fc6719ed1cd3c5c.png

:view: View: Original Article

Link to comment
Share on other sites


  • Replies 11
  • Views 2.8k
  • Created
  • Last Reply
  • Administrator

Firefox sticks it to Google with OdinMonkey, which can boost JavaScript performance by 1000% or more

Mozilla has just rolled out OdinMonkey, a new module for Firefox’s JavaScript engine that promises to speed up JavaScript execution beyond your wildest dreams. If you were drawn to Chrome because of its superior JavaScript performance, or to Internet Explorer because of its neat separate-process Chakra JavaScript engine, OdinMonkey — which can boost JavaScript performance by 1000% or more — will put you firmly back in the Firefox camp.

OdinMonkey is a module for Firefox’s IonMonkey JS engine that optimizes the execution of asm.js. In short, asm.js takes specially-crafted JavaScript code, compiles it to native assembly language, and executes it. With OdinMonkey optimizing this process, code executed this way is only two times slower than native execution (as if the code was executed locally, outside the browser, without the JS-to-assembly transcompiling). While this might not sound particularly fast, normal JavaScript (such as when you load the ExtremeTech website) is maybe 20 or 30 times slower than native code. For comparison, Chrome executes asm.js code at around 10 times slower than native speed, and Firefox (without OdinMonkey) is around 12 times slower than native.

Barely a day goes by without a headline announcing the arrival of an exciting new feature in Chrome, Firefox, Safari, or their mobile variants. For the most part, despite the headlines that tech sites use, these features aren’t actually all that exciting. OdinMonkey, however, really is a big deal: Not only does it boost performance by a huge margin, but it could also act as a cornerstone for web apps that actually perform like their installed, native cousins. In short, OdinMonkey could finally allow for a web-based Adobe Photoshop or Crysis.

Gz34pNb.png

Asm.js and other browsers benchmarked against native code. The native code is baseline, the other values are the number of times slower that an implementation is

More importantly, though, asm.js offers an alternative to Google’s Native Client — a module for Chrome and Chrome OS that allows the browser to execute native C and C++ code. (See: What is Native Client?) While the implementation of Native Client is just fine, the problem is that it draws developers away from cross-platform open web technologies, such as HTML5, CSS, and JavaScript. Mozilla has always been leery of Google’s Native Client intentions, especially when Big G spends so much time extolling the virtues of open web technologies. OdinMonkey and asm.js essentially offer a high-performance alternative that retains the flexibility and platform agnosticism offered by open web technologies. (See: Firefox OS doesn’t stand a chance.)

OdinMonkey landed in Firefox Nightly yesterday, which means it should arrive in the stable build of Firefox 22 in June, assuming no blocking bugs are encountered. If you want to try out OdinMonkey and asm.js, you’re probably out of luck for now. For now, OdinMonkey is designed to handle code that has been created with Emscripten — a relatively new project that’s also developed by a Mozillan. As always, while a new technology might sound awesome, it takes a lot of time and effort for it to cross the chasm from theory and into reality. Still, Firefox and Mozilla are a force to be reckoned with, and no one ever complains about faster JavaScript performance — so here’s hoping that OdinMonkey makes a splash, and that dynamic websites are soon 20 or 30 times faster.

:view: View: Original Article

Link to comment
Share on other sites


just installed 22 nightly and it is really faster in the banana test and the box test than my current firefox 22b6 :D

Link to comment
Share on other sites


just play around with ff 22 nightly and i am very impressed , the above tests run smoother on FF than chrome , even sites and other stuff run fast and IMO faster than google chrome!

way to go mozilla :)

Link to comment
Share on other sites


Is there any tests available? Between Nightly which uses asm.js and latest trunk version of Chromium.

And Nightly went to version 23.0a1 yesterday.

Link to comment
Share on other sites


Is there any tests available? Between Nightly which uses asm.js and latest trunk version of Chromium.

And Nightly went to version 23.0a1 yesterday.

no poing using ff 23 since asm.js doesnt work for any site yet just the above mention in the first post

Link to comment
Share on other sites


  • Administrator

Is there any tests available? Between Nightly which uses asm.js and latest trunk version of Chromium.

And Nightly went to version 23.0a1 yesterday.

no poing using ff 23 since asm.js doesnt work for any site yet just the above mention in the first post

Do note. Mozilla recently ported Unreal Engine 3 to Firefox using this. A real demo of Unreal Engine 3 optimized with this will be released soon. ;)

Link to comment
Share on other sites


Is there any tests available? Between Nightly which uses asm.js and latest trunk version of Chromium.

And Nightly went to version 23.0a1 yesterday.

no poing using ff 23 since asm.js doesnt work for any site yet just the above mention in the first post

Do note. Mozilla recently ported Unreal Engine 3 to Firefox using this. A real demo of Unreal Engine 3 optimized with this will be released soon. ;)

yes .l but afaiu the tech need to be installed in internet pages and other ways in order to feel any ff 23 new tech,,,

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...