Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is LuaJIT really faster than every other JIT-ed dynamic languages? [closed]

Tags:

jit

lua

luajit

According to the computer language benchmark game, the LuaJIT implementation seems to beat every other JIT-ed dynamic language (V8, Tracemonkey, PLT Scheme, Erlang HIPE) by an order of magnitude.

I know that these benchmarks are not representative (as they say: "Which programming language implementations have the fastest benchmark programs?"), but this is still really impressive.

In practice, is it really the case? Someone have tested that Lua implementation?

like image 783
Gabriel Cuvillier Avatar asked Apr 06 '10 20:04

Gabriel Cuvillier


People also ask

How is LuaJIT so fast?

LuaJIT uses advanced compilation techniques, and it also has a very finely engineered implementation. For example, when the fancy compilation techniques can't handle a piece of code, LuaJIT falls back to an very fast interpreter written in x86 assembly.

Is LuaJIT faster than C?

It can only be as fast as C, but is more likely to be slower. It can't be faster than the language of its own implementation. As long as the C code is fully optimized and uses the most appropriate algorithms. Poorly written C code can certainly be slower than well written LUA code.

What is the difference between Lua and LuaJIT?

LuaJIT is a Just-In-Time Compiler (JIT) for the Lua programming language. Lua is a powerful, dynamic and light-weight programming language. It may be embedded or used as a general-purpose, stand-alone language.

Is Lua fast enough?

Lua is fast Several benchmarks show Lua as the fastest language in the realm of interpreted scripting languages. Lua is fast not only in fine-tuned benchmark programs, but in real life too. Substantial fractions of large applications have been written in Lua.


2 Answers

There's a good discussion at Lambda the Ultimate. LuaJIT is very good.

Many people have reported impressive speedups on lua-l (the lua mailing list). The speedups are most impressive for pure Lua code; the trace compiler is not as effective when there are lots of calls to C functions in loadable library modules.

like image 59
Doug Currie Avatar answered Oct 13 '22 22:10

Doug Currie


In my case (a game prototype development), I observed no performance improvement at all. I use lua for embedding, so there are lots of calls to C++ library functions. Even though main loop is in a lua script and all of the important logic is implemented in lua, the overall performance was determined by rendering engines and physics engines implemented in C++. The original lua is already fast enough for such applications.

like image 21
tbear Avatar answered Oct 13 '22 23:10

tbear