lua-users home
lua-l archive

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


Mark Hamburg wrote:
> Very cool. And do I recall that this no longer needs Coco and hence  
> should be friendlier toward use cases with lots of coroutines?

Yes, it's operating on a single C stack, only switching Lua stacks
(i.e. heap-allocated objects). The coroutine model of LuaJIT 2.x
is more like RVM than Coco in that respect.

LuaJIT 2.0 coroutines use very little memory:

LuaJIT 2.0.0             410 bytes/coroutine (lua_State + default stack)
Lua 5.1.4 (x86/POSIX)    860
Lua 5.1.4 (x86/Win32)   1040
Lua 5.1.4 (x64)         1250
LuaJIT 1.1.5           62550

So you can happily juggle with hundreds of thousands of them (again).

Since there is also less context to update, coroutine yield/resume
is substantially faster (even though the JIT compiler currently
falls back to the interpreter for this).

--Mike