xyz Not so fast Hos!

Did atomic tests on laptop and high end pc..

Laptop to pc over wifi - lan:

Godot Engine v4.3.beta2.official.b75f0485b - https://godotengine.org
Vulkan 1.3.278 - Forward+ - Using Device #0: Intel - Intel(R) UHD Graphics 620 (WHL GT2)

ClientNode connected
Timer started!
latency: 8 ms
latency: 7 ms
latency: 8 ms
latency: 6 ms
latency: 6 ms
latency: 6 ms
latency: 7 ms
latency: 7 ms
latency: 6 ms
latency: 7 ms
ClientNode disconnected
ServerNode listenning
--- Debugging process stopped ---

pc to laptop over wifi:

Vulkan 1.3.277 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 3090

ServerNode listenning
ClientNode connected
Timer started!
latency: 75 ms
latency: 3 ms
latency: 125 ms
latency: 3 ms
latency: 71 ms
latency: 94 ms
latency: 16 ms
latency: 40 ms
latency: 64 ms
latency: 94 ms
latency: 112 ms
latency: 33 ms
latency: 58 ms
ClientNode disconnected
--- Debugging process stopped ---

This makes no sense, if the timing was done the right way then the ping times should have atleast been similar on both devices over the same distance.

What im getting is that between computers with similar specs (the ones i tested yesterday) seems like it shows comparably true latency times, but when its high end vs low end then its not the case...

