Skip to content

tweak(network): Reduce the minimum runahead latency limit from 10 to 4#1489

Merged
xezon merged 1 commit intoTheSuperHackers:mainfrom
Mauller:tweak-min-runahead
Aug 29, 2025
Merged

tweak(network): Reduce the minimum runahead latency limit from 10 to 4#1489
xezon merged 1 commit intoTheSuperHackers:mainfrom
Mauller:tweak-min-runahead

Conversation

@Mauller
Copy link

@Mauller Mauller commented Aug 24, 2025

This PR reduces the minimum run ahead limit.

This then allows the game to run with a lower input latency when the network latency allows.

The limit for now has been reduced by 6 frames. If the limit is set too low it can start to introduce stutter to the game where the game starts waiting on data. So a 4 frame window, resulting in 133ms of latency minimum compared to 333ms of retail provides a reasonable lower buffer.

The added advantage of this change is that when a SH client is the host, it can push the runahead below the 10 frames minimum cap for retail clients as well.

@Mauller Mauller self-assigned this Aug 24, 2025
@Mauller Mauller added Enhancement Is new feature or request Network Anything related to network, servers Gen Relates to Generals ZH Relates to Zero Hour labels Aug 24, 2025
@Mauller Mauller changed the title tweak(network) reduce the minimum runahead latency by 60% tweak(network) reduce the minimum runahead latency limit by 60% Aug 24, 2025
@Mauller Mauller added the Minor Severity: Minor < Major < Critical < Blocker label Aug 24, 2025
@Skyaero42
Copy link

Wonder why EA chose a value of 10. Maybe because internet speeds/latency weren't as good as nowadays?

That begs the questions:

  • What if I (West Europe) play against someone in New Zealand? Latency will be around 250-300ms if both have good connection.
  • What if I play on the CO live event on a local lan? Latency is even lower.

I almost feel like this should be configurable by the host for best performance

@Mauller
Copy link
Author

Mauller commented Aug 26, 2025

Wonder why EA chose a value of 10. Maybe because internet speeds/latency weren't as good as nowadays?

That begs the questions:

  • What if I (West Europe) play against someone in New Zealand? Latency will be around 250-300ms if both have good connection.
  • What if I play on the CO live event on a local lan? Latency is even lower.

I almost feel like this should be configurable by the host for best performance

This is only setting the absolute minimal value that the Runahead can be set to.

The game already dynamically adjusts the Runahead based on the network latency.

While testing with GO, we found that when we tried using a value of 2 as the bare minimum, which still allows the local machine to process some frames while waiting on data, the game would stutter when playing with some players but not others. This was when the network latency allowed the runahead to go this low.

In the above instance, 2 GO frames is 33ms compared to 66 for SH builds due to the 60/30Hz differences.

In a LAN i would still consider having some frames of runahead since there will still be some latency that's not directly network related with message processing etc.

I would say that 3 frames is the absolute minimum i would consider but i chose 4 as a reasonable bufffer that can work in 30Hz and 60Hz logic rates without needing individual settings.

Over Radmin, i have had some games where the latency can go bellow 10 but often won't go near the lower limit till you are playing with one other player. More of the netcode needs adjusting before the SH build can become as fast as how GO works.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also make this configurable, in a follow up change?

There even is a EA todo for it:

m_runAhead = min(max(30, MIN_RUNAHEAD), MAX_FRAMES_AHEAD/2); ///< @todo: don't hard-code the run-ahead.

Both MIN_RUNAHEAD and MAX_FRAMES_AHEAD can be made configurable right near

{ "NetworkRunAheadSlack", INI::parseInt, NULL, offsetof(GlobalData, m_networkRunAheadSlack) },

I also wonder what is up with that max(20 or 30, MIN_RUNAHEAD) and MAX_FRAMES_AHEAD/2. Very confusing.

Copy link
Author

@Mauller Mauller Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not a great deal of need to make the minimum value configurable.

That runahead with the comment is for the initial value, the runahead is constantly updated during runtime.

I have attempted to lower the initial runahead value, but it can just end up causing the game to lockup and a disconnect timeout to occur at the start of a match.

@xezon xezon changed the title tweak(network) reduce the minimum runahead latency limit by 60% tweak(network): Reduce the minimum runahead latency limit from 10 to 4 Aug 26, 2025
@xezon xezon added Major Severity: Minor < Major < Critical < Blocker and removed Minor Severity: Minor < Major < Critical < Blocker labels Aug 26, 2025
@xezon xezon added the Performance Is a performance concern label Aug 26, 2025
@Mauller Mauller force-pushed the tweak-min-runahead branch from 08d4ea8 to f453b88 Compare August 26, 2025 19:09
@Mauller
Copy link
Author

Mauller commented Aug 26, 2025

Updated with a comment on the tweak

@Mauller Mauller force-pushed the tweak-min-runahead branch from f453b88 to 4c31ca8 Compare August 27, 2025 19:30
@Mauller
Copy link
Author

Mauller commented Aug 27, 2025

Tweaked and pushed.

@xezon xezon merged commit 63bfe15 into TheSuperHackers:main Aug 29, 2025
17 checks passed
@xezon xezon deleted the tweak-min-runahead branch August 29, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker Network Anything related to network, servers Performance Is a performance concern ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Network has minimum latency of 10 frames, 333 ms

3 participants