Session& session,
const std::string &script)
: Plugin (engine, session)
- , _mempool ("LuaProc", 1048576) // 1 MB is plenty. (64K would be enough)
+ , _mempool ("LuaProc", 2097152)
, lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
, _lua_dsp (0)
, _script (script)
LuaProc::LuaProc (const LuaProc &other)
: Plugin (other)
- , _mempool ("LuaProc", 1048576) // 1 MB is plenty. (64K would be enough)
+ , _mempool ("LuaProc", 2097152)
, lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
, _lua_dsp (0)
, _script (other.script ())
_stats_avg[0] = _stats_avg[1] = _stats_max[0] = _stats_max[1] = _stats_cnt = 0;
#endif
+ lua.tweak_rt_gc ();
lua.Print.connect (sigc::mem_fun (*this, &LuaProc::lua_print));
// register session object
lua_State* L = lua.getState ();
#ifdef WITH_LUAPROC_STATS
int64_t t1 = g_get_monotonic_time ();
#endif
- lua.collect_garbage (); // rt-safe, slight *regular* performance overhead
+
+ lua.collect_garbage_step ();
#ifdef WITH_LUAPROC_STATS
++_stats_cnt;
int64_t t2 = g_get_monotonic_time ();
, pending_locate_flush (false)
, pending_abort (false)
, pending_auto_loop (false)
- , _mempool ("Session", 1048576)
+ , _mempool ("Session", 2097152)
, lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
, _n_lua_scripts (0)
, _butler (new Butler (*this))
Glib::Threads::Mutex::Lock tm (lua_lock, Glib::Threads::TRY_LOCK);
if (tm.locked ()) {
try { (*_lua_run)(nframes); } catch (luabridge::LuaException const& e) { }
+ lua.collect_garbage_step ();
}
}
#ifndef NDEBUG
lua.Print.connect (&_lua_print);
#endif
+ lua.tweak_rt_gc ();
lua.do_command (
"function ArdourSession ()"
" local self = { scripts = {}, instances = {} }"
int do_command (std::string);
int do_file (std::string);
void collect_garbage ();
+ void collect_garbage_step ();
+ void tweak_rt_gc ();
sigc::signal<void,std::string> Print;
lua_gc (L, LUA_GCCOLLECT, 0);
}
+void
+LuaState::collect_garbage_step () {
+ lua_gc (L, LUA_GCSTEP, 0);
+}
+
+void
+LuaState::tweak_rt_gc () {
+ //lua_gc (L, LUA_GCSETPAUSE, 20);
+ lua_gc (L, LUA_GCSETSTEPMUL, 100);
+}
+
void
LuaState::print (std::string text) {
Print (text); /* EMIT SIGNAL */