turns change slower and slower as the game progresses

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report on GitHub. For problems building from source, post in Compile.

Moderator: Oberlus

Message
Author
Ghoster
Space Krill
Posts: 6
Joined: Tue Aug 04, 2015 12:11 pm

turns change slower and slower as the game progresses

#1 Post by Ghoster »

Hi,

I have the same problem with the game, regardless of version: right now I'm testing build 0.45 (2015-08-03.af01c2f) - as the game progresses, the turns tend to change slower and slower
over time, just like the game needed more and more time to calculate data between each turns.

I can provide any log that you need, but please tell me what to do.

Thank you for making this unique game!

oh, I'm running Windows 8.1 64bit, and pretty powerful laptop (will give all specs if needed).

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: turns change slower and slower as the game progresses

#2 Post by Vezzra »

Ghoster wrote:the turns tend to change slower and slower
over time, just like the game needed more and more time to calculate data between each turns.
That's exactly what's happening, and there isn't much you can do about it, except playing on smaller maps, against fewer opponents, lower planet density. What are the typical setup options you're playing with (map size, number of AI, etc.)?

Ghoster
Space Krill
Posts: 6
Joined: Tue Aug 04, 2015 12:11 pm

Re: turns change slower and slower as the game progresses

#3 Post by Ghoster »

Vezzra wrote:
Ghoster wrote:the turns tend to change slower and slower
over time, just like the game needed more and more time to calculate data between each turns.
That's exactly what's happening, and there isn't much you can do about it, except playing on smaller maps, against fewer opponents, lower planet density. What are the typical setup options you're playing with (map size, number of AI, etc.)?
Currently I'm playing on 200 systems, medium starlane frequency and medium planet density, AI = 5.

What settings do you recommend?

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: turns change slower and slower as the game progresses

#4 Post by MatGB »

Ghoster wrote:
Vezzra wrote:
Ghoster wrote:the turns tend to change slower and slower
over time, just like the game needed more and more time to calculate data between each turns.
That's exactly what's happening, and there isn't much you can do about it, except playing on smaller maps, against fewer opponents, lower planet density. What are the typical setup options you're playing with (map size, number of AI, etc.)?
Currently I'm playing on 200 systems, medium starlane frequency and medium planet density, AI = 5.

What settings do you recommend?
If your laptop is that good, it shouldn't be causing a huge amount of lag on those setting, I could play games through with that relatively easily on my much older laptop, and we've had a number of improvements to processing over time.

Basically, every turn, and whenever you queue something in the production panel, the game has to check through various effects to work out what's going on and update your display, we're aware that there are issues on production screen regarding updating the map and similar. If there are too many things to process, this can take longer than is ideal so you get lag.

First thing I always found useful, reduce the total number of ships you have flying by scrapping old obsolete designs, you benefit from reduced upkeep costs and thus new ships are cheaper and it seemed to speed the game up for me.

I also prefer to play on Low planets as each population centre you own requires processing time and I like bigger maps, that would help a bit but a 200 system map shouldn't be causing excessive problems for a decent machine.

The other thing of course is how much slower, what is to one player an acceptable waiting time is to others an interminable wait, maybe I'm just more patient? It's bound to slow down as the game gets bigger, not much can be done to stop it completely, especially given one of the project goals is to make all the content easily customisable which requires referring to source data and similar, are we talkiing minutes, seconds or just noticeably slower but not in an annoying way?

Also, although it doesn't seem to affect it dramatically, turning off gas field rendering and possibly starfield rendering in the galaxy graphics options can produce improvements for some.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Ghoster
Space Krill
Posts: 6
Joined: Tue Aug 04, 2015 12:11 pm

Re: turns change slower and slower as the game progresses

#5 Post by Ghoster »

MatGB wrote: If your laptop is that good, it shouldn't be causing a huge amount of lag on those setting, I could play games through with that relatively easily on my much older laptop, and we've had a number of improvements to processing over time.
Well, you be the judge:
Intel(R) Core(TM) i7-4700HQ CPU @ 2.40GHz
16 GB RAM
GeForce GTX860M

and the lag becomes huge in my oppinion.
MatGB wrote: Basically, every turn, and whenever you queue something in the production panel, the game has to check through various effects to work out what's going on and update your display, we're aware that there are issues on production screen regarding updating the map and similar. If there are too many things to process, this can take longer than is ideal so you get lag.

First thing I always found useful, reduce the total number of ships you have flying by scrapping old obsolete designs, you benefit from reduced upkeep costs and thus new ships are cheaper and it seemed to speed the game up for me.

