Jump to content
XCOMUFO & Xenocide

Performance Question


dteviot

Recommended Posts

OK, looking at the current (XNA) Geoscape design, I'm suspecting that the major consumer of CPU time is going to be testing UFOs for radar visibility.

And obviously, the more UFOs, Aircraft and X-Corp bases there are, the heavier this loading is going to be.

So, I want to do some experiments to find out just how bad it is.

To this end, I need to know:

  • What's the maximum number of UFOs ever seen on the Geoscape simultaneously?
  • What's the typical/maximum number of craft people have flying on the Geoscape simultaneously?
  • What's the typical/maximum number of bases people have?
  • As the number of bases increases, does the number of flying craft tend to drop off?

Thanks for you input

Link to comment
Share on other sites

Max # of UFOs: maybe 10. Not sure - average normally around 2-6

Max# of flying craft: 5 - average around 2-3

Typical # of bases: 5-8 (a lot of smaller radar bases)

After 3 bases the number of flying X-COM craft stays the same. # of detected UFOs rises of course

 

Hope this helps.

Link to comment
Share on other sites

First advice :), don't suspecting is not enough to do microperformance testing. Based on the tenths of performance analysis I had to do to at work, microperformance testing dont work; usually a small change can change the performance bottleneck to another place. Having GPU and CPU makes things worse.

 

Furthermore I found that most of the time the biggest hogs are those that you wouldnt suspect of in the first place. Code for manteinability and readability, if we pinpoint a problem we profile it an act in consecuence, optimized code can get pretty nasty fast. Avoid code optimization, focus on design optimization (less code, more readable probably faster understanding and optimizing if needed) ;). If you still have any specific worry, lets analyze the particular design you are worried about.

 

Greetings

Red Knight

Link to comment
Share on other sites

First advice :), don't suspecting is not enough to do microperformance testing. Based on the tenths of performance analysis I had to do to at work, microperformance testing dont work; usually a small change can change the performance bottleneck to another place. Having GPU and CPU makes things worse.

 

Furthermore I found that most of the time the biggest hogs are those that you wouldnt suspect of in the first place. Code for manteinability and readability, if we pinpoint a problem we profile it an act in consecuence, optimized code can get pretty nasty fast. Avoid code optimization, focus on design optimization (less code, more readable probably faster understanding and optimizing if needed) ;). If you still have any specific worry, lets analyze the particular design you are worried about.

 

Greetings

Red Knight

Actually, I am not intending to do microperformance testing, exactly. I just want to get an idea if basic algorithm is going to work, or if I'm going to eventually need to do something more clever. Read complicated, more error prone, and take more time to implement.

 

To expand, with the current design, in the geoscape there's an update() loop that updates the state of the objects in the geoscape each time slice.

At current time, the maximum time slice is going to be one minute of game time per update().

Now, during the time slice, the following things will happen.

1. UFOs positions are updated.

2. Check UFOs for radar visibility.

3. Update X-Corp craft positions, using radar information where known.

