[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Squeezing more coroutines ?
- From: roberto@... (Roberto Ierusalimschy)
- Date: Sat, 2 Jun 2007 10:19:04 -0300
> So far things are looking great, as far as both available cpu and
> memory usage are concerned: after increasing LUAI_MAXCSTACK, I've been
> testing with 300.000 concurrent and mostly idle threads, created with
> lua_newthread(). Memory usage for these is about 350M, i.e. a little
> over 1KB per created thread.
>
> [...]
>
> Has anyone managed to create something on the order of 1,000,000
> coroutines ? If so, any tips on what to leave out from lua_State (or
> other places) would be appreciated.
Have you tried to reduce the stack size? If each coroutine does very
simple things, maybe each could run with a smaller initial stack.
For instance, you could try BASIC_CI_SIZE=5 (or even smaller; this is
the number of nested calls in a coroutine), and LUA_MINSTACK=10
(this is a little tricky, but should work; I don't think any C function
uses more than 10 temporaries without checking the stack...).
Beware that whenever a stack is too small Lua doubles its size. So,
if you start with too small stacks, you may end with them larger than
if you start with initially larger stacks. (E.g., you set BASIC_CI_SIZE=3,
but your program needs 7. Lua will double it twice, leaving the final
size equal to 12.)
-- Roberto