Okay, I started a game 8 comps random AI vs each other. I will post some random statistics here, mainly so I can remember them but also because they might be interesting for others.
r6048, sound disabled, OpenGL renderer, 1680x1050 resolution. I had census and statistics disabled (I noticed some i18n functions having a non zero impact on performance. As I do not except this to be the main culprit, i decided to skip those functions in my analysis for now). Optimized build with debug symbols: -O3 -g -DDEBUG
On game start, speed x 10, Memory footprint is ~900MB, 80% of one CPU is taken. The cmdqueue has ~40.000 entries and keeping it a heep makes ~12% of all CPU time.
After ~5 game hours, speed x 7, Memory Footprint is ~800 MB, 84% of one CPU is taken, The cmdqueue has ~73.000 entries and the CPU bottlenecks are with ~10% still the heap adjusting, follwed by the replay_writing (Game::SyncWrapper and RealFsStreamWrite::Data) which comes likely from autosaving. I also noticed that showing the minimap has a very heavy impact on performance.
The game runs into a kind of equilibrium now: the computers are so surrounded by trees that the hardly make any progress.
After ~19 game hours, speed x 7, Memory Footprint is ~900 MB, ~85% of one CPU is taken, the cmdqueue has ~78.800 entries and the CPU bottlenecks is still the heap adjusting, closely followed by a new contender IdleWareSupply::nr_supplies which is to be expected as there are many roads where items are just laying around. The game is pretty much ended: only the pink player is still making some progress, all others gave up on the trees.
Summary: my last few optimizations did improve the situation considerably. My 2.2GHz Box with 4Gigs RAM has no problem simulation at x7, but the edges are showing: x 10 is not possible.
The cmdqueue needs some rethinking. the heap is just not cutting it and I think about replacing it via a hash_map of queue containers. I will try that out.
Also, Economy::find_best_supply needs work: currently it checks every supply (warehouses and idle wares floating around) for every request periodically and tries to find the best. It could be improved by only looking closer to the request for a better supply or by using a heurisitc and settling for a pretty good supply.
Also, the statistics menu is a bottleneck in long games. Obviously the whole statistic data is recalculated for each frame which becomes a lot when the game runs > a few hours. This should be a new bug report.
The same for the minimap: It gets redrawn to often. It should maybe only complety redraw itself every few seconds or always one line at each frame (i remember that S2 did it that way. This gives a cool effect when some area is conquered).
This also should be a new bug report.
Okay, I started a game 8 comps random AI vs each other. I will post some random statistics here, mainly so I can remember them but also because they might be interesting for others.
r6048, sound disabled, OpenGL renderer, 1680x1050 resolution. I had census and statistics disabled (I noticed some i18n functions having a non zero impact on performance. As I do not except this to be the main culprit, i decided to skip those functions in my analysis for now). Optimized build with debug symbols: -O3 -g -DDEBUG
On game start, speed x 10, Memory footprint is ~900MB, 80% of one CPU is taken. The cmdqueue has ~40.000 entries and keeping it a heep makes ~12% of all CPU time.
After ~5 game hours, speed x 7, Memory Footprint is ~800 MB, 84% of one CPU is taken, The cmdqueue has ~73.000 entries and the CPU bottlenecks are with ~10% still the heap adjusting, follwed by the replay_writing (Game::SyncWrapper and RealFsStreamWri te::Data) which comes likely from autosaving. I also noticed that showing the minimap has a very heavy impact on performance.
The game runs into a kind of equilibrium now: the computers are so surrounded by trees that the hardly make any progress.
After ~19 game hours, speed x 7, Memory Footprint is ~900 MB, ~85% of one CPU is taken, the cmdqueue has ~78.800 entries and the CPU bottlenecks is still the heap adjusting, closely followed by a new contender IdleWareSupply: :nr_supplies which is to be expected as there are many roads where items are just laying around. The game is pretty much ended: only the pink player is still making some progress, all others gave up on the trees.
Summary: my last few optimizations did improve the situation considerably. My 2.2GHz Box with 4Gigs RAM has no problem simulation at x7, but the edges are showing: x 10 is not possible.
The cmdqueue needs some rethinking. the heap is just not cutting it and I think about replacing it via a hash_map of queue containers. I will try that out. :find_best_ supply needs work: currently it checks every supply (warehouses and idle wares floating around) for every request periodically and tries to find the best. It could be improved by only looking closer to the request for a better supply or by using a heurisitc and settling for a pretty good supply.
Also, Economy:
Also, the statistics menu is a bottleneck in long games. Obviously the whole statistic data is recalculated for each frame which becomes a lot when the game runs > a few hours. This should be a new bug report.
The same for the minimap: It gets redrawn to often. It should maybe only complety redraw itself every few seconds or always one line at each frame (i remember that S2 did it that way. This gives a cool effect when some area is conquered).
This also should be a new bug report.
Next, I'll try to save and load the game.