Also laptop is linux and pc is windows. Not sure if that changes anything. So im not sure what else to try.. 🙁

  • xyz replied to this.

    kuligs2 This makes no sense, if the timing was done the right way then the ping times should have atleast been similar on both devices over the same distance.

    What "timing"?
    If your client and server are polling as fast as possible, then the "problem" is with your networks and has nothing to do with Godot. It could also be the case that a thread is not getting enough of a time slice and/or not being put on a separate core. This again is the responsibility of the OS and Godot can do nothing about it.

    You want the server to run as fast as possible. So it needs to be on a fast machine. You can try the other alternative I've suggested earlier, namely running the custom main loop and do everything in the main thread. Also don't forget to shut down any other unneeded work the server machine may be doing because it can steal cpu cycles that otherwise would be used by the server app.

    In general, if you run the server and the client as separate apps on the same machine communicating via localhost - there should be zero latency. If that is indeed the case then there's nothing more that can be done on Godot side.

      xyz If your client and server are polling as fast as possible, then the "problem" is with your networks and has nothing to do with Godot

      How come using "ping" command in terminal produces constant results and are not in sort of same margins that im getting on either of my godot application examples?

      There is nothing wrong with the network as i can reproduce the "pings" ICMP, from one to other computer with close to similar results. in this case pc to laptop and vice versa 1-3ms... Not 100ms in one way and 8ms in other way.

      xyz It could also be a case that a thread is not getting enough of a time slice and/or not being put on a separate core. This again is the responsibility of the OS and Godot can do nothing about it.

      This could be the problem, as the problem occures only on low spec machine, while the high spec machine as server gives out good pings, and low spec server gives out delayed pings.

      xyz You can try the other alternative I've suggested earlier, namely running the custom main loop and do everything in the main thread.

      Are you talking about this? https://docs.godotengine.org/en/stable/classes/class_mainloop.html How is is different from running separate scripts? It seems like it is just a plain script that extends mainloop class? So in this case if i put the server code in this script, do i poll in the _process or create a thread like we did yesterday?

      The whole idea behind this exercise is to eventually make a lobby system, where players host a game, game sends address to masterlist, other players query master list for hosted games, make connections to the hosted games, get game info, view all games in a browser and join. In other words - server browser.

      I have figured out the masterlist thing, and game info thing, now i just wanted to show players the ping between their machine and the hosted game machine, so that they would be able to join the ones that are closer - lesser latency.

      • xyz replied to this.

        kuligs2
        Then just execute ping via OS::execute()

        Also note that ping typically uses plain IP protocol which is one layer below UDP socket protocol in the internet protocol suite. So it'll likely be faster. For the actual reference times try pinging with a tool that lets you specify the protocol.

        Also, you can benchmark time between two consecutive iterations in the polling loop and see if the values corelates with the communication delay.

          xyz

          xyz Then just execute ping via OS::execute()

          First of all didnt know you could do that. Secondly this would assume that these programs exist on the device, and in real world situations is not reliable. I could pack the libs along with godot but idk.. it could be last resort. Im sure there is a way to do it reliably in godot. I just need to figure it out.

          xyz Also note that ping typically uses plain IP protocol which is one layer below UDP socket protocol in the internet protocol suite. So it'll likely be faster. For the actual reference times try pinging with a tool that lets you specify the protocol.

          I know, but relatively speaking i would understand that i would get higher times using higher protocols like UDP but here problem is consistency. One device receives faster than the other while doing the same work... if both devices would show the same times, dont matter how high they are, then i could start thinking about other protocols, and in godot i dont thik there is anything lower than TCP or UDP..

          xyz Also, you can benchmark time between two consecutive iterations in the polling loop and see if the values corelates with the communication delay.

          What am i measuring here? For example now im measuring from put_packet until i get_packet. This is done on the client, server just get_packet and puts_packet back at the client. And this action is triggered by times once every second.

          Measuring for fast polling happens?

          poll
          latency = current_time - last_poll_time?
          last_poll_time = current_time

          And then read out that latency variable? But the pollin would happen super fast as it runs like 100000/s or something..

          • xyz replied to this.

            kuligs2 One device receives faster than the other while doing the same work

            You don't know if they do the same work. The work is not symmetrical so with machines of different power it's totally expectable that swapping it may give different benchmarks of their total work. Test the actual UDP protocol communication both ways with some reliable tool. Comparing UDP times with IP pings is comparing apples and oranges.

            kuligs2 Measuring for fast polling happens?

            Yeah, just get the average ballpark here and see if it's larger when there is larger reported latency. This will be a hint that the thing is caused by polling frequency (quite likely). Otherwise it's something else.

            The whole point of doing all those tests is to determine if this it Godot's or OS's "fault", so you can properly decide where to intervene.

              xyz
              Ok so (i havent yet tested, will be like 6h before i get hom) but i assume that like you said the polling happens on different rates, each machine ticks at its own pace. So how would you sync times? Im no math expert, but to me it seems that i would need to get some sort of value that i could use as a baseline for truth, and then depending on the poll rate somehow deduct the actual time? Maybe i could put_packet once and then let the server send me multiples of that packet back and i average the time on client somehow?... Need to think this through..

              • xyz replied to this.

                kuligs2 What exactly would "sync times" mean here? You can't or need not to "sync" anything. There will always be latency in any network communication and it will always vary depending on multiple factors including protocols, routing, bandwidths, current traffic, server or client cpu load etc. You can't rely on any absolutes in network communication.

                As I said, your "objective" baseline is something you'd measure using a reliable UDP pinging tool. Compare your Godot stuff with that if you want to determine if it performs near optimum.

                kuligs2 A good thing to also try would be to write the server side test code in Python using Python's socket and see how that performs when pinged by Godot client.

                  xyz did nmap/zenmap ping, multiple computers around the office, seems to give me back around 0 to 10 ms..

                  nmap -sU -p IP
                  Host is up (0.00013s latency).
                  Host is up (0.0010s latency).

                  I guess ill write that pyton thing..

                  • xyz replied to this.

                    xyz what thing? when? The main loop?

                    Now i got an idea why would it be so different, maybe because i was running it from the editor? Maybe editor attaches somehting to the compiled binary and does some baboonary on it thus slowing down packets or something.. Will try to compile OS native binaries to test this.. But i can do these test when im home, At work pc's are somewhat fast and similar and i see no apparent problems here.

                    • xyz replied to this.

                      kuligs2 what thing? when? The main loop?

                      The Godot client and server apps - the thing you're working on. Have you run them on your work machines, the same machines you've run nmap?

                        xyz yes. Ive tested this project on office machine vs office, home machine vs laptop, office vs virtual machine home, The problem is with laptop so far.. At home i dont have any other computer, i could spin up virtual on other hardware. And at work i dont hav eaccess to wired network for laptop, and wifi is not passed to wired network for safety reasons.

                        Later I will do nmap at home for laptop and see what i get. And then try to compile the app so that i can exclude editor shenanigans. Then i could write some server app outside godot environment to test the ping measurements in godot and measure ping on that app from godot server.

                        After that idk.. try that main loop thing? But you never answered should i run threads in the separate loop or use _process func?

                        • xyz replied to this.

                          kuligs2 Forget the main loop thing. I think it won't contribute to the performance much. Do everything else you mentioned though. And report back 😃

                            xyz Ok nmap results:
                            nmap -sU -p 27800 IP

                            pc to laptop

                            Host is up (0.093s latency).
                            Host is up (0.017s latency).
                            Host is up (0.026s latency).
                            Host is up (0.10s latency).
                            Host is up (0.094s latency).
                            Host is up (0.088s latency).
                            Host is up (0.097s latency).
                            Host is up (0.11s latency).
                            Host is up (0.034s latency).
                            Host is up (0.043s latency).
                            Host is up (0.071s latency).
                            Host is up (0.066s latency).
                            Host is up (0.087s latency).
                            Host is up (1.1s latency).
                            Host is up (0.11s latency).
                            Host is up (0.088s latency).
                            Host is up (0.077s latency).
                            Host is up (0.16s latency).
                            Host is up (0.069s latency).
                            Host is up (0.038s latency).
                            Host is up (0.097s latency).
                            Host is up (0.041s latency).
                            Host is up (0.050s latency).
                            Host is up (0.026s latency).
                            Host is up (0.11s latency).
                            Host is up (0.10s latency).
                            Host is up (0.10s latency).

                            Laptop to pc:

                            Host is up (0.0056s latency).
                            Host is up (0.0058s latency).
                            Host is up (0.0053s latency).
                            Host is up (0.0031s latency).
                            Host is up (0.0058s latency).
                            Host is up (0.0058s latency).
                            Host is up (0.0052s latency).
                            Host is up (0.0058s latency).
                            Host is up (0.0054s latency).
                            Host is up (0.0055s latency).
                            Host is up (0.0052s latency).

                            well the data is pretty consistent... 🙂

                            Im guessing, idk..

                            Browser on pc:

                            Browser on laptop

                            well i guess the latency is correct, something wierd is going on on laptop.. 😃

                            EDIT:
                            Here is a test from local lan game:

                            The arch is the laptop. At few points i got packet loss on pc (laptop is host), but ping stayed consistent and on both games its the same number

                            • xyz replied to this.

                              kuligs2 So charges against Godot dropped then? 😃
                              Looks like just a standard case of frail laptop with moldy network adapter. Pro tip: don't use such machines as servers.
                              🤓

                                xyz I bought it 2 weeks ago 😃 (used) thickpad yoga x390. But yeah.. you live and you learn.. every day..

                                Now gonna try to finish that browser thing.. i still need to dispose the threads correctly, otherwise im getting red warnings..

                                xyz BTW, i got an ethernet adapter for my laptop (its not an usb adapter i think because it uses proprietary connector).

                                Anyways, now i tested the latency and its all good.
                                On pc:

                                On laptop

                                TLDR wifi is voodoo, cant trust it.