lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Ilya Martynov wrote:
> On Wed, Apr 18, 2012 at 20:11, Michal Kottman <k0mpjut0r@gmail.com> wrote:
> > You can alleviate this problem by going multi-process instead of
> > multi-thread. Since your worker thread already run in their own Lua
> > environments, they could also be running inside their own Lua process. You
> > can use something like ZeroMQ to handle communication between processes.
> > Since each process has its own virtual memory, every process can allocate
> > the full amount of memory LuaJIT allows.
> 
> Multi-process approach doesn't work very well if you need to share data
> between threads.

Since sharing Lua data between threads is not safe, you need to
marshall everything between threads using shared memory. Or better
directly access shared memory. But that's the ideal use case for
FFI data structures, because they can be safely shared (with
appropriate locking, just like in C).

If you have big data structures, then your best bet is to manage
them with the FFI, anyway. There's no 2GB or 4GB limit for them on
LuaJIT/x64. Shareability is an added bonus.

--Mike