Experimental changes in the Multiplayer Ping Reduction System

New EE2 Government (since: 01.03.2014), everything about the EE2 management. You can report other players here.
Post Reply
User avatar
Dr.MonaLisa
High Representative
Posts: 8965
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 59 times
Been thanked: 154 times

Experimental changes in the Multiplayer Ping Reduction System

Post by Dr.MonaLisa »

On 28th December 2017, I released a Minor Update that reduced ping between players by 30 up to 60 milliseconds

https://ee2.eu/patch/changes/#156020
[156020 - 2017-12-28]:
* Added fixes to reduce ping (delay) between the host and players by ~30 up to 60 milliseconds.
The fix reduced the sleep in the Multiplayer's ENet thread from 30 to 1 ms.

Yesterday, this is 26 of October 2024, we detected an anomaly in games with too low ping between players. The anomaly was the following:
- When player GenialnyŹółw joined my room, we had ping of 22 ms. Once the game was started, we noticed a strange mini-freezes, noticeable especially when fighter jets were moving. It didn't affect the command lag, everything was still perfectly responsive, but the game felt slower.
- When player GenialnyŻółw was hosting the game, the mini-freezes were less noticeable, but still existing.

For the testing purposes, I modified remotely the sleep in the ENet thread:
- When restored default EE2's "30 ms" the mini-freezes (units slowdown) were gone.
- Setting values lower than ~15 were causing the mini-freezes to appear again.
- Setting the value of 0 solved the mini-freezes problem competely.

Theory of the reasons that cause it:
- This is most likely a bug or some security fix in Windows, that causes functions WaitForSingleObject or Sleep to take more CPU time than expected (or simply inaccurate time). Since I recently upgraded to Windows 11 24H2, this feels like the most probable scenario.
- High-end processors with the high clock speed. Since I use Ryzen 9 5950X and I have more mini-freezes (when hosting the game) than player GenialnyŹółw with a worse processor, it's possible that the reason are some AMD fixes or simply the data is being processed on my computer too fast. Ironically, the better processing speed could be affecting it, but it's unlikely.

Solution:
- As a solution, I have remotely set the ENet Thread's Sleep time to 0 milliseconds, for all Unofficial Patch users. This means that we disable the thread sleep completely, and prevent the WaitForSingleObject or Sleep functions from being called by the ENet thread.

Possible problems:
- Very unlikely, but this hotfix might increase the CPU load on the processor core that EE2 uses for Multiplayer. This is very unlikely, because both players would need to have ping "0" between each other. Since there is always a delay, we can assume that the thread is anyway waiting for data from players and doesn't loop infinitely. This is still something to observe and report in this topic if you experience such problems.
- As always, we cannot predict what other issues can appear when the sleep is removed completely, therefore it's important that multiplayer users report the NEW issues they noticed in this topic.

What you have to do?
- You don't need to do anything, as the ENet Threa'd Sleep removal was applied to all users with the Unofficial Patch Keep Alive system. It's important to have a working Internet connection before starting the Launcher / game, so that the new configuration value is downloaded from the EE2.eu server. In any case, it's important to notify me about NEW issues that you notice during multiplayer matches.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains

User avatar
Dr.MonaLisa
High Representative
Posts: 8965
Joined: 17 Jun 2010, 11:21
Location: Poland
Has thanked: 59 times
Been thanked: 154 times

Re: Experimental changes in the Multiplayer Ping Reduction System

Post by Dr.MonaLisa »

This experimental change was reverted on 27-28th October 2024.

Unfortunately, it seems that removing the sleep fully is causing the 100% processor core load for the EE2ENet thread. This thread is separated from the main game thread, therefore it shouldn't cause any performance issues, but it still doesn't seem right to waste electricity and cause more heat.

Since this problem affects very little players, and usually the ping is not that low (under 30 ms), I decided to restore the default UP1.6's sleep time (1 ms).
However, the next Minor Update 160020 (released somewhere in November), will have the following change:
- New Feature: Option "EE2ENet Boost" added to Maximization Helper & Game Tweaker:
* When enabled, this option removes the 1 ms sleep in the Multiplayer EE2ENet thread. This helps resolve issues with random or periodic lag in multiplayer games, where units may visibly slow down, especially in low-ping games with ping under 30 ms.
* Enabling this option increases one of the CPU cores usage (used by EE2ENet thread) to 100% (instead of 0-1%), so it is recommended to only use this feature as needed and disable it afterward.
* Changing the status of this option has an immediate effect (no game restart is required).

Therefore players who need it, because they notice unit slowdowns will be able to easily check an option in the Maximization Helper window, which will have immediate effect, even during active game. I believe this is the best solution that everyone will be satisfied with :)
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Post Reply

Return to “Ministry of Game Affairs of the Empire Earth II Community”