lua-users home
lua-l archive

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


Thiago Bastos wrote:
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).

¿Have you taken any time measurements?
I don't know about you, but in my experience, having thousands of scripts running simultaneously doing anything non-trivial is very demanding for the CPU. Also, saying that you will also be spawning new scripts doesn't help things, because some time will be spent parsing them.

In my preliminary tests, I found lua to be about ten times slower than equivalent C++ code (which BTW is very good performance). But I don't plan on having thousands of characters running simultaneously: if I did, I would probably want that 10x performance back.

Make sure that you can afford so many NPCs before you decide on the specific way to divide the work in threads.

Sergio.