View Single Post
Old 02-12-2012, 07:36 PM   #1
Kitriel
New Member
 
Join Date: Jul 2010
Posts: 10
Kitriel is on a distinguished road
High volume scripting question

I've been dabbling and testing my lua scripting embedded into my c++ original code base, and i've got it working fine. No errors and it all does what I want. My issue is when I have a high volume of scripts running at once.

I was just curious how other codebases that use these combinations, or other combinations of source and scripting language, handle high volume of scripts being executed at once.

Possible solutions I've thought of that don't quite work:

-I currently outsource my saving code to a seperate program, which saves on its own. This frees the core program to continue what it's doing and the background program saves on its own time and taking up its own resources(albeit shared with the core program, just not slowing the core down while it waits for it). This example works perfectly with saving data, as it is not time sensitive and does not need to return anything to the core program. Since scripts interact with the core (to pull or set variables/etc), this tactic gets a tad more complicated and i'm not overly sure it'd even work, but it is something i've been debating about doing.

-Another example would be to throttle the number of scripts that can execute 'at once', but this still comes back to the problem of idle scripts(executed every 1sec) having the potential to be greatly delayed. In high volumes, this delay could be as high as minutes. (say 2500 scripts, for example. Theoretical, of course, but that delay using this method would still exist)

-I've looked into multi-threading and learned how it works, and it's quite useful if used right. But my concern comes down with integrity of the variables being used by the scripts if several scripts are being run at the same time against the same mob or player. If one script on one thread changes a variable that another script on another thread is currently using ... yeah, ****(pardon my language) goes down hill fast.

So basically i'm just wondering how others have handled this issue and hoping they can share their experiences(and headaches) that this issue may have caused and how they solved it as i'm currently scratching my head over this problem. And quite frankly, it's game breaking and extremely demoralizing because I wanted a game filled with scripts to enhance 'reality' or 'believability' of the world. aka having mobs actually go to jobs and do things and wander (not aimlessly) between shops/friends/etc.

Thanks for your time and any responses,
-Kitriel
Kitriel is offline   Reply With Quote