Skip to content

Conversation

@gotmachine
Copy link
Contributor

@gotmachine gotmachine commented Mar 8, 2025

The current CommNetThrottling patch is a fix for the stock logic, that was inactive due to a botched implementation.
We previously had that (fixed) stock throttling mechanism as a disabled by default, opt-in patch (see PR #58).

The stock implementation and default settings of the patch is rate-limiting CommNet updates based on real-world elapsed time, 5 seconds in normal play and phys-warp, and 0.5 second in non-phys warp. Compared to what happens in stock (which isn't rate-limited at all, CommNet updates happen every visual frame), the 5 second lag in CommNet updates is quite noticeable (for example when waiting for signal acquisition after a LoS loss), and the 0.5 second hard cap is making the simulation precision quite terrible at mid to high timewarp rates.

While there are very little gameplay mechanisms affected by the loss of precision in stock, some mods are using CommNet a bit more extensively, and I'd argue that there is usually a lot more performance headroom in non-phys timewarp.

This PR propose a revamped mechanism that use an upper limit interval between updates in an in-game time set to 2.5 seconds, which is more acceptable for gameplay purposes. It also put an upper bound on the real time update frequency set to 50 hz (20 ms minimum interval), as there is no point in running at stupidly high update frequencies on high frequency monitors or if the framerate isn't locked (manually or through V-Sync). That last setting can be increased to up to 500 or even 1000 ms in case the user doesn't care about simulation precision during timewarp and want to avoid the continuous performance hit in such cases. This PR also enable the patch by default.

…updates are now occuring at a configurable in-game seconds interval (default is 2.5 seconds), instead of a real time interval with a hard minimum of 0.5s. This mean simulation precision will stay consistent when timewarping, as updates will happen more frequently as the timewarp rate goes up, up to every fixed frame when crossing the 125x warp threshold (for the default 2.5s). We also put a upper bound on the update frequency at 50 Hz by checking the fixed/physics frame count (no point in running at stupidly high update rates on high frequency monitors or if framerate isn't locked).
… limit and a real world time minimum interval.
@gotmachine gotmachine added the kspPerformance Possible performance improvement in KSP label Mar 8, 2025
@gotmachine gotmachine merged commit 9010ae1 into dev Mar 8, 2025
1 check passed
@gotmachine gotmachine deleted the BetterCommNetThrottling branch March 9, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kspPerformance Possible performance improvement in KSP

Development

Successfully merging this pull request may close these issues.

2 participants