RemoteTechnologiesGroup / RemoteTech

Community developed continuation of Kerbal Space Program's RemoteTech mod.
http://remotetechnologiesgroup.github.io/RemoteTech
GNU General Public License v2.0
233 stars 102 forks source link

RemoteTech causing slowdown for RSS/RO #747

Closed MikeOnTea closed 6 years ago

MikeOnTea commented 6 years ago

Using RSS/Realism Overhaul/RP-0, a few other mods like eve/scatterer, and KSP 1.3.1. Did a Sandbox test with a clean environment except one satellite in orbit. Launched a rocket, and measured the time it took for the mission time to reach 1 minute. Without RT it took 1:14, with RT added, it took 1:27, thus quite a bit slower. Also, without RT, the game reached realtime speed after a bit more than a minute, while with RT it takes quite a bit longer.

System specs: Core i5 @ 4GHz, 16GB RAM, Windows 7.

KSP-TaxiService commented 6 years ago

Hmmm, honestly, it is known that RemoteTech has the polynomial CPU-time complexity on the top of its heavy use on LINQ library. This time complexity O(V²) comes from maintenance and connection-query of its internal network of vessels, V. In addition, under certain factors and scenarios, LINQ can affect the performance significantly.

So RemoteTech will always induce CPU costs, no matter how optimised it can be.

Can you provide output_log.txt in KSP_x64_Data for further analysis?

MikeOnTea commented 6 years ago

Sure, output_log.zip. While doing it, i did another comparison, this time with no vessels in orbit. 1:18 without RT, 1:36 with RT. Maybe the larger number of ground stations in RSS is part of the problem. How often is reachability/network link status updated? Might it be an option to somehow make that configurable so users can lower the update interval for better performance? Also, have you tried profiling RT? I don't know how well that works for unity games/mods, but if it works one can at least see which code takes most of the execution time. For a project at work, for example, the profiler helped me to identify one performance critical piece of LINQ code that could be optimized by converting to non-LINQ, but i could leave all the other places alone.

KSP-TaxiService commented 6 years ago

Thanks for the output log.

When I said RemoteTech maintains vessels, it uses KSP's global list of vessels, including space stations and asteroids.

Your log shows the normal work pattern of RemoteTech (eg registering all vessels every time the scene changes). Just lot of network-related activities everywhere.

Due to the combination of Microsoft .NET Framework 3.5 (old), external RemoteTech DLL and separate Unity exe, it is complicated to run Visual Studio's performance profiler on RemoteTech DLL. I so far unsuccessfully tried to profile it. Without any profiler results, I am stuck with no way to find sub-optimal calls and I don't want to resort to manual debugging.

So yup, I don't really have good way to make optimization changes to the codebase.

KSP-TaxiService commented 6 years ago

Sorry but I am afraid I can't do much on finding further optimizations or phasing out LINQ in RT codebase.