Lua's Energy Problem
Interpreted languages are notoriously power-hungry. Lua, despite its lightweight design, is no exception. A new paper from João Saraiva (arXiv:2601.16670) measures Lua's runtime performance and energy efficiency across 25 official interpreter versions and JIT compilers. The results are stark: the best LuaJIT compiler consumes seven times less energy and runs seven times faster than the best Lua interpreter. LuaJIT even approaches C's efficiency, using roughly six times more energy and running about eight times slower.
Methodology: 25 Versions Under Test
The study uses a comprehensive benchmark suite to measure execution time and energy consumption. It covers:
- Standard Lua interpreters: versions 5.1 through 5.4 (and sub-releases)
- LuaJIT compilers: including LuaJIT 2.0, 2.1, and the latest 2.2 development branch
All benchmarks were run on a controlled hardware setup (Intel i7-12700, 32GB RAM, Ubuntu 22.04) using Intel's RAPL (Running Average Power Limit) interface for energy measurement.
JIT Compilation: The Game Changer
LuaJIT's trace-based JIT compilation transforms hot loops into machine code, eliminating interpreter overhead. The paper reports that all LuaJIT versions outperform all interpreters on both speed and energy. For example, on the binary-trees benchmark, Lua 5.4 interpreter consumed 120 Joules and ran for 8.5 seconds, while LuaJIT 2.1 consumed only 17 Joules and ran for 1.2 seconds.
# Example: run Lua benchmark with energy measurement
$ perf stat -e power/energy-pkg/ lua binary-trees.lua
$ perf stat -e power/energy-pkg/ luajit binary-trees.lua
Comparing to C
C remains the gold standard. The study includes C implementations of the same benchmarks (compiled with GCC -O3). Results show:
- LuaJIT is 8x slower and uses 6x more energy than C
- Standard Lua interpreter is 56x slower and uses 42x more energy than C
This demonstrates that JIT compilation bridges much of the gap, though native compilation still wins.
Evolution Over Time
The paper tracks Lua's efficiency across versions. Key findings:
- Lua 5.1 to 5.4: Performance improved ~15%, energy efficiency ~20%
- LuaJIT 2.0 to 2.2: Performance improved ~30%, energy efficiency ~25%
- LuaJIT 2.2 (2025): Best overall, with 7x improvement over Lua 5.4 interpreter
Why Developers Should Care
If you're using Lua in production (e.g., game scripting, embedded systems, or Redis scripting), switching from the standard interpreter to LuaJIT yields immediate benefits. The paper provides concrete evidence that JIT compilation is not just about speed—it's about reducing energy costs and carbon footprint.
Practical Next Steps
- Replace
luawithluajitin your build scripts and Docker images - Benchmark your own Lua code using
perf stat -e power/energy-pkg/to measure energy - Consider LuaJIT FFI for performance-critical sections—it can call C functions directly, reducing overhead further
Limitations
The study focuses on CPU-bound benchmarks. I/O-bound or memory-bound workloads may show different characteristics. Also, LuaJIT may not support all Lua 5.4 features (e.g., goto with labels), so test compatibility first.
The Bottom Line
LuaJIT is a drop-in replacement that makes Lua 7x greener and faster. For any team serious about sustainability or performance, there's no reason to stick with the standard interpreter.




