Jump to content

Massive frame rate issues, getting worse as save goes on


Recommended Posts

Ok, so I've been having some issues of late, and I'm really at a loss as to where to look. I have a fairly heavily modded (~100 mods) install, and initially the performance wasn't perfect, but it was definitely manageable. It seems though that the further my career save goes, the worse the problem gets, to the point where the last couple of launches have been complete slide-shows, maybe 5 fps if I'm lucky. Just going around in Kerbin orbit with a decent sized ship (maybe 150 parts?) I'm seeing maybe 3 FPS at best. I don't have any reason to believe it's related to part count or a particular mod, as the modlist hasn't really changed since I started the save, and I have flown the same ship several times before with nowhere near this degree of issues. Loading the same vessel into a sandbox game gives me expected performance (not spectacular, but 25-30 FPS at least).

I do have some visual mods (EVE, scatterer) installed, and my system isn't exactly bleeding edge (GTX 670, i7 4770, 32GB), but none of that would seem to explain how the performance would be fine initially, but severely degrade over time. Memory and CPU usage aren't terrible (around 12GB and hovering at about 20%, not maxing out any of the cores), and I'm at a loss to find the bottleneck.

The only thing I can think of, is that perhaps it's somehow related to the number of vessels in the save? I have an admittedly large (~115) number of flights in progress, but I can't seem to understand how having many unloaded vessels on the other side of the solar system would effect the performance of the active vessel. There can't be *that* much processing going on with them, can there? I mean it's not like KSP does any kind of background processing, other than their orbits, which should be on rails anyway right?

I'm mostly posting this in the hopes that someone might have some advice on whether there is any kind of profiling I can do, or other ways to help narrow down the issue. I'm stuck at this point feeling like I have no idea where to look, and no good way to narrow down the options.

Thanks!

Link to comment
Share on other sites

1 hour ago, Chris97b said:

There can't be *that* much processing going on with them, can there? I mean it's not like KSP does any kind of background processing, other than their orbits, which should be on rails anyway right?

Unfortunately, this just isn't the case.  There is a known inefficiency in the handling of on-rails vessels due to the game recalculating the mass of every vessel on every physics update.  Not only does this use a considerable amount of CPU, but the code that does the calculations using the unloaded vessel data also creates a large amount of garbage.

There are also other things that are calculated, such as heat effects and whether any on-rails vessels have entered the current physics bubble and need to be loaded.

As a further test to flying the same ship in an empty save, you could also make a copy of your save and then terminate vessels in the tracking station a few at a time and see what effect it has on the frame rate.  Another thing that might show interesting results is running my MemGraph mod (linked in my sig below) to display the memory allocation rate and garbage collection frequency.  The heap padding feature probably wont help you but it's worth doing it on the off chance that your performance issue is actually due to the garbage collector running almost constantly.

Edit: I also meant to say that the devs are aware of this issue and do plan to fix it though they might appreciate seeing any performance figures you come up with...

Edited by Padishar
Link to comment
Share on other sites

15 minutes ago, Padishar said:

Unfortunately, this just isn't the case.  There is a known inefficiency in the handling of on-rails vessels due to the game recalculating the mass of every vessel on every physics update.  Not only does this use a considerable amount of CPU, but the code that does the calculations using the unloaded vessel data also creates a large amount of garbage.

Whoa... I shudder to think how many parts I probably have unloaded at the moment. That would certainly explain a few things. I guess I don't understand why that's necessary though, how could the mass of a vessel change if physics aren't being applied? I can't imagine a corner case where simply saving the total mass in the persistence file when a vessel goes on rails wouldn't be sufficient.

17 minutes ago, Padishar said:

As a further test to flying the same ship in an empty save, you could also make a copy of your save and then terminate vessels in the tracking station a few at a time and see what effect it has on the frame rate.  Another thing that might show interesting results is running my MemGraph mod (linked in my sig below) to display the memory allocation rate and garbage collection frequency.  The heap padding feature probably wont help you but it's worth doing it on the off chance that your performance issue is actually due to the garbage collector running almost constantly.

Yep, I'll do some testing and see what I can come up with. Thanks very much for the tips!

Link to comment
Share on other sites

2 minutes ago, Chris97b said:

Whoa... I shudder to think how many parts I probably have unloaded at the moment. That would certainly explain a few things. I guess I don't understand why that's necessary though, how could the mass of a vessel change if physics aren't being applied? I can't imagine a corner case where simply saving the total mass in the persistence file when a vessel goes on rails wouldn't be sufficient.

I guess you were typing that when I edited my first post.  It's basically a case of technical debt built up during the early access development period that didn't get cleaned up before release.  The devs are aware of it (and a number of others) and have plans to address them as soon as practical.  I don't believe the stock game ever changes the mass of any parts while a vessel is on rails but some mods do.  Any mass change could be communicated to the vessel directly rather than the vessel adding up the mass of all the parts every time.  Unfortunately, while this should work quite nicely for resources being produced and consumed, it doesn't fit very well with the IPartMassModifier interface that mods can use to dynamically adjust the non-resource bit of part masses.  However, I'm sure the Squad devs will be able to sort it out...

Link to comment
Share on other sites

9 minutes ago, Padishar said:

I guess you were typing that when I edited my first post.  It's basically a case of technical debt built up during the early access development period that didn't get cleaned up before release.  The devs are aware of it (and a number of others) and have plans to address them as soon as practical.  I don't believe the stock game ever changes the mass of any parts while a vessel is on rails but some mods do.  Any mass change could be communicated to the vessel directly rather than the vessel adding up the mass of all the parts every time.  Unfortunately, while this should work quite nicely for resources being produced and consumed, it doesn't fit very well with the IPartMassModifier interface that mods can use to dynamically adjust the non-resource bit of part masses.  However, I'm sure the Squad devs will be able to sort it out...

Yep, some basic testing pretty much confirms the issue is just a matter of too many unloaded vessels. Interestingly enough, the perceived performance (IOW my "feel" for the frame rate) seemed to improve dramatically after removing only 2-3 vessels (out of ~115), and they weren't particularly more complicated than any others. I have an armada of 28 ships heading to Jool, mostly copies of each other headed to each moon. Removing 3 of them nearly doubled the performance. It's almost like there's a line that once crossed, everything goes downhill fast.

That's sorta unfortunate actually. I was kinda hoping maybe there would be something I could do to make it playable at least. I guess I could remove Remote Tech and whack all of my comms setups, but that's the only thing I can think of that would still fit the goal of the save (colonize all 5 of Jool's moons).

Interestingly enough, it doesn't really seem to be related to memory or GC. The memory usage was pretty constant across tests and the GC stutter is painful, but no more so than it has been the entire save lol. This would seem to agree with the idea that the issue is simply CPU related in terms of processing a number of unloaded vessels.

I'm no expert coder by any means (not on your guys' level anyway), but it seems to me that if there's an interface that mods are implementing to change the mass of unloaded vessels, couldn't that interface have a mechanism to set a flag that the vessel mass needed to be recalculated?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...