lua-users home
lua-l archive

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


Greetings,

I need some advice before I take an important design decision in my project.

It involves having thousands of simultaneously running scripts, such as for
NPC's AI (agents) and other tasks. I'll have a preemptive scheduler to
manage the running scripts (using yield with count hooks).

Besides the elevated number of running scripts, there's also an elevated
number of spawned scripts per second. Scripts are always being created and
destroyed.

My question is: should I go for a system with only one real lua_State and
thousands of threads, or a mix of real lua_States with threads?

Please ignore the fact that if I have multiple lua_States I'd have to "open"
the lualibs multiple times, as it would NOT be necessary in my project.

I'm especially concerned about a lua_State getting too crowded, i.e. garbage
collection consuming too much time and the registry table etc getting too
big. I'm sure there are many non-linear algorithms involved (reallocation
etc).

I'm considering the ideal system for my project, taking into account known
upcoming technologies such as the incremental garbage collector in Lua 5.1.

Any thoughts?

Thanks,
Thiago Bastos