Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to LuaJIT 2.1 #637

Open
AltraMayor opened this issue Mar 28, 2023 · 1 comment
Open

Upgrade to LuaJIT 2.1 #637

AltraMayor opened this issue Mar 28, 2023 · 1 comment

Comments

@AltraMayor
Copy link
Owner

AltraMayor commented Mar 28, 2023

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 Allocate Lua states on NUMA nodes that GT instances reside #143 can finally be implemented.
@AltraMayor
Copy link
Owner Author

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant