Bug #5136
Turning on fuel cells causes lag
100%
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
History
#1 Updated by carlothecurious over 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 over 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 over 9 years ago
- File FuelCellLag.craft FuelCellLag.craft added
- File off.jpg off.jpg added
- File on.jpg on.jpg added
- Status changed from New to Confirmed
- % Done changed from 0 to 10
- Platform Any added
- Platform deleted (
Windows)
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 over 9 years ago
- File agframetimespike.jpg agframetimespike.jpg added
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 over 8 years ago
- Status changed from Confirmed to Needs Clarification
- % Done changed from 10 to 0
#8 Updated by TriggerAu over 8 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