Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP_NODELAY is disabled by default in WebSocket communication in 4.x, but was enabled by default in 3.x #86234

Closed
AlexandrDzyuba opened this issue Dec 16, 2023 · 1 comment · Fixed by #94618

Comments

@AlexandrDzyuba
Copy link

Tested versions

Reproducible in Godot 4.1, 4.2.1

System information

Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org Vulkan API 1.3.236 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 1660 Ti

Issue description

When utilizing WebSocket communication in Godot 4 with a remote server, there is a notable latency issue causing ping times to vary between 200ms and 300ms. This discrepancy is observed when compared to a similar project in Godot 3.5, where the ping ranges from 60ms to 90ms.

After investigation, it was found that disable the Nagle's algorithm using set_no_delay(true) for each WebSocketPeer significantly reduces the latency, bringing the ping down to 60-90ms. This behavior suggests that the default Nagle's algorithm implementation in Godot 4 might contribute to higher latency.

Note: The issue is not present in Godot 3.5, suggesting a change in the default behavior of WebSocket communication in Godot 4.

Proposed Solution:
Consider reviewing and optimizing the default implementation of Nagle's algorithm in Godot 4's WebSocket communication to achieve lower latency without the need for developers to manually disable the algorithm using set_no_delay(true).

It is recommended to document this optimization option in the WebSocket documentation, providing developers with information on how to improve latency by adjusting the Nagle's algorithm settings for their specific use cases.

Note: This report is submitted to bring attention to the observed latency issue and to suggest potential improvements for a smoother development experience in Godot 4.

Steps to reproduce

Create a Godot 4 project with WebSocket communication to a remote server.
Observe ping times ranging from 200ms to 300ms.
Disable Nagle's algorithm using set_no_delay(true) for each WebSocketPeer.
Observe a significant reduction in ping times to 60-90ms.
Expected behavior:
Ping times should be consistent and low without the need to disable Nagle's algorithm manually.

Minimal reproduction project (MRP)

test.zip

@Calinou Calinou changed the title High Latency Issue in Godot 4 WebSocket Communication TCP_NODELAY is disabled by default in WebSocket communication in 4.x, but was enabled by default in 3.x Dec 16, 2023
@Faless
Copy link
Collaborator

Faless commented Dec 17, 2023

I see, I would almost consider this a regression maybe.
IMO the WebSocketMultiplayer should indeed always set the no delay, while the low lever peer should probably leave the OS default (unless changed by the user).

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants