-
Notifications
You must be signed in to change notification settings - Fork 677
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
WIP: Build without Lua scripting via USE_LUA (#1204) #1245
base: unstable
Are you sure you want to change the base?
Conversation
I see the Test Tags system now and am using that to constrain tests which utilize Lua. |
This sounds right to me.
Test tag sounds like the best solution. Is it feasible? (If not, maybe we can just run a few selected test suites in the CI for the build without Lua.) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1245 +/- ##
============================================
- Coverage 70.70% 70.65% -0.05%
============================================
Files 114 114
Lines 63157 63159 +2
============================================
- Hits 44653 44628 -25
- Misses 18504 18531 +27
|
Although I perhaps wanted It passes tests with both See this commit for the tag changes. |
I guess |
I hadn't re-run Lua-enabled after fixing some Lua-disabled tests.... this last commit corrects that with the proper empty results. |
The expression `dictSize(evalScriptsDict())` is used a couple times for memory reporting. `dictSize` is a macro without NULL checking and used within a `FMTARG` macro in `server.c`. Overall, this makes it challenging to stub out when building without the Lua engine. This change lifts that expression up to its own function `evalScriptsDictSize`. Signed-off-by: Evan Wies <[email protected]>
Adds the ability to disable Lua scripting using the build conifguration `USE_LUA`. This will prevent the building of the Lua static library and will keep Lua and most Lua scripting internals out of the build. This approach strived to minimize the change surface, stubbing out keys requried functions and otherwise `ifdef`ing out large swathes of code. The base Lua scripting commands like `EVAL` remain intact, but reply with an error message `Lua scripting disabled`. `INFO` commands still include scripting statistics to prevent breaking any DevOps scripts, etc. Signed-off-by: Evan Wies <[email protected]>
Adds LUA_TEST_FLAGS to Makefile to propagate filtering of scripting tests. Expands "scripting" tag to all uses of Lua. Signed-off-by: Evan Wies <[email protected]>
Signed-off-by: Evan Wies <[email protected]>
Signed-off-by: Evan Wies <[email protected]>
Signed-off-by: Evan Wies <[email protected]>
* fix ci.yml whitespace, from yamlint * fix defrag.c, from -Werror Signed-off-by: Evan Wies <[email protected]>
Sorry for the repeated build failures -- glad the CI catches it :) I was missing some targets and hence some Lua coverage. I still cannot do a full test on Linux with |
* Make clang linter happy in defrag.c * Tag a test as scripting in memefficiency.tcl Signed-off-by: Evan Wies <[email protected]>
We discussed this in an online meeting. The core team was OK with being able to remove LUA from the server, but we would like to make it more pluggable and modular. Instead of just not installing LUA, we would like to make it so that LUA is not added as an engine (similar to how functions allows you to specify the engine type) and so when you try to run EVAL you get an error like "no default engine loaded". In the future folks can use either Lua 5.4 or LuaJIT. |
Signed-off-by: Evan Wies <[email protected]>
I made that error message change per your suggestion. Some of that work (modular engine system) is beyond the scope of this PR, but I think it is a sensible approach. At least the If you have specifics to add that are low-hanging, I could explore it. |
There is partial logic for a modular engine system. EVAL currently accepts a shebang that is intended to be able to select the scripting engine in the future.
Here we want the module API to provide a way for modules to provide a scripting engine. I created this issue: #1261. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we allow loading of functions in case the engine doesn't support any engine. Would that cause any confusion? Same thing applies for functions arriving via replication stream.
void evalCommand(client *c) { | ||
addReplyError(c, "No default engine loaded"); | ||
} | ||
|
||
void evalRoCommand(client *c) { | ||
addReplyError(c, "No default engine loaded"); | ||
} | ||
|
||
void evalShaCommand(client *c) { | ||
addReplyError(c, "No default engine loaded"); | ||
} | ||
|
||
void evalShaRoCommand(client *c) { | ||
addReplyError(c, "No default engine loaded"); | ||
} | ||
|
||
void scriptCommand(client *c) { | ||
addReplyError(c, "No default engine loaded"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need test to cover these scenarios. So, we might need separate test suite/tag for this particular flow.
dictDefragFunctions defragfns = { | ||
.defragAlloc = activeDefragAlloc, | ||
.defragKey = (dictDefragAllocFunction *)activeDefragSds, | ||
.defragVal = (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS ? (dictDefragAllocFunction *)activeDefragSds | ||
: val_type == DEFRAG_SDS_DICT_VAL_IS_STROB ? (dictDefragAllocFunction *)activeDefragStringOb | ||
: val_type == DEFRAG_SDS_DICT_VAL_VOID_PTR ? (dictDefragAllocFunction *)activeDefragAlloc | ||
.defragVal = (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS ? (dictDefragAllocFunction *)activeDefragSds | ||
: val_type == DEFRAG_SDS_DICT_VAL_IS_STROB ? (dictDefragAllocFunction *)activeDefragStringOb | ||
: val_type == DEFRAG_SDS_DICT_VAL_VOID_PTR ? (dictDefragAllocFunction *)activeDefragAlloc | ||
#ifdef USE_LUA | ||
: val_type == DEFRAG_SDS_DICT_VAL_LUA_SCRIPT ? (dictDefragAllocFunction *)activeDefragLuaScript | ||
#endif | ||
: NULL)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be just me. But ifdef
within the struct declaration gives a hit to the readability. We can consider refactoring this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe like?
dictDefragFunctions defragfns = {
.defragAlloc = activeDefragAlloc,
.defragKey = (dictDefragAllocFunction *)activeDefragSds,
.defragVal = (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS ? (dictDefragAllocFunction *)activeDefragSds
: val_type == DEFRAG_SDS_DICT_VAL_IS_STROB ? (dictDefragAllocFunction *)activeDefragStringOb
: val_type == DEFRAG_SDS_DICT_VAL_VOID_PTR ? (dictDefragAllocFunction *)activeDefragAlloc
: NULL)};
#ifdef USE_LUA
if (val_type == DEFRAG_SDS_DICT_VAL_LUA_SCRIPT)
dictDefragFunctions.defragVal = (dictDefragAllocFunction *)activeDefragLuaScript;
#endif
Adds the ability to disable Lua scripting using the build
configuration
USE_LUA
. This will prevent the buildingof the Lua static library and will keep Lua and most Lua
scripting internals out of the build.
This approach strived to minimize the change surface, stubbing out
keys requried functions and otherwise
ifdef
ing out large swathes of code.The base Lua scripting commands like
EVAL
remain intact, but replywith an error message
Lua scripting disabled
.INFO
commandsstill include scripting statistics to prevent breaking any DevOps scripts, etc.
There are decisions to make:
What do with
EVAL
commands, etc? Currently, the command still exists but replies with an Error.What to do with testing infrastructure?
EVAL
is sprinkled throughout.grep -or EVAL tests/unit | wc -l ==> 125
. Do we break tests into files withEVAL
and ones without?