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
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

#16 Post by MatGB »

I have a completely different solution to the lag problem that creeps in after turn 250ish:

Try to always win by then ;-)

And yeah, whenever discussions get into higher end maths or more complex coding I tend to switch out and go find some basic addition style stuff that my elderly brain can still grok.
Mat Bowles

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

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

#17 Post by Dilvish »

Vezzra wrote:Now, my math skills are quite humble, but AFAIK this means there is absolutely no way to get below n^2 behavior.
It means that the theoretical worst behavior is necessarily like that over some kind of time range, but it doesn't necessarily mean that our typical behavior necessarily has to be like with within the span of 500-1000 turns or something.

One of the big changes from a year or two ago was to make Conditions start out with appropriate smaller sets of objects to scan (like if we have a "System" Condition, instead of scanning all objects to see which objects are systems, we start off with a pre-processed set of Systems). I believe there are still a few more techniques that could be applied to bring some n^2 operations down to n log n (or N^3 down to n^2 log n), but I don't think those are actually our biggest issue.

I think the biggest issue has to do with cascading waves of ObjectChangedSignals in the MapWnd. Notice that the delay when you change the Focus on just a single planet in the SidePanel is very similar to the entire delay for changing the Focus on a whole set of planets via right-click in the ObjectsList Window. I rather suspect it is similar cascades of update signals, slowing down the MapWnd, that makes for our worst offender. But that's just a suspicion, I haven't chased it enough to really be sure about that.
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
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: turns change slower and slower as the game progresses

#18 Post by MatGB »

Dilvish wrote:I think the biggest issue has to do with cascading waves of ObjectChangedSignals in the MapWnd. Notice that the delay when you change the Focus on just a single planet in the SidePanel is very similar to the entire delay for changing the Focus on a whole set of planets via right-click in the ObjectsList Window. I rather suspect it is similar cascades of update signals, slowing down the MapWnd, that makes for our worst offender. But that's just a suspicion, I haven't chased it enough to really be sure about that.
It is massively quicker to change the focus of 10+ systems via objects menu than it is to change one via sidepanel as long as none of the systems you're changing are displayed in the sidepanel. Other planets displayed is fine, as long as none of them are mass changed.

This makes zero sense to me but it's the way it is.
Mat Bowles

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

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

#19 Post by Geoff the Medio »

Dilvish wrote:I think the biggest issue has to do with cascading waves of ObjectChangedSignals in the MapWnd.
That may be a big issue, but it doesn't have much to do with turn processing times.

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

#20 Post by Vezzra »

Dilvish wrote:I think the biggest issue has to do with cascading waves of ObjectChangedSignals in the MapWnd.
Regarding the increasing sluggishness of the UI in the later stages of the game, you're right of course. But we've been talking about the increasing turn processing time, haven't we?

Although the UI sluggishness is most certainly the bigger issue, no question.

EDIT: Oh, Geoff beat me to it.

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

#21 Post by Dilvish »

Geoff the Medio wrote:That may be a big issue, but it doesn't have much to do with turn processing times.
If whatever it is you're referring to by 'turn processing time' excludes updating the MapWnd, then it seems to me to be a not so useful metric for user experience of lag.

I don't have time to chase down details right at the moment, but later today hopefully I can come up with some time to make some more specific charts, two of them focused on the amount of time the server takes for making its two updates each turn, and corresponding ones for the human client processing those updates. I suppose ideally I can show them all in a single chart together with total elapsed turn-to-turn time.
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

#22 Post by Vezzra »

Dilvish wrote:If whatever it is you're referring to by 'turn processing time' excludes updating the MapWnd, then it seems to me to be a not so useful metric for user experience of lag.
Oh, you suspect the updating of the map window to be the main culprit for the long turn processing times? I've to admit, I never thought of that...

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

Re: turns change slower and slower as the game progresses

#23 Post by Morlic »

To follow up on that: Having a system selected and thus the side panel opened increases the time between turns significantly for me. So that the UI has a significant influence seems plausible to me.
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
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: turns change slower and slower as the game progresses

#24 Post by MatGB »

Morlic wrote:To follow up on that: Having a system selected and thus the side panel opened increases the time between turns significantly for me. So that the UI has a significant influence seems plausible to me.
It had never occured to me to test this, but agreed, getting from turn 195 to 196 with no fleet or sidepanel open was noticeably faster for me than getting from turn 196 to 197 with both a fleetwnd and the sidepanel open, and the sidepanel noticeably, um, shuddered(? not sure of best term) at each update, and not just because it was a shared system and one of my troop ships turned up.
Mat Bowles

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

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

#25 Post by Geoff the Medio »

Probably a call to disable object signals could be inserted before turn-update-meter-calculations on the client, which might eliminate some of this effect...

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

Re: turns change slower and slower as the game progresses

#26 Post by Ghoster »

Vezzra wrote:
Dilvish wrote:I think the biggest issue has to do with cascading waves of ObjectChangedSignals in the MapWnd.
Regarding the increasing sluggishness of the UI in the later stages of the game, you're right of course. But we've been talking about the increasing turn processing time, haven't we?

Although the UI sluggishness is most certainly the bigger issue, no question.