4. Check the queue of scheduled events, (e.g. Research projects, base facility construction, etc. and fire any that are now due.

 

Of these taks 2 is likely to be the most expensive, because I have to check every UFO against every base and craft, to see if it's in radar range. This results in

(num craft + num bases) * (num ufos) = (5 + 8) * 10 = 130 distance calculations every update.

 

So, my plan was to set up a simple test with 10 UFOs flying a random walk mission, 13 craft with a "fly to nearest UFO" mission. And then see how many updates the PC could crank. If it manages 1440 per second, the rate is 1 day game time per second real time. (And I don't need to worry about optimization.) In fact, so far as I'm concerned, if it can manage a rate of 144 per second (6 game days per minute) I'm going to be happy with that. Once the rest of the game is working, I can then look at going back and speeding up radar detection/craft position updating.

 

I've got several ideas how this could be done, but don't want to do that until/unless I have to. (I'm putting them here so I don't forget them) E.g.

1. Bases are fixed, so I can precompute a 80 km square "gird" over the earth, and mark the number of radars covering each zone. Then I just take the UFO's position, and lookup the grid to see if I need to check for visibility or not. (That allows me to replace the num bases number in the above equation with one.)

2. Checking for craft visibility could be reduced by measuring the distance between craft and UFOs, then allow for speeds and figure out soonest time that a craft could reach range of a UFO. Then only check for radar visibility once that much time has passed.

Link to comment
Share on other sites

Well you can always use a probabilistic approach to handle variable timeslices. Sounds to me that 1 minute it would be a little too small a time step, especially on a 1 day timeframe. The algorithm may be sound, but as the time increase linerly with the timestep then the could definitely be a problem in the 1 day timestep. Moreover, as the calculation is not "bounded" over the timestep, as you are dependant on the Machine CPU for the interaction.

 

I would move toward a different approach, even before doing the performance testing; definitely there is a need to profile the process if you have reasons to go that way.

 

Greetings

Red Knight

Link to comment
Share on other sites

  • 2 weeks later...
OK, looking at the current (XNA) Geoscape design, I'm suspecting that the major consumer of CPU time is going to be testing UFOs for radar visibility.

And obviously, the more UFOs, Aircraft and X-Corp bases there are, the heavier this loading is going to be.

So, I want to do some experiments to find out just how bad it is.

To this end, I need to know:

  • What's the maximum number of UFOs ever seen on the Geoscape simultaneously?
  • What's the typical/maximum number of craft people have flying on the Geoscape simultaneously?
  • What's the typical/maximum number of bases people have?
  • As the number of bases increases, does the number of flying craft tend to drop off?

Thanks for you input

I'd agree with Mad about the max # of UFO's in the air at one time. 10 seems to be about right, and this tends to happen when you have an infiltration/base building mission in progress later in the game when detection ranges are higher.

 

For X-COM, the typical is 1-2 craft in the air. 4 are the max amount of craft you can engage a target at one time, and you may have a transport in the air too so 4-5 may be a typical max. The slower your craft are (I'm thinking about the starting craft here), the more you are going to have in the air at the same time. As for the ultimate max, that depends. You can build 8 bases, and at each of those bases you could build 8 Hangars. That would come out to 64 craft total. Nobody ever builds that many hangars though because defending the base from the inside becomes a strategic nightmare. Typical hangars are 3 per base. The typical number of bases depends on a lot of factors. Cost is a biggie. Time is another. If I play for a long time and refuse to go to Cydonia, 8 bases is not unusual. For other players who just want to beat the game as fast as possible, one base is certainly enough. If I had to make a guess, 4 would be the average.

 

For the last point (does the number of flying craft drop off), that depends on what you mean by craft and bases. X-COM or alien? The number of X-COM craft in the air at once does decline a bit as the number of your bases increase. This is because they are going to be closer to the action instead of a world away. If you mean UFO's, the number of alien craft in the air increases as you build bases due to increased radar coverage of the globe. Alien activity also increases as time goes on so that means a natural spike in detection due to sheer numbers. :)

 

- Zombie

Edited by Zombie
Link to comment
Share on other sites

OK, looking at the current (XNA) Geoscape design, I'm suspecting that the major consumer of CPU time is going to be testing UFOs for radar visibility.

And obviously, the more UFOs, Aircraft and X-Corp bases there are, the heavier this loading is going to be.

So, I want to do some experiments to find out just how bad it is.

To this end, I need to know:

  • What's the maximum number of UFOs ever seen on the Geoscape simultaneously?
  • What's the typical/maximum number of craft people have flying on the Geoscape simultaneously?
  • What's the typical/maximum number of bases people have?
  • As the number of bases increases, does the number of flying craft tend to drop off?

Thanks for you input

I'd agree with Mad about the max # of UFO's in the air at one time. 10 seems to be about right, and this tends to happen when you have an infiltration/base building mission in progress later in the game when detection ranges are higher.

 

For X-COM, the typical is 1-2 craft in the air. 4 are the max amount of craft you can engage a target at one time, and you may have a transport in the air too so 4-5 may be a typical max. The slower your craft are (I'm thinking about the starting craft here), the more you are going to have in the air at the same time. As for the ultimate max, that depends. You can build 8 bases, and at each of those bases you could build 8 Hangars. That would come out to 64 craft total. Nobody ever builds that many hangars though because defending the base from the inside becomes a strategic nightmare. Typical hangars are 3 per base. The typical number of bases depends on a lot of factors. Cost is a biggie. Time is another. If I play for a long time and refuse to go to Cydonia, 8 bases is not unusual. For other players who just want to beat the game as fast as possible, one base is certainly enough. If I had to make a guess, 4 would be the average.

 

For the last point (does the number of flying craft drop off), that depends on what you mean by craft and bases. X-COM or alien? The number of X-COM craft in the air at once does decline a bit as the number of your bases increase. This is because they are going to be closer to the action instead of a world away. If you mean UFO's, the number of alien craft in the air increases as you build bases due to increased radar coverage of the globe. Alien activity also increases as time goes on so that means a natural spike in detection due to sheer numbers. :)

 

- Zombie

 

Thank you.

Link to comment
Share on other sites

×
×
  • Create New...