AltraMayor/gatekeeper

Upgrade to LuaJIT 2.1

AltraMayor opened this issue · 1 comments

There are currently three motivations for upgrading LuaJIT from 2.0 to 2.1 in Gatekeeper:

  1. The 1GB memory limit per process. Let $x$ be the amount of memory that a Lua state in an instance of the GT block consumes; this Lua state is responsible for running the Lua policy. A typical Grantor server has 2 instances of the GT Block. During Lua policy reloads, new Lua states are created in parallel to avoid hiccups while making policy decisions. Thus, $4x$ must be less than 1GiB, which implies that $x < 256MiB$; this is not much. Currently, Lua policies consume less than 1MB because most of its resources are allocated outside of Lua. LuaJIT 2.1 introduces the new garbage collector GC64, which lifts this limit to 128TB.
  2. There is no way to catch the "not enough memory" exception; also see the page LuaJIT v2.0 Status. If this exception were catchable, GT instances could run the garbage collector and retry. This problem has been solved in LuaJIT 2.1.
  3. Lua memory is not in huge pages or NUMA aware. Once GC64 is available, issue #143 can finally be implemented.

LuaJIT is being assumed to be on rolling releases; that is, it's stable, and updates are being made to branches 2.0 and 2.1. Moreover, LuaJIT 2.1 has been used in production by OpenResty at least since 2014. Therefore, we can upgrade to LuaJIT 2.1 before it gets the official "stable" mark. If something goes wrong, we can workaround disabling the JIT compiler with jit.off().