EDIT: Oh, Geoff beat me to it.
From my simple man gaming experience - I was playing today and end up with two AIs (one being previously killed): turn change rate was very sluggish, reaching even 100+ seconds, BUT when I killed enemy fleet consisting of 150 ships, the game just "unblocked" - and turns changed reliably much, much faster to a normal level - up to 5 seconds, even less. This enemy fleet was very stationary - it just stood mostly on one system (I'm lame, so was playing against turtles). The other AI had around 120 ships, and I was close to 100.

So I guess in my case, a lot of processing is strongly connected with overall number of ships, and not so much with other aspects.

I will make another game maybe tommorow and will gather data according to given instructions.

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

#27 Post by Geoff the Medio »

See if something like this affects the sidepanel-open turn delay effect:

Code: Select all

diff --git "a/C:\\Users\\Geoff\\AppData\\Local\\Temp\\TortoiseGit\\Map7FFC.tmp\\MapWnd-270f542-left.cpp" "b/C:\\Users\\Geoff\\Desktop\\FreeOrion_VS2013_SDK\\FreeOrion\\UI\\MapWnd.cpp"
index bcda01d..43efc84 100644
--- "a/C:\\Users\\Geoff\\AppData\\Local\\Temp\\TortoiseGit\\Map7FFC.tmp\\MapWnd-270f542-left.cpp"
+++ "b/C:\\Users\\Geoff\\Desktop\\FreeOrion_VS2013_SDK\\FreeOrion\\UI\\MapWnd.cpp"
@@ -2285,6 +2285,8 @@ void MapWnd::InitTurn() {
     // FIXME: this is actually only needed when there was no mid-turn update
     universe.InitializeSystemGraph(HumanClientApp::GetApp()->EmpireID());
 
+    universe.InhibitUniverseObjectSignals(true);
+
     // update effect accounting and meter estimates
     universe.InitMeterEstimatesAndDiscrepancies();
 
@@ -2299,6 +2301,8 @@ void MapWnd::InitTurn() {
 
     GetUniverse().ApplyAppearanceEffects();
 
+    universe.InhibitUniverseObjectSignals(false);
+
     // set up system icons, starlanes, galaxy gas rendering
     InitTurnRendering();
 

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

#28 Post by Geoff the Medio »

Geoff the Medio wrote:See if something like this affects the sidepanel-open turn delay effect:

Code: Select all

diff --git "a/C:\\Users\\Geoff\\AppData\\Local\\Temp\\TortoiseGit\\Map7FFC.tmp\\MapWnd-270f542-left.cpp" "b/C:\\Users\\Geoff\\Desktop\\FreeOrion_VS2013_SDK\\FreeOrion\\UI\\MapWnd.cpp"
index bcda01d..43efc84 100644
--- "a/C:\\Users\\Geoff\\AppData\\Local\\Temp\\TortoiseGit\\Map7FFC.tmp\\MapWnd-270f542-left.cpp"
+++ "b/C:\\Users\\Geoff\\Desktop\\FreeOrion_VS2013_SDK\\FreeOrion\\UI\\MapWnd.cpp"
@@ -2285,6 +2285,8 @@ void MapWnd::InitTurn() {
     // FIXME: this is actually only needed when there was no mid-turn update
     universe.InitializeSystemGraph(HumanClientApp::GetApp()->EmpireID());
 
+    universe.InhibitUniverseObjectSignals(true);
+
     // update effect accounting and meter estimates
     universe.InitMeterEstimatesAndDiscrepancies();
 
@@ -2299,6 +2301,8 @@ void MapWnd::InitTurn() {
 
     GetUniverse().ApplyAppearanceEffects();
 
+    universe.InhibitUniverseObjectSignals(false);
+
     // set up system icons, starlanes, galaxy gas rendering
     InitTurnRendering();
 
Bump...

JoltMe
Space Krill
Posts: 3
Joined: Fri Apr 29, 2016 7:06 am

Re: turns change slower and slower as the game progresses

#29 Post by JoltMe »

I have been programming for about 30 years, named by UCLA as the best programmer on the planet. (Not like that matters much, and I only stated vague credentials for the purposes of my response). I have only developed a couple games, so please bare with me, and I am new at this game. I am running a 2.8ghz quad core with 8gb ram and after turn 400 (roughly), the turn rate tends to be 30-45 seconds with a single AI (I am just learning the game) and 200 star systems.

I have noticed that my CPU spikes but ram stays fairly constant. If I were to troubleshoot this scenario, I would say that what is currently in my viewfinder (screen, viewable part of the universe) should be the only portion of the program using much CPU and the non-viewable areas should be shelled out to ram. It may have a slight effect on movement around the map (which can be remedied, or improved) but would (I am quite sure) speed up the turn progress...?

Pelure d'Orion
Space Krill
Posts: 1
Joined: Sat Oct 24, 2015 9:32 am

Re: turns change slower and slower as the game progresses

#30 Post by Pelure d'Orion »

Hello everyone.

I always encounter a very long turn duration when advancing in the game.
Around turn 200-300, turn change takes 4 to 5 minutes when autosave is off, and one hour (yes, 60 minutes !) on AUTOSAVE turns.

Moreover, manual save is never allowed, because AIs always stays "green >" up to human player's end of turn.

My configuration is :
* Windows 7 Home 64-bits.
* Intel Core i7 Q720 @ 1.6 GHz, 4 Gb RAM, Windows performance Index = 5.9
* nVidia GeForce GT 330M
* FreeOrion_2016-05-10.2a6b7b4_Test_Win32

Having played Turtle or Aggressive AIs.

Post Reply