Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> How does PNaCl differ beyond intermediate representation from asm.js?

Both are basically intended as a target for LLVM-compiled code, so lots of similarities, but the main difference is that asm.js is a subset of JS so it runs in any JS engine, while PNaCl is different. Aside from that, there are lots of technical differences, but it's hard to say which actually matter in the long run. To quickly summarize, right now asm.js tends to run a little more slowly than PNaCl but start up a little more quickly. But engineers on PNaCL and on JS engines intend to shrink those differences over time, and there is no reason in principle why they won't succeed.

To judge for yourself, you can see some comparisons between PNaCl and asm.js in these two sites:

http://www.flohofwoe.net/demos.html

http://trypepperjs.appspot.com/

My impression is that the perf differences are not that noticeable already. For example, the bullet demo in the second one seems to run slightly faster in PNaCl than asm.js. However, profiling shows that 65% of time is spent in three.js rendering code, not in asm.js, so perhaps rendering differences account for most of the disparity, and it mostly isn't comparing asm.js to PNaCl.



We were seeing some significant slowdowns when running lua in emscripten (testing on repl.it) vs. PNaCl.

Take this naive fibonacci function: function fib(n) return n<2 and n or fib(n-1)+fib(n-2) end print(fib(30))

On my machine, it completes in less than a second on PNaCl, but takes nearly 10 seconds to complete in emscripten.


repl.it contains code from a few years ago. That's way before a huge amount of general optimizations in emscripten, as well as asm.js. Here is a more up to date Lua VM running in JS:

http://kripken.github.io/lua.vm.js/repl.html

But even that is already out of date ;) just this week I found that I was building Lua with a bad choice of optimization flags. We include Lua VM benchmarks in the emscripten test suite, so for the latest numbers (with the proper optimization flags), see

https://docs.google.com/spreadsheet/ccc?key=0AkuGewEm05tZdFd...

It's possible to run the Lua VM in JS at only about 50% slower than a native build.

edit: fix link


Ah, thanks for that! I was wondering if repl.it was out of date. Might be worthwhile to get the owner to update... :)


Regarding repl.it, I'm not sure how active it is. Their python C port for example is 2 years since the last update. I'll ping them to see.

Regarding lua, I updated the lua vm project, and tried your fibonacci function from before in the repl

http://kripken.github.io/lua.vm.js/repl.html

Looks like in both firefox and chrome it runs in about a second in JS, which feels about the same as the time it takes in PNaCl in chrome on

http://gonativeclient.appspot.com/demo/lua




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

Search: