Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: [1] 2 3 ... 7

Author Topic: [Late Game] Battles & Colony Management ruin FPS gradually & permanently.  (Read 17002 times)

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

Heya,

I am playing Starsector with a buttload of mods, larger fleets, and 7GB RAM assigned to the game. My savegame file is currently ~80MB in size.
  • Loading into the game, performance is fine.
  • Loading my save, everything is fine.
  • I can fly around, slip in and out of systems, and everything is fine.
And yet...
  • With every colony I touch, performance drops by a tiny margin, and does not recover.
This manifests in colony docking dialog loading longer and longer. Interactions with the options in the menu itself go smooth and quickly, but if I take a tour across my currently seven colonies, I am experiencing a delay upwards of two seconds after docking.
  • With every battle I fight, performance drops significantly and does not recover.
  • Battlesize is directly proportional to performance loss.
  • Not sending in my flagship and fighting battles from the tactical screen helps with performance in fights.
  • The subsequent performance loss is irrespective of whether I watched the battle from flagship, via video feed, or not at all.
Masochistic as I am, I tried to push this as far as I can, and with three HVB fights in sequence, I reduced my FPS (travel mode) to less than three, and colony dialogs take about five seconds to pop up. Another three seconds needed to get from colony menu to colony management. At this point, the associated RAM is maxed out, my CPU is barely concerned and effectively idle. The only way to return to a functional game is saving (takes upwards of five minutes), quitting the game, restarting, loading back in. I can currently play one or two battles, or do two rounds of colony management before the loss of performance becomes annoying. One more battle/five more markets, and I have to restart. This is the end of most of my playthroughs, after a couple of days.

My conclusion is some sort of clean-up not happening and/or some sort of memory leaking that seemingly isn't caught.

Is there anything I can do? Is there anything responsible I could monitor?
« Last Edit: August 02, 2020, 06:30:04 AM by Ced Riggs »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile

Hi - hmm. If you can share your mod list, I think that'd be helpful - this indeed sounds like some kind of leak or similar issue. Knowing which mods are involved could help narrow it down over time.

It's possible to connect to a running copy of the game and check it for leaks - and what's causing it - but its fairly involved. Depending on how comfortable you are with that sort of stuff, there are some instructions here:

http://fractalsoftworks.com/forum/index.php?topic=7690.msg128363#msg128363

Basically, best-case scenario is this would zero in on a specific Java class in a specific mod.
Logged

caekdaemon

  • Ensign
  • *
  • Posts: 24
    • View Profile

Is there anything I can do? Is there anything responsible I could monitor?
I've got this exact same issue: ton of mods, larger fleets, lots of RAM allocated to the game, but then serious drops in FPS after battles until getting into the next battle, where the game will run fine, then get even laggier after getting back to the stratmap. I tried to figure out what it was by a little testing here and there, and at first I thought it was just a problem when two big fleets duked it out with one another, but after a while I noticed that it seemed to have something to do with the afterbattle looting as it seemed to get worse when I had more varieties of item in the cargohold, but don't quote me on that.

Unfortunately, I can't load the save now - Tahlan Shipworks has had an update which doesn't seem to be backwards compatible with that save, so it's KIA, so I can't load it up to rummage around. My current new save seems to have the issue as well, but since I'm flying a smaller fleet the problem doesn't seem to be anywhere near as bad until it builds up over a few hours of play. 
Logged

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

If you can share your mod list, I think that'd be helpful - this indeed sounds like some kind of leak or similar issue. Knowing which mods are involved could help narrow it down over time.
Every mod that works with the current game version and doesn't overlap. I am currently running about 90 mods.

Depending on how comfortable you are with that sort of stuff, there are some instructions here:
http://fractalsoftworks.com/forum/index.php?topic=7690.msg128363#msg128363
Basically, best-case scenario is this would zero in on a specific Java class in a specific mod.
Comfortable enough! Will do that extensively tomorrow and report back.

I noticed that it seemed to have something to do with the afterbattle looting as it seemed to get worse when I had more varieties of item in the cargohold, but don't quote me on that.
Quoted you on that on principle, and, that is a valid pointer. I will look out for that.
Logged

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

