Project

General

Profile

Bug #5136

Turning on fuel cells causes lag

Added by carlothecurious almost 9 years ago. Updated over 7 years ago.

Status:
Closed
Severity:
Low
Assignee:
-
Category:
Parts
Target version:
-
Start date:
06/15/2015
% Done:

100%

Version:
Platform:
Any
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

Turning on fuel cells appears to cause noticeable physics lag.

Example test ship in stock 1.0.2 (build 00842) with 80 cells - http://i.imgur.com/fjI2HCP.jpg?1

The point where I turn on all the cells (via an action group) is fairly obvious.

System specs - http://www.mediafire.com/view/mmtukboqocfa4zm/DxDiag.txt

FuelCellLag.craft (137 KB) FuelCellLag.craft Pod, battery, tank and 72 fuel cells Padishar, 06/24/2015 10:56 PM
off.jpg (271 KB) off.jpg Padishar, 06/24/2015 11:46 PM
on.jpg (293 KB) on.jpg Padishar, 06/24/2015 11:46 PM
agframetimespike.jpg (317 KB) agframetimespike.jpg Padishar, 07/25/2015 05:02 PM
6922
6923
7166

History

#1 Updated by carlothecurious almost 9 years ago

I chatted with RoverDude about this on reddit and it seems it's just a result of maxing CPU load. Feel free to close this.

#2 Updated by Padishar almost 9 years ago

I wouldn't be so quick to close this. This is almost certainly caused (or at least made much worse) by inefficiencies in the Part.RequestResource function that is called on each fuel cell part each frame to add the electricity to the vessel. Each call loops through all the parts in the vessel building a list of all the EC storage parts (in a way that creates unnecessary garbage), works out which ones of them should get filled up and then splits the amount of EC being added between all those parts. So, in addition to the garbage thrash, this is effectively O(n^2) so as the number of parts increases the performance suffers drastically.

I would be interested to see what GCMonitor (http://forum.kerbalspaceprogram.com/threads/92907) shows for this vessel. I'll knock up a few test craft later...

#4 Updated by Padishar almost 9 years ago

6922
6923

Confirmed using FuelCellLag.craft attached. While the fuel cells are off the game is running at 60fps (limited in settings) and GCMonitor shows this:

Enabling the fuel cells (action group 1) causes very rapid creation of garbage with the garbage collection running every 1.5 seconds. The frame rate drops to 16-18 fps. GCMonitor shows:

The garbage thrash continues once the fuel cells shut themselves off (once the 4k battery gets to 3800), I guess they don't shut off very much. Turning them off with action group 2 returns everything back to normal, 60 fps and the much slower rate of garbage collection.

#6 Updated by Padishar almost 9 years ago

7166

Another somewhat worrying thing is how long it takes to run the action group that enables or disables the fuel cells. This shows a graph of the frame time (time between successive calls to Update) and shows it taking approx. 400ms to enable or disable the cells. This can easily be seen without the frame time graph by activating the action group while rotating the camera.

Why does it take this long to enable 72 parts?

#7 Updated by TriggerAu almost 8 years ago

  • Status changed from Confirmed to Needs Clarification
  • % Done changed from 10 to 0

#8 Updated by TriggerAu over 7 years ago

  • Status changed from Needs Clarification to Closed
  • % Done changed from 0 to 100

Closing this report out for now. If you find it is still occuring in the latest version of KSP please open a new report (and this one can be linked to it.) For best results, the wiki contains really useful info for when creating a report http://bugs.kerbalspaceprogram.com/projects/ksp/wiki.

You can also ask questions about the bug cleanup in the forum here: http://forum.kerbalspaceprogram.com/index.php?/topic/143980-time-to-clean-up-the-bug-tracker/ and tag @TriggerAu to get my attention

Also available in: Atom PDF