News for hackers. Stuff that matters.
Re:V8: A Tale of TurboFan by rurban on Thursday March 02, 2017 @04:35AM (#13772839)
Seeing all the problems and wrong assumptions they had, makes me appreciate luajit even more.

100x smaller, multiple times faster and did it right from the beginning.

Re:V8: A Tale of TurboFan by mraleph on Thursday March 02, 2017 @09:51AM (#13774326)
> multiple times faster

This is an unsubstantiated claim. If LuaJIT was indeed multiple times faster on arbitrary code, everybody would be just running JS on something like LuaJIT in browsers :)

LuaJIT does spectacular job on loops, especially if you limit yourself to number crunching and FFI.

But if you code is polymorphic, makes heavy use of normal OOP and does not decompose into a graph of biased loops and linear traces V8 will pull ahead due to its method-compiler nature which is not susceptible to tracing pitfalls.

Here is an interesting example: there is an issue[1] "Metatable/__index specialization" in LuaJIT repository filed by Mike Pall himself, it's about adding infrastructure which would allow traces to make optimistic assumptions about metatable constness, because it would greatly improve the quality of traces produced from OOP heavy code. (Also this is precisely the limitation that is already imposed on FFI metatypes to allow JIT generate better code). The issue is still unimplemented in LuaJIT... However this is something that V8 could do for several years now, because it is extremely important for the kind of code people are writing in the real world.

[1] https://github.com/LuaJIT/LuaJIT/issues/41

Re:V8: A Tale of TurboFan by readittwice on Thursday March 02, 2017 @05:39AM (#13773094)
To be fair it probably also helped that Lua is a simpler language and therefore easier to optimize. A tracing JIT also has an inherent downside: the infamous example of an if in an inner loop with roughly the same probability for the then and else branch.

That said LuaJIT is an impressive piece of software. Would love to know what Mike Pall is up to now.

Re:V8: A Tale of TurboFan by Nemcue on Thursday March 02, 2017 @08:24AM (#13773815)
Afaik it's so complex it can't keep up with Lua though.
Re:V8: A Tale of TurboFan by beagle3 on Thursday March 02, 2017 @03:06PM (#13777712)
It could easily keep up with Lua if Mike Pall agreed with the changes made to Lua, but he didn't.

The Lua ecosystem is very different than almost any other; It's primary use case, probably 95% of projects using it or more, is being embedded into another project for scripting/configuration/control. As such, it is common for projects to pick a version of Lua and stick with it, rather than upgrade to the latest-and-greatest-with-slight-to-major-incompatibilities. Pall liked 5.2, and thought 5.3 didn't offer enough to break compatibility.

Re:V8: A Tale of TurboFan by curveship on Thursday March 02, 2017 @08:32AM (#13773845)
> multiple times faster

You sure about that? In the alioth benchmarks, v8 wipes the floor with lua: http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...

Re:V8: A Tale of TurboFan by pygy_ on Thursday March 02, 2017 @08:44AM (#13773915)
That's not LuaJIT
Re:V8: A Tale of TurboFan by curveship on Thursday March 02, 2017 @09:03AM (#13774023)
Ah, my bad. Are you aware of any benchmarks comparing v8 to LuaJIT? Looks like LuaJIT got removed from the alioth site (?).
Re:V8: A Tale of TurboFan by igouy on Thursday March 02, 2017 @11:30AM (#13775361)
6 years ago.

"If you're interested in something not shown on the benchmarks game website then please take the program source code and the measurement scripts and publish your own measurements."

Like this guy did -- https://pybenchmarks.org/u64q/which-programs-are-fastest.php

Re:V8: A Tale of TurboFan by scriptproof on Thursday March 02, 2017 @04:41AM (#13772858)
That is irrelevant. On a typed and mostly static language all is 100x easier to compile too.
Re:V8: A Tale of TurboFan by NiLSPACE on Thursday March 02, 2017 @04:52AM (#13772899)
Lua is a dynamic language though.
Re:V8: A Tale of TurboFan by scriptproof on Thursday March 02, 2017 @09:49AM (#13774309)
You are right. What is the magic formula to make the JIT so fast?
Re:V8: A Tale of TurboFan by pjako on Thursday March 02, 2017 @11:48AM (#13775581)
Javascript has some features that makes it hard to be JITed. For example it has no fixed object layout. If you are interested into how language design impacts performance this is worth reading: http://wren.io/performance.html
Re:V8: A Tale of TurboFan by throwawayish on Thursday March 02, 2017 @04:46AM (#13772881)
JavaScript is typed as well.