Dear programmers of Sins of a solar empire rebellion,
The overall game is wonderful, however, approaching later stage of the game when there are huge number of units of any kind (including all structures, trade ships, etc), the game becomes very slow. Typically, in a major battle involving 6~10 players, each having hundreds of ships (including carrier fighters and bombers) in one gravity well, the game is so slow and essentially unplayable. I have a lenovo Y470 computer with 2G video ram and 8G DDR3 ram, CPU is 2.0G 4-core with Hyper-threading, turbo boost to 2.66GHz, graphic card is Geforce 550M. I realize that even when the game is very very slow, it does NOT make use of multi-core CPU resources. Typically, it only uses 2 threads, one for drawing graphics, one for processing game logics.
I myself am a programmer, with some experience in optimization. From my point of view, the game engine can be optimized for parallel processing which makes use of all CPUs. The object list can be processed in parallel by making a duplicate copy which doubles memory used for storing all dynamic object data. So create 2 list buffers, one is home buffer, the other copy (target buffer) for updated objects. During update, the home copy is kept read-only and is accessible by all threads, updated information is stored on the target copy, and all update is based on information in the home copy only, and each update only write the data of updating object (a thread updating object 319 can read any objects in home buffer but it can only write to object 319 in target buffer). Updates of objects which will influence the state of other objects have to be put into a list which is to be processed after the parallel update is over.
To better address the multiple object influence issue, alternatively, you may consider constructing a directed graph, in which each object is a node. If A influences B, there is an arrow from A to B. When you update an object, you lock the object first, if an object is locked by some other thread, you process the next object first and come back to it later.
In such a way, there will be no conflict among all threads. And the entire game logic process can be parallelized, which can make better use of multi-core CPU. Thanks!
Cheers,
Xuancong
g0801784@nus.edu.sg