Page 1 of 1

Progress on scripting engine

Posted: Sun Jun 07, 2009 1:51 am
by zuzuf
So how is this going ? Well, we have support for both COB and Lua scripts.

You can script AIs, missions and units. There is now a console interface for debugging mission and AIs scripts (Lua only but COB scripts are not applicable to those kinds of scripts anyway).
This new scripting engine introduced a big performance loss because of the abstraction layer lacking some optimizations. Good news, it's been fixed in last revision (along with lots of other bugs in LuaThread).

So what's the secret of speeding up those scripts ? In fact scripts run quite fast, what was slow was starting a script because it involved creating a new ScriptInterface object which is slow for COB scripts and much worse for Lua scripts since it almost creates a new VM. So finally recycling our garbages solved the problem :D. Instead of creating and releasing those threads, they are only created when needed, once they're useless they're removed from the execution stack and stored into a freeThread queue where we'll take them later when we need some ScriptInterface thread to run a script function.

I can now run a game with hundreds units fighting at 10x speed !! (before this optimization it slowed down to 1x or lower :( - those results are with a binary built without optimization in a debugger :P ).

Performance is back :twisted:

Re: Progress on scripting engine

Posted: Sun Jun 07, 2009 5:38 am
by xpoy
Performance is back :twisted:

Re: Progress on scripting engine

Posted: Sun Jun 07, 2009 7:10 am
by Balthazar
Perfomance is back!

:P