Hacker News new | past | comments | ask | show | jobs | submit login
Asm.js performance improvements in the latest version of Firefox (hacks.mozilla.org)
162 points by matt42 on May 12, 2014 | hide | past | favorite | 34 comments



Not bad. On a related note, it seems that with FTLJIT, Safari now beats Chrome (V8) and Firefox-without-asm.js on asm.js benchmarks:

http://arewefastyet.com/#machine=12&view=breakdown&suite=asm...

This is great news for anyone for whom V8 was already good enough, although Safari's still handily beaten by Firefox with asm.js mode, which is handily beaten by native. I wonder whether Apple is interested in implementing a special asm.js mode for Safari, which, LLVM being LLVM, might surpass Firefox.


  together with all the other work on optimizing
  asm.js, allows it to run at around 1.5x slower
  than the speed of the same C/C++ when compiled
  natively
Running at 67% of native speed, and backwards compatible with all non ASM.js browsers? That's pretty great!


I am working on a project based on asm.js technology. From my experience very limited and simple asm.js code might be compatible with "all non asm.js browsers". In particular I found IE9 wouldn't work with some compiled code. IE10 so far so good (but slow of course.)


asm.js relies on typed arrays, and IE9 doesn't support them. So I'd be surprised if IE9 was able to handle any asm.js code.


Emscripten can emit code without typed arrays. It's fairly slow but does work in IE9.


Oh, cool. I didn't know that.


Yes, you are right, but I found back then that not all code can be compiled without these arrays. Can't remember why right now tho. So there are certainly issues with browsers not supporting typed arrays.


Yes, it is tricky to compile without typed arrays. It means we need to disable LLVM optimizations, and also a lot more undefined behavior in C will fail (anything that assumes memory aliasing).

With a little effort stuff can be ported, I ported CPython that way. But typed arrays is far better.


That asm.js demo of Angry Bots [1] is damn slick. In Chrome (2013 macbook air) it's a bit choppy, but on Firefox 30 beta it's very smooth.

[1] http://beta.unity3d.com/jonas/AngryBots/


I was really surprised to see it barely using only a fraction of my CPU on my MBP in Aurora (was expecting to see it max out one of my cores). Very cool stuff.


works well on FireFox even with an old computer,but yeah it's a catastrophy on Chrome or IE.Good for Firefox that could become the Gaming Browser. Bad for us devs that will have to learn C++ to get good perfs out of game,because you cant write asm.js by end.


Eh, it's possible to write asm.js just much harder than regular JavaScript.

Keep in mind Operating systems were written in assembly, asm.js is not as bad as assembly in some regards.


LLJS targeting asm.js may help but it still looks like an early effort.

http://jlongster.com/Compiling-LLJS-to-asm.js,-Now-Available...

https://github.com/jlongster/LLJS


There are constraints to asm.js that are restrictively difficult for a human to maintain. If your code doesn't pass the validator it runs as normal JS.


I'm not writing an operating system.The point is you cant get these perfs with using regular javascript.ASM.js is not regular javascript,since it's a subset.


No, but this operating system is the example of most performant, least resource hungry application I can think off. If you need performance you don't write C, you write assembly. Same with asm.js.


You try to avoid writing in assembly unless you absolutely have to, because it's a big maintenance pain and unless all your assumptions are correct it may not be as fast as the compiler.

It's not worth bothering with unless you're vectorising or want to use some other instructions that are not normally emitted (e.g. ARM add-with-saturation).


Yeah, but assembly generally isn't portable (x86 assembly is different than ARM assembly, etc.), that's what makes it biggest pain IIRC.

Asm.js on the other hand, is portable and just that makes it way better than any regular assembly. Also it seems better looking than regular assembly (no registers as such, no jumps, etc.).

It's a huge step back compared to plain JS, but it's not that impossible to write in.


Works "okayish" in Chrome for me.


Makes me think of this video "The Life and Death of Javascript " which brings what the future could be like with asm.js: https://www.destroyallsoftware.com/talks/the-birth-and-death...


I'm looking forward to Unity in the browser. The web player has never worked on Linux.

Unfortunately, the first demo terminates my browser with a segfault.

Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0


Segfaulted for me as well. FF v29.0.1, Arch Linux x86-64, kernel v3.14.3, Intel HD4600 under Mesa/Intel DRI v10.1.3. The WebGL test link posted by azakai does exactly the same thing though.

Discussion: https://bbs.archlinux.org/viewtopic.php?id=181408

Worked really smoothly on Windows.


Does your crash show up in Firefox's about:crashes page? The crash report might show whether it odds the same missing GL symbol the Arch Linux discusses.


about:crashes doesn't exist, but yes


Do other WebGL demos work on your machine? Might be a GL driver issue. Simple test is on http://get.webgl.org/


No. Additional context:

Arch Linux, 64-bit, fully updated. Nvidia proprietary drivers, triple headed setup with i3-wm.


WeBGL works just fine here (Arch Linux, 64-bit, Nvidia drivers [though my browser uses the Intel card]).


It's an issue with Archlinux package. The 64bit nightly from Mozilla worked for me with no issues.


Just tried the angrybots someone mentioned above and it worked just fine (xubuntu 14.04, Linux 3.13, nvidia gtx 670 (driver 331.38), firefox 29)


Works for me on 64bit Fedora. I use then nvidia drivers from rpmfusion.


The Dead Trigger 2[1] game runs amazingly smooth on FF 29.0, Debian, Kernel 3.2 and is amazing to play.

I have been playing for quite sometime now, but the only problem is I can't find how to change the guns. There is no menu options or anything.

[1] http://beta.unity3d.com/jonas/DT2/


Tab changes the guns. Also 1,2,3 do weapon-related effects (one of them is a grenade, I think).


Yeah. Found it. 3 throws grenade. Tab - next weapon, q - previous weapon.

Played it for an hour or so.


I hope one day it will not be possible to run manually-written JS in browser. You would need to use a safer language that compiles into an asm.js module.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: