13
0
Fork 0

Update Lua allocator for sessions scripts

* increase memory pool (bindings alone require 1.5 MB), and all session
  scripts have a shared memory pool.
* use TLSF (like Lua DSP processors) - this fixes an issue with atomics
  (notably int62_t, temporal) on macOS and ARM, which need to be
  aligned.
This commit is contained in:
Robin Gareus 2024-05-15 19:45:13 +02:00
parent afb519cd84
commit 9d046af47a
4 changed files with 18 additions and 3 deletions

View File

@ -30,7 +30,6 @@
#include <vector>
#include <string>
#define USE_TLSF
#ifdef USE_TLSF
# include "pbd/tlsf.h"
#else

View File

@ -60,11 +60,15 @@
#include "pbd/event_loop.h"
#include "pbd/file_archive.h"
#include "pbd/rcu.h"
#include "pbd/reallocpool.h"
#include "pbd/statefuldestructible.h"
#include "pbd/signals.h"
#include "pbd/undo.h"
#ifdef USE_TLSF
# include "pbd/tlsf.h"
#else
# include "pbd/reallocpool.h"
#endif
#include "lua/luastate.h"
#include "temporal/range.h"
@ -1652,7 +1656,11 @@ private:
bool pending_abort;
bool pending_auto_loop;
#ifdef USE_TLSF
PBD::TLSF _mempool;
#else
PBD::ReallocPool _mempool;
#endif
LuaState lua;
mutable Glib::Threads::Mutex lua_lock;
luabridge::LuaRef * _lua_run;

View File

@ -258,8 +258,14 @@ Session::Session (AudioEngine &eng,
, _last_roll_or_reversal_location (0)
, _last_record_location (0)
, pending_auto_loop (false)
, _mempool ("Session", 3145728)
, _mempool ("Session", 4194304)
#ifdef USE_TLSF
, lua (lua_newstate (&PBD::TLSF::lalloc, &_mempool))
#elif defined USE_MALLOC
, lua (lua_newstate (true, true))
#else
, lua (lua_newstate (&PBD::ReallocPool::lalloc, &_mempool))
#endif
, _lua_run (0)
, _lua_add (0)
, _lua_del (0)

View File

@ -321,6 +321,8 @@ def configure(conf):
atleast_version='0.24.2', mandatory=True)
conf.define ('LV2_SUPPORT', 1)
conf.define ('USE_TLSF', 1)
# non-standard LV2 extention -- TODO: add option to disable??
if conf.is_defined ('HAVE_LV2_1_10_0'):
conf.define ('LV2_EXTENDED', 1)