aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-01-05 14:54:31 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-01-05 14:54:31 +0100
commitddd66308d67ae29b59b81bd83fe0506e4a11d08b (patch)
treebe6dad87ae0fe72f5d118196be12b2f22799f164
parent97df9bd48cb6d4847896377d4eefaead9e2cd75f (diff)
downloadapplause2-ddd66308d67ae29b59b81bd83fe0506e4a11d08b.tar.gz
flush LuaJIT compiled code cache before executing commands
-rw-r--r--applause.c14
-rw-r--r--applause.lua5
2 files changed, 19 insertions, 0 deletions
diff --git a/applause.c b/applause.c
index 4a5f453..6c3a2a3 100644
--- a/applause.c
+++ b/applause.c
@@ -638,6 +638,20 @@ do_command(lua_State *L, const char *command)
int stack_top;
char *buffer;
+ /*
+ * EXPERIMENTAL: I found that performance decreases
+ * progressively when running one and the same command.
+ * This is probably because the limited space for the
+ * compiled code gets filled up rapidly and LuaJIT
+ * resorts to using the interpreter.
+ * This flashes the entire code cache for every
+ * new command and improves matters.
+ * TODO: It would probably be a good idea to increase the
+ * total size of the code cache and give some indication
+ * of its usage (e.g. in the prompt).
+ */
+ luaJIT_setmode(L, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_FLUSH);
+
/* the error hanlder function for lua_pcall() */
lua_pushcfunction(L, traceback);
diff --git a/applause.lua b/applause.lua
index 5fe77e4..dd1d78f 100644
--- a/applause.lua
+++ b/applause.lua
@@ -400,6 +400,11 @@ function Stream:play()
-- Perform garbage collection cycle and turn it off
-- temporarily. This improves the realtime properties
-- of the sample generation loop below.
+ -- FIXME: Since stopping the garbage collector here
+ -- (in the Lua/C code this did not happen!?), memory
+ -- consumption increases constantly. Perhaps it is a
+ -- good idea to tweak garbage collection during the
+ -- generator loop.
collectgarbage("collect")
collectgarbage("stop")