Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions doc/admin-guide/plugins/lua.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,24 @@ enabled. The default value of '0' means disabled.

::

map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/XXX/tslua.so @pparam=--ljgc=1
map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/XXX/tslua.so @pparam=--ljgc=1 @pparam=/script/test.lua


Configuration for JIT mode
==========================

We can also turn off JIT mode for LuaJIT when it is acting as global plugin for Traffic Server. The default is on (1). We can write this in plugin.config to turn off JIT
We can also turn off JIT mode for LuaJIT for Traffic Server. The default is on (1). We can write this in plugin.config to turn off JIT

::

tslua.so --jit=0 /etc/trafficserver/script/test_global_hdr.lua

An example when using the plugin in remap.config

::

map http://a.tbcdn.cn/ http://inner.tbcdn.cn/ @plugin=/XXX/tslua.so @pparam=--jit=0 @pparam=/script/test.lua


Profiling
=========
Expand Down
15 changes: 15 additions & 0 deletions plugins/lua/ts_lua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,10 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
int fn = 0;
int states = ts_lua_max_state_count;
int ljgc = 0;
int jit = 1;
static const struct option longopt[] = {
{"states", required_argument, 0, 's'},
{"jit", required_argument, 0, 'j'},
{"inline", required_argument, 0, 'i'},
{"ljgc", required_argument, 0, 'g'},
{0, 0, 0, 0 },
Expand All @@ -367,6 +369,19 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_s
Dbg(dbg_ctl, "[%s] setting number of lua VMs [%d]", __FUNCTION__, states);
// set state
break;
case 'j':
jit = atoi(optarg);
if (jit == 0) {
Dbg(dbg_ctl, "[%s] disable JIT mode for remap plugin", __FUNCTION__);
for (int index = 0; index < ts_lua_max_state_count; ++index) {
ts_lua_main_ctx *const main_ctx = (ts_lua_main_ctx_array + index);
lua_State *const lstate = main_ctx->lua;
if (luaJIT_setmode(lstate, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF) == 0) {
TSError("[ts_lua][%s] Failed to disable JIT mode for remap plugin", __FUNCTION__);
}
}
}
break;
case 'i':
inline_script = optarg;
break;
Expand Down