by nonchalance · 13y ago · 0 comments
> When I sit down and think about performance gains that asm.js-implementation OdinMonkey-style brings to the table I don’t see anything that would not be possible to achieve within a normal JIT compilation framework and thus simultaneously make human written and compiler generated output faster.
https://v8.googlecode.com/issues/attachment?aid=25990016000&...
you can see that on a few of those there is still a significant difference, for example on Lua (I filed an issue on that here http://code.google.com/p/v8/issues/detail?id=2873 ).
In principle, a JIT can do anything an AOT compiler can (and more). In practice, the JITs in Chrome and Firefox have gotten close to what the asm.js AOT in Firefox can reach, but only on most benchmarks, not all. The AOT does give a fairly good guarantee of always running the code at a good speed, while the JITs depend on heuristics. In practice, this means that JITs can be tweaked to run any benchmark well, but they don't always do it out of the box, while the AOT far more often does do so.
Again, JIT heuristics can be fixed and improved, I have no doubt about that. And JITs could be designed to rely less on heuristics, I am a strong believer in that as well. But neither of those has yet been proven. I hope they will, though :)
There is still a ways to go though before they are fully on par with Firefox. Note that one of the benchmarks is still far slower on Chrome, and there are still probably edge cases here and there that trigger slow JS in Chrome. The guarantee of asm.js that your code is ~2x slower than native is nice. Additionally, loading in massive amounts of asm.js in Firefox will be much faster in Firefox in the future when they optimize the parser for asm.js.
All in all, these are very happy times. There are pros and cons to both approaches, but it's exciting to see how far it's going.
What? How did a couple of benchmarks that showed ~2x performance for a few tasks become a 'guarantee'? In some situations asm.js only takes twice as long to run your code, in others it takes 12 times as long[1] or even more[2].
[1] http://cdn.arstechnica.net/wp-content/uploads/2013/05/benchm... [2] http://cdn.arstechnica.net/wp-content/uploads/2013/05/classi...
It's fair to say that for single-threaded code, asm.js has a very good chance of running at half the speed of native, or better. For multicore code, it depends on whether web workers make sense for that use case - if they do, it can still maintain the same performance compared to native. Otherwise, the web platform would need to consider adding some more low-level parallelism to JS. Such proposals exist and there is some discussion about them.
It's hard to get over the fact that a JIT simply faces an uphill battle against an engine that starts by restricting you to a subset of the language; basically, you can assume both engines are being written by equally smart people, so you kind of have to expect that the one that takes the restrictions is going to have a long-term persistent advantage in practice, no matter how theoretically the other team could catch up. OdinMonkey still has all the JIT opportunities, but it has other opportunities too.
JavaScript is not some immutable thing. It needs enhancing, not replacing.
edit: Video link http://www.youtube.com/watch?v=IXIkTrq3Rgg
I looked at the spec briefly (http://wiki.ecmascript.org/doku.php?id=strawman:value_object...), but it doesn't talk about the how.
I agree that we don't want to break the single-threaded JS model. But we have options, the easiest of which is to restrict shared mutable state to ArrayBuffers and asm.js, or asm.js-like code.
In this cas mozilla is the one that took the lead on the asm.js case, and healthy competition is always better, but I believe it makes no doubt that the v8 team would have worked at improving their js speed as much as possible even without that pinch from mozilla.
That's not accurate. I recommend you go back and look at the actual order of events here.
Apple started the JS perf battle with SquirrelFish Extreme and Firefox answered with TraceMonkey, all before Chrome was even announced.
I am not discounting the impact that V8 has had on the industry, but it is simply wrong to claim that Google kicked this thing off when Apple and Mozilla were both there publicly squaring off in JS benchmarks well before you, and just about every one else on the planet, even knew Chrome was a thing.
http://nontroppo.org/timer/kestrel_tests/
and when Safari was still an early beta Opera was marketed as "The Fastest Browser on Earth".