lua-users home
lua-l archive

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


On 28/01/2014 4:49 AM, Dirk Laurie wrote:
Now if I redesign it to use fewer lua_States that would be nicer. But I'd
>rather not then see performance hickups come in and learn that the original
>design was actually better.
>
A lua_State is simply a thread, and if you are only accessing it via
the coroutine
library it is idiomatic Lua (=nice) even if you have a huge table of coroutines.

Doesn't a lua_State also include its own GC state?

The implication being that many independent lua_States will each have their own independent (non-interfering) GC contexts, whereas running all tasks as coroutines within a single lua_State will share a single GC context (and potentially interact/interfere).

Seems to me that allocating and tearing down a lua_State for each task might have more predictable memory behavior (similar to using zones/arenas). Reusing a single lua_State will have behaviour more strongly dependent on the long term behavior of the GC algorithm (which might be good or bad).

Just some idle conjecture, but I'd be interested to hear the GC aspect discussed.

Ross.