godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.21k stars 21.22k forks source link

PacketPeerUDP and StreamPeerTCP latency gets higher with more connected clients #81915

Open ghost opened 1 year ago

ghost commented 1 year ago

Tested versions

v4.2.1.stable.official [b09f793f5]

System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.3742) - Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz (4 Threads)

Issue description

UDPServer or PacketPeerUDP gets big latency on LAN network Its 27msec for only PING command between Server and 1 Client But its about 50msec for only PING command between Server and 3 Clients

Steps to reproduce

  1. Start Project below
  2. Run 2 or More Instances image
  3. Choose one windows press F2 to create Server
  4. Choose other and press F1 to create Client
  5. Get ping 27-50msec on LAN

Minimal reproduction project (MRP)

ServerUDP.zip

AThousandShips commented 10 months ago

Just edit your post instead of ads it here, no need to link it like that 🙂

ghost commented 10 months ago

Just edit your post instead of ads it here, no need to link it like that 🙂

sorry for, just its fundamental issue, want more people to see, there are no progress from september. I think i will try to solve it by my self.

Calinou commented 10 months ago

This is because you're sending/receiving packets and calculating ping on the main thread, so ping can only be a multiple of the frametime. Disabling V-Sync and ensuring framerate is as high as possible will decrease ping a lot:

image

This limitation is shared by a lot of games, which is one of the reasons competitive players like to reach hundreds of FPS. It's not just about input latency to display :slightly_smiling_face:

I can confirm the ping increases when more than 1 client is connected. The ping increase is proportional to how many clients are connected. You can test this by setting the Max FPS project setting to 20, then restarting all 4 instances. Ping will increase by increments of 50 for every new client connected. I don't know whether this is a bug or due to how the demo project is designed.