Merged
Conversation
aa07afe to
2cbccd5
Compare
Although the code already uses lua_pcall() to call the Lua function lookup_policy(), it does not protect the code that sets the call frame of lookup_policy(). Therefore, if Lua runs out of memory (or any other error), the Lua state panics. Not only does this commit protect the code that sets the call frame of lookup_policy(), but it also runs Lua's garbage collector and retries lookup_policy() if the failure was due to a lack of memory.
acd4b25 to
7adb7aa
Compare
This commit closes #212
The TBL24 present in a FIB head takes 64MB. A Lua policy may have 4 FIBs: IPv4 source, IPv4 destination, IPv6 source, IPv6 destination. Therefore, an instance of a Lua policy may take more than 4 * 64MB = 256MB. A typical Grantor server has 2 instances of the GT Block. Therefore, The instances of a Lua policy may take more than 2 * 256MB = 512MB. During reloads or recreation of FIBs, the number of FIBs may double. Which requires more than 1GB of memory and reaches LuaJIT's limit of 1GB per process. This patch moves FIB heads to huge pages to avoid the problem decribed above. Moreover, having TBL24s in huge pages is also a performance improvement since it puts less load on the virtual memory subsystem and it is NUMA aware.
Owner
Author
|
This pull request has successfully reduced the memory pressure on Lua policies in production. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As Lua policies evolve, they may increase the memory pressure on Lua. This pull request releases some of this pressure.
The long-term solution is to upgrade to LuaJIT v2.1 and to enable GC64 once LuaJIT v2.1 is stable.