Update: To get jvisualvm, I went and grabbed the current JDK; Java 14.0.2 from Oracle.

That did not get me jvisualvm, as this has been removed in 2016, and @Alex post is from 2014. So I went an grabbed VisualVM (same guys, just, no longer associated with Oracle), clipped Starfarer to the VM, and went out to cause mayhem to find my leak in the wild. I fought endless battles, traveled across the universe, flipped markets and caused wars. Two hours later, I could still play fine, and never got to the point where I felt like, yupp, that's the ticket, time to heap dump. Some crazy battles had so many fighters that my rig started chugging, but as soon as the fight was over or enough carrier died, we were back to almost 100% performance. I did notice a very minor stuttering every ~3s that barely registered, like a loss of one or two frames every so often, but that was it.

Will monitor and see if I get this again tomorrow, so I can search for the leak.

Tentative first thought: Maybe JDK 14.0.2x64 fixed an issue JRE 1.8.0_131x86 was having? Will investigate further when it's not half an hour past midnight.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile

Were you actually running the game using Java 1.8? You'd have to replace the jre/ folder that comes with the game, and edit the settings.json file to do that and disregard some fairly dire warnings about it causing instability and so on.

The version of Java you have installed on your system shouldn't matter, though, since the game will run using the jre it's bundled with regardless.
Logged

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

... then it's not that, and I am back to square one of not knowing what the heckie. Thanks for pointing that out. I'll monitor performance, and if I have something, I now know what to look for via VisualVM - thanks Alex!

PS: You might wanna update that post with the links to VisualVM, the usage is analog enough that I could replicate all steps you mentioned in that program.
Logged

Nick XR

  • Admiral
  • *****
  • Posts: 712
    • View Profile

You can also use the ConsoleCommands to take a heap dump, if you do that and put the dump in a public place I can take a look at it too.  I'm having similar issues so another data point is interesting to me.

(also once you have a dump you can use EclipseMAT too, or Visual VM)

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

You can also use the ConsoleCommands to take a heap dump, if you do that and put the dump in a public place I can take a look at it too.  I'm having similar issues so another data point is interesting to me.

(also once you have a dump you can use EclipseMAT too, or Visual VM)

Once I can reproduce the behavior, I'll do both - an analysis like Alex described, and a dump for you to look at. I'll start a new playthrough and will keep an eye on it. That'll take some time (work, learning how to sprite, things), but I'll keep you posted here.

PS: Never had a GC issue, only degrading performance. Was always able to save, even in 3FPS scenarios.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile

PS: You might wanna update that post with the links to VisualVM, the usage is analog enough that I could replicate all steps you mentioned in that program.

Good call, thanks! Did that.

PS: Never had a GC issue, only degrading performance. Was always able to save, even in 3FPS scenarios.

Interesting. It taking that long - you mentioned five minutes! - still seems to indicate that there's something going on to slow it down, though. It's possible that the leak just isn't quite big enough to make it crash while saving but just big enough to make it slow, but, yeah, that'd be a fine line for it to walk. The really low campaign framerate seems to be almost be more indicative of some kind of cumulative problem with, say, the same script getting repeatedly added to the game or something that just over time adds up and massively slows it down.

Semi-related note: how big are your savefiles? The size of the campaign.xml, specifically.
Logged

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

Interesting. It taking that long - you mentioned five minutes! - still seems to indicate that there's something going on to slow it down, though. It's possible that the leak just isn't quite big enough to make it crash while saving but just big enough to make it slow, but, yeah, that'd be a fine line for it to walk. The really low campaign framerate seems to be almost be more indicative of some kind of cumulative problem with, say, the same script getting repeatedly added to the game or something that just over time adds up and massively slows it down.

Semi-related note: how big are your savefiles? The size of the campaign.xml, specifically.
My lategame saves are well above 70MB, with my current one being roughly 82MB and climbing. I haven't had the time to start a new game yet to hunt for "that" behavior again, but there's a weekend approaching.

