Share this project

Done

Share this project

Done
Planetary Annihilation brings RTS gameplay to a new generation of players in a way that's never been seen before.
Planetary Annihilation brings RTS gameplay to a new generation of players in a way that's never been seen before.
44,162 backers pledged $2,229,344 to help bring this project to life.

Multithreading - The Future of PA and Titans

Posted by Planetary Annihilation Inc (Creator)
70 likes

Hello Commanders,

@sorian is back working on server simulation performance with multithreading this month and we have a technical update to share on his work for the next update.

Two years ago I was given the opportunity to continue work on my baby, Planetary Annihilation, for the 99377 Performance Update. My primary focus was attempting to improve performance by multithreading parts of the simulation. My initial focus was on areas of the simulation where I thought it would be easiest to do things in parallel. The most natural separation was based around planets.

Since navigation and physics are typically the worst performance offenders, separating updates by planet seemed like a good plan. Their updates tend to only act on a single entity. Initial testing blew up spectacularly, as I expected it would. Fortunately, there were not many areas of contention between threads and a performance win was born.

So, now that I am back, you may be wondering what I am working on now. I’ll be continuing right where I left off! This time I am digging further into the sim to see where I can split large groups of tasks over threads to speed things up. Early this week I was focused on the physics update. I figured, since we should only be looking at two unique physics objects at the same time, it should be possible to thread this.

Well, I was right and wrong. There were the usual small issues to fix, but threading the physics update revealed a larger issue. The physics system utilizes an HGrid (described as a loose octree) to find potential entity overlaps using a function called buildPairs. It turns out that there is no guarantee that the vector of pairs that we get back does not contain duplicates. Under normal operation this isn’t a huge issue, as this is a single call that immediately returns and it was just being done thousands of times more than it needed to be. However, when you throw threading into the mix it gets ugly. Fixable, but ugly.

I have also started work on restructuring the sim tick a bit to allow the navigation and physics updates to happen alongside other updates. Right now I have it running alongside the economy update, but the economy update is only a small part of the overall update, so not much of a win there yet. I am hoping to split some of the plan steps (our sim has plan, execute, and record steps for entities) out into a group that can also run at the same time as the navigation/physics update.

For the navigation system, I have been mainly focusing on the epic number of allocations the navigation system does during voxel integration. I have a new system in place that saves off vectors of cost cells (the objects the integrator makes tens of thousands during voxel integration) for reuse. The integrator is also doing a better job of allocating in blocks instead of individually. On the multithreading front, the navigation system has proven to be quite difficult. There are so many little acceleration features and so much lazy loading that is simply prevents multithreading without a significant amount of work.

So, what’s next? There is still more work to be done with navigation, there is still the sim tick stuff to be investigated, and some AI updates as well (of course), starting with a much needed performance pass. And that doesn’t even get into other fun stuff like modern toolchain and Coherent GT updates.

Mike “Sorian” Robbins

https://forums.uberent.com/threads/multithreading-the-future-of-pa-and-titans.73101/

Matt Pettifer, jarnhaan, and 68 more people like this update.

Comments

Only backers can post comments. Log In
    1. Missing avatar

      Neil Hooey on

      Hey Sorian, is Mavor joining the new team to work on PA?

    2. Mark on

      @ardemeus yes.
      You may also like to read some past blogs from sorian.
      https://web.archive.org/web/20170303114938/https://soriandev.blogspot.com/

    3. Nathan Camp on

      It is awesome to get these behind the scenes looks, they are one of my favourite parts of kickstarters.

      Also it is amazing seeing this one light up again! So keen for more action on the developers side.

    4. ardemeus on

      Is he the same sorian who made a.i. for supreme commander ?

    5. Missing avatar

      Robert Silesius on

      This is amazing.

      Is this going to coincide with a PR push to attempt to get the game into the spotlight again?

    6. Paolo Pomes on

      Oh yes! Talk nerdy to me! XD

    7. volumedigital on

      Nice work, Sorian. Thanks for the post - John Mavor's technical chat during the kickstarter campaign was a highlight for me, so keep 'em coming, if you can spare the time!

    8. Missing avatar

      FrankyB on

      Thank you for the very interesting insights! I just hope nobody wants to blow off Linux support. Keep up the excellent work!