Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualTispe

Posted 18 March 2014 - 07:36 AM

I am wondering about this myself. I use a thread which Enet is created and managed on. The whole thing boils down to 1ms latency vs 100% CPU usage.

 

In the networking thread I can set the timeout to 1ms, such that it will use less then 1% of the CPU. But this may cause 1ms latency, or if Sleep() is used inside the Enet library upto 10ms iirc. I have only found some while loops in the Enet code, I can't figure out how it waits for packets, maybe it has driver interupts waking it up. Which eliminates the latency, but idk.

 

Or have a 0ms timeout and the thread will consume 100% of the core it is running on. So I don't know which to use to be honest.

 

But anyway, I don't think one should have more then 1ms timeout. Since your main thread needs to send packets too. If you have a 5000ms timeout then you only send out packets every 5seconds...

 

I don't think Enet has internal threads for recieving/sending packets. Because if you don't service the host within 15-20seconds it will disconnect from the server. So if you have it in your main thread and the game freeze for 20sec then you disconnect.


#1Tispe

Posted 18 March 2014 - 07:32 AM

I am wondering about this myself. I use a thread which Enet is created and managed on. The whole thing boils down to 1ms latency vs 100% CPU usage.

 

In the networking thread I can set the timeout to 1ms, such that it will use less then 1% of the CPU. But this may cause 1ms latency, or if Sleep() is used inside the Enet library upto 10ms iirc. I have only found some while loops in the Enet code, I can't figure out how it waits for packets, maybe it has driver interupts waking it up. Which eliminates the latency, but idk.

 

Or have a 0ms timeout and the thread will consume 100% of the core it is running on. So I don't know which to use to be honest.

 

But anyway, I don't think one should have more then 1ms timeout. Since your main thread needs to send packets too. If you have a 5000ms timeout then you only send out packets every 5seconds...


PARTNERS