I also prefer to play on Low planets as each population centre you own requires processing time and I like bigger maps, that would help a bit but a 200 system map shouldn't be causing excessive problems for a decent machine.
Ok.
MatGB wrote: The other thing of course is how much slower, what is to one player an acceptable waiting time is to others an interminable wait, maybe I'm just more patient? It's bound to slow down as the game gets bigger, not much can be done to stop it completely, especially given one of the project goals is to make all the content easily customisable which requires referring to source data and similar, are we talkiing minutes, seconds or just noticeably slower but not in an annoying way?
It is utterly annoying and it progresses as the game goes on. It's bearable after 100 turns and becomes 20-25 seconds after 400 turns. Is it as the game had more and more data to process as the game progresses. The laptop starts to constantly cool itself on higher fan rotation mode. :D Even the sound starts to stutter on end of every turn cycle (when next turn is about to become active). It happens just the same way, no matter whether I use built-in graphic processor or the GTX860M.
MatGB wrote: Also, although it doesn't seem to affect it dramatically, turning off gas field rendering and possibly starfield rendering in the galaxy graphics options can produce improvements for some.

pheldens
Pupating Mass
Posts: 96
Joined: Fri Mar 15, 2013 12:54 pm

Re: turns change slower and slower as the game progresses

#6 Post by pheldens »

on a quadcore 3.5 ghz SSD it takes several (5) seconds between turns on a default 150 system game and the fan spins up , at turn 300 or so

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: turns change slower and slower as the game progresses

#7 Post by Dilvish »

Ghoster wrote:Well, you be the judge:
Intel(R) Core(TM) i7-4700HQ CPU @ 2.40GHz
16 GB RAM
GeForce GTX860M
That is certainly fine in general. My desktop stats are pretty similar, though I guess they had to keep your processor speed down to minimize heat. Mine is an i7-4770K @3.5 GHz, and I commonly play 300-500 systems with 10-20 AIs. If the per turn delay was 20 seconds at turn 400 though I probably wouldn't really think twice about that.

This thread got me a bit curious for details, so I made a testgame with 200 systems, most things on medium except no monsters, 6 empires (AI, my empire did nothing but observe) , and plotted the times to turn 300-- it really ramps up towards the end. Keep in mind this is AI -only, and the lead was up to 2k PP per turn at the end, well ahead of the others and probably was still just cranking out a ton of ships.
times.png
times.png (25.97 KiB) Viewed 5093 times
The basic problem is that there gets to be just so many objects interacting. I think we had gotten rid of all processing behavior that led to N-cubed processing times, but maybe it was just n^4, and there are surely still at least some N^2 logN behavior, and then also ships are being created at a faster rate as well (killed at a faster rate, too, but I think the creation rate rises faster).

Anyways, it was surprising to me to see just how steep it the curve got there, perhaps sometime someone could follow up on it more to see which effects are making the most trouble, etc.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: turns change slower and slower as the game progresses

#8 Post by Vezzra »

Dilvish wrote:The basic problem is that there gets to be just so many objects interacting. I think we had gotten rid of all processing behavior that led to N-cubed processing times, but maybe it was just n^4, and there are surely still at least some N^2 logN behavior
I think the basic problem here is the way our scriptable effects framework has been designed. To provide maximum flexibility, basically each object can influence/interact with each other object. So, the algorithm has to walk through each effectsgroup of each universe object, tech, special etc., and each of them can potentially affect each universe object.

Now, my math skills are quite humble, but AFAIK this means there is absolutely no way to get below n^2 behavior. Which consequently leads to curves like the one above, I don't see a way to avoid that (other than to completely redesign the entire effects mechanism, which does not sound particularly appealing... ;)).

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: turns change slower and slower as the game progresses

#9 Post by Geoff the Medio »

Vezzra wrote:To provide maximum flexibility, basically each object can influence/interact with each other object. So, the algorithm has to walk through each effectsgroup of each universe object, tech, special etc., and each of them can potentially affect each universe object.
Not necessarily; some effects only act on the source object with a relatively simple modification, and in that case the time to execute should be nearly constant per effect / source object, so roughly linear in the number of objects producing those effects, or maybe nlogn if there are some lookups in ObjectMaps involved in the preprocessing. There will still be other cases with higher order dependence on numbers of objects, though.

Morlic
AI Contributor
Posts: 296
Joined: Tue Feb 17, 2015 11:54 am

Re: turns change slower and slower as the game progresses

#10 Post by Morlic »

Vezzra wrote: So, the algorithm has to walk through each effectsgroup of each universe object, tech, special etc., and each of them can potentially affect each universe object.

Now, my math skills are quite humble, but AFAIK this means there is absolutely no way to get below n^2 behavior.
I think your math skills are good enough to have heard about the distributive property.

