[Tex/LaTex] LuaJIT and LuaTeX

lualuatex

Is it possible to change the Lua engine in LuaTeX to LuaJIT?

Will it be as simple as replacing the Lua5.1 source code in the LuaTeX tarball with the LuaJIT source, or does it require (drastic) changes to the build system, or is it entirely not possible?

Best Answer

I did an attempt a while ago with LuaJIT 1, and it did not seem to be that hard. A few small build tweaks would be needed, but nothing major.

The main reason why there is no LuaJIT in LuaTeX currently is that we have a few patches to Lua now that are not in LuaJIT (and are hard to add) like an extended coroutine subsystem. In lua5.2, our patches to the Lua core will become obsolete, so once we switch to that Lua version, LuaJIT becomes interesting again and I will certainly try to have LuaJIT support by default on the supported platforms. That should be before LuaTeX 1.0, but not in next few months.

But, don't expect much of it. Even in ConTeXt, most Lua processing is iterating over C data structures using our embedded Lua support libraries. JITting the little bit of Lua code that wraps that together will not help a lot, a few percent at best is my current guess (which is also why incorporating LuaJIT is low priority)

Related Question