Questions tagged [luajit]

LuaJIT is a Just-In-Time Compiler for the Lua programming language. LuaJIT offers more performance, at the expense of portability. On the supported OS's (all popular operating systems based on x86 or x64 CPUs (Windows, Mac OSX, Linux, ...), ARM based embedded devices (Android, iOS) and PPC/e500v2 CPUs) it offers an API- and ABI-compatible drop-in replacement for the standard Lua interpreter.

Overview

LuaJIT is a high-performance, Just-In-Time(JIT) implementation by Mike Pall for the Lua programming language. It has been successfully used as a scripting middleware in games, 3D modelers, numerical simulations, trading platforms and many other specialty applications. It combines high flexibility with high performance and an unmatched low memory footprint: less than 125K for the virtual machine(VM) plus less than 85K for the JIT compiler (on x86).

LuaJIT has been in continuous development since 2005. It's widely considered to be one of the fastest dynamic language implementations. It has outperformed other dynamic languages on many cross-language benchmarks since its first release — often by a substantial margin. In 2009 other dynamic language VMs started to catch up with the performance of LuaJIT 1.x. Well, I couldn't let that slide. ;-)

2009 also marks the first release of the long-awaited LuaJIT 2.0. The whole VM has been rewritten from the ground up and relentlessly optimized for performance. It combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler. An innovative trace compiler is integrated with advanced, SSA-based optimizations and a highly tuned code generation backend. This allows a substantial reduction of the overhead associated with dynamic language features.

It's destined to break into the performance range traditionally reserved for offline, static language compilers.

Compatibility

LuaJIT implements the full set of language features defined by Lua 5.1. The virtual machine is API- and ABI-compatible to the standard Lua interpreter and can be deployed as a drop-in replacement.

LuaJIT offers more performance, at the expense of portability. It currently runs on all popular operating systems based on x86 or x64 CPUs (Linux, Windows, OSX etc.) or embedded systems based on ARM (Android, iOS) or PPC/e500v2 CPUs. Other platforms will be supported in the future, based on user demand and sponsoring.

388 questions
56
votes
1 answer

Why is LuaJIT so good?

EDIT: unfortunately LuaJIT was taken out of the comparison in the link below. This comparison of programming languages shows that LuaJIT has an over tenfold improvement over the normal Lua implementation. Why is the change so big? Is there something…
Mihai
  • 1,155
  • 2
  • 11
  • 18
48
votes
4 answers

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

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…
Gabriel Cuvillier
  • 3,403
  • 1
  • 25
  • 31
41
votes
2 answers

How to compile Lua scripts into a single executable, while still gaining the fast LuaJIT compiler?

How can I compile my Lua scripts into a single executable file, while also gaining the super fast performance benefits of LuaJIT? Background: My Lua scripts are for a web application I created (e.g. to host http://example.com) My current technology…
nickb
  • 8,430
  • 11
  • 34
  • 46
20
votes
4 answers

How do install libraries for both Lua5.2 and 5.1 using Luarocks?

I am writing a small Lua project and using Luarocks to install my 3rd-party dependencies. The default Lua version on my machine is 5.2 and up to this point everything is working just fine. However, today I have stumbled across a problem that is…
hugomg
  • 63,082
  • 19
  • 144
  • 230
18
votes
1 answer

How to check if nginx uses LuaJit and not Lua?

I installed http-lua-module with nginx, made a script that works perfectly fine, but now I want to be sure that nginx uses LuaJit instead of Lua (because my research shows that LuaJit is faster). I added to the .bushrc those lines of code : export…
Vor
  • 27,623
  • 37
  • 119
  • 184
17
votes
4 answers

How catch ctrl-c in lua when ctrl-c is sent via the command line

I would like to know when the user from a command line presses control-c so I can save some stuff. How do I do this? I've looked but haven't really seen anything. Note: I'm somewhat familiar with lua, but I'm no expert. I mostly use lua to use the…
lars
  • 1,786
  • 3
  • 27
  • 43
15
votes
3 answers

How to install Torch on windows 8.1?

Torch is a scientific computing framework with wide support for machine learning algorithms. It is easy to use and efficient, thanks to an easy and fast scripting language, LuaJIT, and an underlying C/CUDA implementation. Q: Is there a way to…
101010
  • 39,010
  • 10
  • 84
  • 149
11
votes
3 answers

How to use LuaJIT's ffi module when embedding?

I'm trying to embed LuaJIT into a C application. The code is like this: #include #include #include #include #include int barfunc(int foo) { /* a dummy function to test with FFI */ return…
jagttt
  • 936
  • 1
  • 10
  • 24
11
votes
3 answers

How to get past 1gb memory limit of 64 bit LuaJIT on Linux?

The overview is I am prototyping code to understand my problem space, and I am running into 'PANIC: unprotected error in call to Lua API (not enough memory)' errors. I am looking for ways to get around this limit. The environment bottom line is…
robm
  • 1,133
  • 1
  • 12
  • 22
10
votes
2 answers

How difficult is the LuaJIT FFI?

I recently looked into Lua and it seems really nice. The only annoying thing is its lack of (standard) libraries. But with the JIT compiler comes along a nice FFI C interface. Coming from a java background, i tried to avoid C as much as possible,…
Moe
  • 1,019
  • 1
  • 9
  • 14
9
votes
2 answers

Are there any examples of multithreaded Tracing JIT compilers?

Both the JVM and the .NET CLR include Just-In-Time compilers which support multiple user threads. However, I believe these are method-at-a-time JITs. All of the tracing JITs I am aware of, for example LuaJIT and PyPy, are only single-threaded. Are…
user200783
  • 12,313
  • 10
  • 58
  • 110
8
votes
2 answers

Why is LuaJIT's memory limited to 1-2 GB on 64-bit platforms?

On 64-bit platforms, LuaJIT allows only up to 1-2GB of data (not counting objects allocated with malloc). Where does this limitation come from, and why is this even less than on 32-bit platforms?
bobcat
  • 9,713
  • 6
  • 34
  • 72
8
votes
2 answers

How does LuaJIT's trace compiler work?

I've been reading up on JIT's and LuaJIT's trace compiler in particular, and I ended up with some questions. From what I understand, LuaJIT's JIT doesn't compile hot methods like Java's HotSpot does, it compiles hot paths originating from loops.…
Robin Heggelund Hansen
  • 4,716
  • 6
  • 32
  • 51
8
votes
1 answer

Does LuaJIT support __gc for tables?

Lua 5.2 (in contrast to 5.1) supports __gc for tables. Has LuaJIT borrowed this nice feature? (I did a google search, and examined LuaJIT's Change History but couldn't figure out the answer.)
Niccolo M.
  • 3,132
  • 1
  • 14
  • 30
7
votes
4 answers

LuaJIT not seeing rocks installed by LuaRocks

lua -e "print(package.path)" ./?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib/lua/5.1/?.lua;/usr/lib/lua/5.1/?/init.lua luajit -e…
1
2 3
25 26