Jump to content

A peak into optimization


Recommended Posts

Hi folks,


I recognize that a lot of the development work on IA4 is kind of done in a black void, so I thought I'd share some data on optimization generated over last Friday's beta test.




This graph shows server performance per minute, relative to the number of players connected and the number of AI units present in the mission.  If you played on Friday you noticed that performance really began to tank at around the two hour mark.  Your first instinct might be to think, "well, the mission's been running for 2 hours, there's probably a lot of clutter, lots of units running around, it's probably making the mission slower".  But in fact, that's not the case.  The key metric that's slowing down the mission...?  The number of players connected!


Arma's actually quite efficient when it comes to running units, the trouble is when you have a mission that is running any kind of custom script (as both 3 and 4 do) in order to manage how the mission plays, and to give any special instructions to the AI units.  In the case of 4, there's one special script called opforAwarenessDaemon, whose sole purpose is to give instructions to patrolling AI units based on their knowledge of player units.  Put another way: if you're shooting at the AI, the script will let the AI respond to your shots rather than just sit there and take it.  It'll have them change their patrol path, call in support from other units, or even call in air support.


Here's another version of the chart that's a bit easier to read when it comes to player count / FPS;


What we're seeing in the graph is that when the player count is below 30 players, everything is working fairly well - average server FPS (the green line) hovers between 20-47 FPS, which is excellent.  And it's doing so whether the number of AI is low or high. But when we get over 30 players, server performance tanks quickly (see the chart between the 100 and 150 minutes mark).  This is because with more players, there are more enemy units, and they're taking longer to do their opforAwareness check.  And since Arma's internal design philosophy is that if the program can't complete a script in a certain amount of time, it gets bumped to the next cycle, which just pushes the problem further down the line... until eventually the program crashes.


(the spikes, if you're wondering, are generally when new AOs are spawning and a bunch of new AI units are populated.)


So, how does one address this?


1. Less AI units?  IA4 scales the number of enemy units to the number of players, so that there are plenty of targets for the players to engage and make the mission fun.  If I reduce the number of units, I'll hear more feedback of "I just got the AO and it ended".  And since on its own, Arma is pretty efficient at running units, that's not the preferred option.

2. Optimize opforAwarenessDaemon?  Definitely the preferred direction.  Data like this helps me identify methods for improving the efficiency of the code in question.  In the script there are a few factors to be decided in figuring out what targets the enemy AI units will prioritize, as I've laid out in this decision tree: to summarize, every 20 seconds, an enemy group leader will assess their known targets, and decide whether one of them is a threat worth leaving their patrol route to attack.

OpforAwareness decision tree.png

There are certainly things I do (ie., corners I can cut) which give similar results to what I'm looking for, that are more efficient in doing so. But the long and the short of it is the same.  If there are more players to assess, and more enemy groups to do the assessing, then that's more work being performed by the server.


3. Cut opforAwarenessDaemon?  It has to be a consideration; while the intent of IA4 is to create a more intelligent mission, if the performance requirements to do so exceed the playability of the mission, then it's just not worth it to pursue, and maybe it'll have to go back on the shelf and await a more capable engine (Arma 4, here we come?).


So that's a look at how the sausage gets made - if you have comments or suggestions, I'm always happen to discuss.


- R

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Forum Statistics

    Total Topics
    Total Posts
  • Create New...