As for the fine line: I deliberately tried to keep going to see if I could eventually reach a GC crash. Yet even when the game slowed down to a crawl, no crash occurred. Additionally, since these performance drops were not in a smooth curve but more like falling down a flight of stairs, I usually had one big fight, maybe two if I felt masochistic, then I saved and restarted the game, plus clearing out my RAM standby list. Repeat this process in 2h to 3h intervals, depending on what I was doing - exploration without fights usually went well enough. But it never crashed on me, no matter how bad I let it get.

As these problems became a steady and constant issue, I made a save I declared my "last", and set sail for crash country. And yet, I never found the shores. The worst I found was the aforementioned ~3FPS and the ~5 minute saving of a game (time measured by the highly academic method of clicking Save & Exit, then getting water, going for a smoke, and coming back to watch the tail end of the bar fill up. The margin of error is 2 minutes). Then I posted here, set up VisualVM as instructed, and was ready to bug hunt like a pro. I picked a war with every neighbor I head, smashed into three IBBs, two HVBs, made Sylphon RnD homeless (Sorry, Nia. ;_;) and finally rolled into a High Danger Bladebreaker system, killing off battlegroups three at a time with a 300 DP battlesize - and Bladebreakers don't retreat.

The battles slowed down and stuttered over fighter spam and particle hooray. But as soon as the battles were over and the loot looted, the game returned to an almost normal state. It was slightly impacted, but nothing that'd make me consider the Restart Dance. It kept on chugging. I have nothing in my hands but questions.

The only thing I did between my first post in this thread and my VisualVM setup was installing JDK 14.0.3 - same mods, same vmparams RAM settings, same save file.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23989
    • View Profile

Thank you for elaborating. Not much to add on my end, aside from this being odd. I almost feel like it's a combination of multiple issues. At a guess, some of them clearing up after installing JDK 14 is probably a coincidence. (You didn't happen to reboot or something around the same time? Depending on how often you reboot, that might've factored in...)
Logged

caekdaemon

  • Ensign
  • *
  • Posts: 24
    • View Profile

Been continuing on that new save I mentioned earlier in the thread and it has just started to get the slowdowns, too. I haven't done anything with the JDK or anything like that, so I can't comment on that, but just like Ced, the game gets increasingly laggy after battles and takes longer and longer to save. The only difference to me seems to be that I get my problems from fleets and fleet battles, whereas they get it from colonies like they mentioned back in the OP.

And oddly enough, it doesn't seem like a memory leak, either: I checked the console from the mod, and it says the game is only using 3.3GB out of the 6.9 I've gave it, so that doesn't seem like it'd be the problem...except a hunch had me try something and check on Task Manager, which helpfully says that the game is actually using 5.6GB instead. I don't know if that kind of discrepancy has something to do with this or not, but it might be something that helps as it'd put a smile on my face if I didn't have to restart the game after every hour or so :P
Logged

Ced Riggs

  • Ensign
  • *
  • Posts: 43
    • View Profile

You could still try that VisualVM monitoring that Alex mentioned, see if you have a leak or nah. Considering that Starsector was first released (in Beta) in 2011, it is entirely possible that our contemporary rigs can keep going with a leaked campaign engine. I could imagine that current gen rigs simply shoulder that and keep going, but Alex might be able to shed light on that. I am just making *** up at this point.

In my new, tiny playthrough, no adverse performance has become apparent yet. I'll keep an eye it, though.
Logged

Nick XR

  • Admiral
  • *****
  • Posts: 712
    • View Profile

I too (as well as a bunch of people on Discord) have seen this post battle slowdown.  It's usually after a large battle, but not always.  From looking at stack traces during the slowdown I *think* it's something in the economy getting stuck in an event driven loop.  Something like:
X Happens, triggers Y Update
Y Update happens, triggers X

Maybe not that simple, but it seems to be a pure CPU issue.  I could be entirely wrong about this, but when I looked at the stacks, the only thing that seemed to be happening consistently was an econ update, but maybe that's always happening enough that I'm totally wrong.  But what I am pretty sure about is it was a CPU bound issue, not a memory issue.
Pages: [1] 2 3 ... 7