[Technical] What takes most time in processing turn?

raxo2222

Time Traveller
Joined
Jun 10, 2011
Messages
9,731
Location
Poland
For example while on beginning I had 5 sec turns in Gigantic map (mind that this onewas filled by like 3/4 with space terrain) single AI on start, by reneissance turns were 25 secs as there were around 30 cities.

Is there any way I could see what takes most time in turn processing?

Similiarly what is most memory demanding stuff in game?

I'm just curious here.
 
Last edited:
There is a way to profile a turn and find out what functions in the code are taking longest. Is that what you're asking to be instructed to be capable of doing?

Alberts2 has been working on optimization issues and he really is one of the best at this that I've ever seen so I think we should just let him go about what he's doing with as little disturbance to his goals as possible.
 
There is a way to profile a turn and find out what functions in the code are taking longest. Is that what you're asking to be instructed to be capable of doing?

Alberts2 has been working on optimization issues and he really is one of the best at this that I've ever seen so I think we should just let him go about what he's doing with as little disturbance to his goals as possible.
I don't want to interfere him, I just wanted to see what uses most processing/ram resources.
Basically if there is 5 second turn, then what happens in each second of turn?
I'm just generally curious why smaller maps have shorter turn times even on beginning of game.
I bet animal spawning and property flow causes longer turns on bigger maps even in early game.
AI thinking what unit/building should be created next scales with amount of cities and researched techs.
Would be suprised, if it was something else.
 
Last edited:
It all depends from one round to the next what takes more time. AI decision-making takes the vast majority of processing but to define that deeper depends on whether the AI needs to make civic or tech choices, how many building choices, etc... Probably unit movement decisions take the most time overall. Thus a map with a lot of units takes a longer time than a map with fewer units.

Relative to unit AI, animal spawning and property flow is almost entirely negligible.
 
It all depends from one round to the next what takes more time. AI decision-making takes the vast majority of processing but to define that deeper depends on whether the AI needs to make civic or tech choices, how many building choices, etc... Probably unit movement decisions take the most time overall. Thus a map with a lot of units takes a longer time than a map with fewer units.

Relative to unit AI, animal spawning and property flow is almost entirely negligible.
Does unit AI cover animals/barbarian units too? As in do barbarian/animal AI decide, to where move their units?

BTW freshly launched mod takes only 510 MB of memory :D
I have mem-saver enabled in stock civ4 config (alt-tabbing is possible, as I use windowed mode)

Started duel-sized map: 770 MB of memory. First 10 turns passed in 25 secs. No AIs though.
Exited to main menu, now 720 MB of memory is used.
I guess there is still room for optimizations for RAM usage.

Started gigantic map with 99% ocean: 910 MB memory usage. 35 secs for 10 turns. (Base is 720 MB here though)
Went to main menu, 820 MB of RAM used.

Gigantic map with barbarians, 15 AI, and mostly land (820 MB of base load):
1400 MB. Revealing entire map increased load only by 30 MB. 1m 40s passed.
I guess Gigantic and possibly Giant should have reduced AI defaults.
In fact Gigantic (and giant?) could be as well as removed.
Only 64bit+multithreading could save gigantic map with 15 AI.
 
Last edited:
Does unit AI cover animals/barbarian units too? As in do barbarian/animal AI decide, to where move their units?
Yes, but barbarian and animal AI coding is simpler.
 
I wonder how much more this mod could be optimized in general.
 
Alberts2 has been working on optimization issues and he really is one of the best at this that I've ever seen so I think we should just let him go about what he's doing with as little disturbance to his goals as possible.
Amen Brother! Let the man do his work!
 
My response was to T-brd's post. And what alberts2 is doing now is extremely important to this area of concern, whipper snapper youngster. :D I think I'm going to start calling you Curious Raxxo, Curious George's other brother. :lol::yup::pat:
 
Hey Grandpa I'm just looking how biggest mod of this fairly ancient game works internally :p :mischief:
I'm just generally curious ;)
This particular question is complex enough that you'd really have to be a coder to understand the full depth of the answer so trying to give a layman's answer is difficult. It's like trying to explain physics without math.

Suffice it to say, there is a lot that can still be done to optimize if you're skilled enough to do it and thank god we have an almost superhuman source of assistance at the moment! I've even decided to stay out of the DLL programming for a bit to give him some room to work. (I have a lot to do with XML right now anyhow.)
 
The problem could be the properties system; every time I end a turn or load a game, it tanks until i move may view to the tiles to "initialize" them. It also lags whenever i hover over a tile in this state as well.
 
New The problem could be the properties system; every time I end a turn or load a game, it tanks until i move may view to the tiles to "initialize" them. It also lags whenever i hover over a tile in this state as well.
This effect is due to Koshling's graphical paging modification which saved us a tremendous amount of playable game memory by forcing the map to only display what it sees and to refresh its rendering at intervals whenever you scroll to a new portion on the map. You'll detect obvious delays in these renderings and this was a huge benefit for us as a whole so that the game memory wasn't juggling so much information at once as it did in Vanilla.
The game has recheck the crime, disease, etc for every city and tile, regardless of type, which slows the game down.
It's not doing this as you scroll around the map but rather it IS between turns doing a lot of calculations for properties. Still, if you were to profile the turn times I don't think you'll find it to be a BIG contributor to speed. Alberts2 has said it's not the most efficient system, but I doubt it compares to the unit AI determination sequences.
 
It's not doing this as you scroll around the map but rather it IS between turns doing a lot of calculations for properties. Still, if you were to profile the turn times I don't think you'll find it to be a BIG contributor to speed. Alberts2 has said it's not the most efficient system, but I doubt it compares to the unit AI determination sequences.
Is what alberts2 found and pointed out helping you understand that section better now?
 
Is what alberts2 found and pointed out helping you understand that section better now?
What section? Are you talking about his using Visual Studio 2017? That's certainly very interesting and I'd like to get it. I haven't had time to get the program yet. I'm deeply intimidated by trying to setup a new way of going about things but hopefully it'll work out and I'll be able to use some if its benefits.

As for profiling, it's something I can do according to some older instructions that may not be as accurate as how he's going about it now. But it's something I rarely do because it's a very laborious process and he's likely a lot better than I am at making full use of what he learns from it, aka zeroing in on the exact ways to make things more efficient where they need to be.

As for the memory solution he created recently, that was a fix on Koshling's setup and yes, I can and will be using his advancement in procedure where I need to replicate the method.
 
That's a unit AI that's caught in an infinite loop. I've not tried to solve that particular problem yet but it's not an uncommon one that I've solved numerous times before in other areas. I have means to resolve it but I haven't been working on the code recently. There's still probably quite a few of these yet. I often find one in a save that had nothing to do with reporting such a problem and resolve it along the way as a matter of course.

I've got that and that crash reported recently to resolve in the bugs thread still.
 
Top Bottom