What I did:
1. The pathfinder runs in an asynchronous thread in parallel with the rest of the simulation. This means that when units request paths, it just gives them path IDs, but no path yet. Less than 1 game frame later the path thread has computed the path, and the unit starts moving.
2. The movetype update and slowupdate is multithreaded. It updates all the movetypes in a random order, but it still syncs, because all the operations that would desync are delayed and run by a single thread afterwards.
3. Some additional (minor) multithreading of QuadField, Radar and LOS update.
1 and 2 depend on a system of "stable data" to make sure that unit data read by the worker threads is not changed suddenly by another thread. Any volatile data read would naturally desync the game.
The good:
Performance! (some examples below)
Random idling units: >100% faster
Patrolling fighters: >40% faster
Lots of collisions and pathfinding in large unit squads: >200% faster
Idling fighters: >20% faster
So basically this means twice as big battles if you have a quad core. You can "give all" twice as much units before the CPU is maxed out.
The bad:
It makes the code more complex
Units are a bit more likely to get stuck (fixable)
Some remaining bugs, and most likely desyncs (fixable)
If you have a quad core, please test and give feedback.
http://springrts.com/dl/buildbot/defaul ... -gad8971f/
Recommended settings for 8 logical CPUs:
Code: Select all
MultiThreadCount = 6
SetCoreAffinity = 1
SetCoreAffinitySim = 16
SetCoreAffinitySimMT = 204
SetCoreAffinityRenderMT = 204
SetCoreAffinityPath = 204
SimThreadCount = 5