Friday 17 February 2012

Testing Performance of Battles

The past week I've mainly been working on the parallel (multi-core) code ensuring its all stable, tracking down any race conditions and seeing how it all performs with lots of battles going on.

Below is some screenshots for the stress test I did to help me decide what to set the maximum number of ships per game to.

The galaxy I generated had 100 star systems, 200 planets and at each planet there is a 36 vs 36 ship battle taking place at exactly the same time. So in total there are 14,400 ships being simulated in full detail. The chances of there being so many battles taking place at once in a typical game will be very small. The much larger "total objects" stat in the screenshots includes asteroids, wreckage as well as the ships.

My development computer has:
AMD Phenom X4 9950 (4 cores)
Nvidia Geforce GTX 260
2GB Ram

Overall I'm fairly pleased with the performance so far as I havnt yet profiled or optimised most of the code. However the galaxy view in the second screenshot still needs work as the stars in the background are not rendered very efficiently.

Screenshots at various stages of the test as more ships get destroyed...







4 comments:

  1. I'm really excited about this. It looks like it is exactly the sort of 4x game I can really enjoy!

    ReplyDelete
  2. I started reading and thought the ship cap was going to be 36/army and I was sad… then I read the next sentence and saw it was 14,400 or 7,200/army and I was happy :) And this is before optimization! Please make sure to test on ATI video card.

    ReplyDelete
  3. 14.4k ships is really impressive. You should do a tutorial after this project is done. I can't wait to see how you handled these ships. Any hints?

    ReplyDelete
    Replies
    1. This is not going to be much a tutorial, but my best advise would be to use multi-threading to avoid processors from doing nothing most of the time.

      I currently use the Parallel Patterns Library thats included with Visual Studio for all the thread handling code which will scale to however many cores the game is run on.

      Writing decent multi-threaded code is rather problematic and you have to make sure to avoid deadlocks/race conditions, protect shared data and that the threading overhead doesnt outweigh any perfomance boosts (function granularity).

      To give you an idea how much difference this makes, when I disable all the multithreaded code in the game (debug option in the settings) so that it uses the single-core code instead, it can only handle about 20% the maximum number of ships.

      Delete