[aquaria] Patch to run Lua scripts as threads

Andrew Church achurch+aquaria at achurch.org
Thu Jul 8 23:01:28 EDT 2010

Good news: I've gotten PSP loading times down about 30% with the new
script handling. (:  I ended up having move the entire contents of
entityinclude.lua straight into the C++ code (because the dofile() that
loads it isn't executed until script runtime, so it ended up loading
entityinclude into every single script instance) -- but that means we
can pass the C++ named constants straight into Lua instead of having two
separate copies of the constants, so it may be for the better.

I also tried precompiling the scripts, but that didn't make any
measurable difference, so I'll just leave that out for simplicity.
I suspect the speedup is mainly from reducing the amount of I/O, which
is slow on the PSP -- I couldn't see any difference in PC loading times
with the new script execution model.

Memory usage is up a bit, unfortunately (4.9MB to 5.6MB in Home Waters),
but it's still a lot better than it used to be (21MB), so it should be
good for now.  If I get around to trying out that alternate threading
model, I may try using the nested environment trick again so we only
need one copy of the common functions and constants.

  --Andrew Church
    achurch at achurch.org

>Sweet. :)
>Yeah that sounds a lot more involved... It'll be interesting to see how this
>affects performance!
>On Wed, Jul 7, 2010 at 12:30 PM, Andrew Church
><achurch+aquaria at achurch.org<achurch%2Baquaria at achurch.org>
>> wrote:
>> Actually, I already finished fixing up the scripts to use the getVars()
>> system -- as the enormous diff in my repository can attest to. (:  I'm
>> running through them at the moment to find regressions and deal with
>> a few variable typos and stuff I caught along the way.  I haven't tried
>> a PSP build yet, but I'm hoping it'll cut down on map change time now
>> that we don't have to compile every script umpteen times over.  It does
>> feel like map changes on the PC are a little faster, though my own
>> system is fast enough it's hard to tell the difference.
>> I still want to try and find a way to get the scripts working without
>> the extra variable table, not so much for performance or anything but
>> because I always strive for elegant code (as you may have noticed, heh).
>> I think the ultimate solution would be to redesign the scripts to run as
>> true threads, in the sense that you start a script and it keeps running
>> in a while loop or something until the entity dies or the map changes or
>> whatever.  That may be a project for Much Later, though...
>>  --Andrew Church
>>    achurch at achurch.org
>>    http://achurch.org/

More information about the aquaria mailing list