Code: Select all

1*1 + 1*2 + 1*3 + ... + n*1 + n*2 + ... + n*n = (1+... + n) * (1 + ... + n)
So while each of the objects interacts which each other, I can do n^2 operations in 2n+1 operations instead.

Generally, you have some complexity O(g*n) where g is the number of "groups" of operations you perform which may be smaller than O(n) (e.g. O(1) as in the example above).

Now in FO, g = O(n) so the asymptotic behaviour wouldn't change. I do not feel qualified enough to discuss whether this would still provide measurable performance boost (or is even compatible with current implementation) to e.g. cache all effects that affect all planets/ships of an empire/species ...
Last edited by Morlic on Wed Aug 05, 2015 11:28 am, edited 1 time in total.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

Ghoster
Space Krill
Posts: 6
Joined: Tue Aug 04, 2015 12:11 pm

Re: turns change slower and slower as the game progresses

#11 Post by Ghoster »

Oh my goodness, I knew that people working on such game are brainy...but still...wow...

Anyways, if would you find mathematical solution to make the code more efficient, that would be freakin' revolutionary for this game.

I don't think AI's are the problem. If I eliminate 1 of 3 from the game, the "processor eating" proccess still goes on and on.

I'm on turn 450 and waiting time for next turn varies from 5-6 seconds to 106 seconds (counted!). Craziness. ;)

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: turns change slower and slower as the game progresses

#12 Post by Geoff the Medio »

Ghoster wrote:Anyways, if would find mathematical solution to make the code more efficient, that would be freakin' revolutionary for this game.
You might not appreciate the current state of the code, but compared to how long the effects calculations used to take, there have already been quite dramatic improvements / optimizations.

One thing you could do is start up FreeOrion, go into the options UI tab, and turn on verbose logging. Then load a saved game that currently take a long time (by your standards) to process a turn, and end turn. Then quit, and find the .log files, zip them up and attach to a forum post. They might be quite large, so preferably delete them all before starting, make sure to start the game anew, and play just one turn. It will probably take extra long to process the turn, but the log files should have some potentially useful timing info in them. Saving the game in XML format and attempting to post might also be helpful, though the file might be too big for the forum to allow it to be attached.

User avatar
Vezzra
Release Manager, Design
Posts: 6095
Joined: Wed Nov 16, 2011 12:56 pm
Location: Sol III

Re: turns change slower and slower as the game progresses

#13 Post by Vezzra »

Ghoster wrote:Oh my goodness, I knew that people working on such game are brainy...but still...wow...
I can understand you well. When I try to follow some discussions here, I often feel like Sam in this strip: http://freefall.purrsia.com/ff300/fv00215.htm. "It's really simple" - "Yeah, right."

You have seen nothing yet, though. Take a look at some of the discussions of our AI folks for example. Oh my...
I'm on turn 450 and waiting time for next turn varies from 5-6 seconds to 106 seconds (counted!). Craziness. ;)
Hm. That's odd. Usually turn execution times don't vary that much.

pheldens
Pupating Mass
Posts: 96
Joined: Fri Mar 15, 2013 12:54 pm

Re: turns change slower and slower as the game progresses

#14 Post by pheldens »

the amount of systems could also be brought down to 100

I find 150 to be on the high side already to manage manually (gets boring and tedious in the endstages), but then again, space is vast so.

more threading of the turn calculations may be possible.

Ghoster
Space Krill
Posts: 6
Joined: Tue Aug 04, 2015 12:11 pm

Re: turns change slower and slower as the game progresses

#15 Post by Ghoster »

Geoff the Medio wrote:
Ghoster wrote:Anyways, if would find mathematical solution to make the code more efficient, that would be freakin' revolutionary for this game.
You might not appreciate the current state of the code, but compared to how long the effects calculations used to take, there have already been quite dramatic improvements / optimizations.

One thing you could do is start up FreeOrion, go into the options UI tab, and turn on verbose logging. Then load a saved game that currently take a long time (by your standards) to process a turn, and end turn. Then quit, and find the .log files, zip them up and attach to a forum post. They might be quite large, so preferably delete them all before starting, make sure to start the game anew, and play just one turn. It will probably take extra long to process the turn, but the log files should have some potentially useful timing info in them. Saving the game in XML format and attempting to post might also be helpful, though the file might be too big for the forum to allow it to be attached.
Thank you very much, I'll be sure to do it. Always glad to make an even small contribution. I appreciate the work done, don't get me wrong. But it's just still not close to the state to provide a prolonged, comfortable gameplay. But I still play though :D

Post Reply