What happens if you do pass 0 to the timeout, and let it just spin (as a test)?<div>Does it still drop huge amounts of packets and expose the same kinds of problems?<br><div>Ruud<br><br><div class="gmail_quote">On Tue, Jun 19, 2012 at 11:13 PM, Soren Dreijer <span dir="ltr"><<a href="mailto:dreijer@echobit.net" target="_blank">dreijer@echobit.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Well, so regardless of whether the timer enet uses is inaccurate, it's<br>
guaranteed that enet_host_service() returns as soon as new packets have been<br>
received (courtesy of select()). That means that my process should be<br>
spinning at 100% CPU if it's struggling to keep up with all the incoming<br>
packets, but it isn't.<br>
<br>
That's what puzzles me. You're correct in that I could just do my own sleep<br>
to optimize the loop so I can send packets as fast as possible, but that<br>
doesn't solve the issue at hand, unfortunately.<br>
<br>
I'm trying to repro this in a staging environment since I can't just restart<br>
the server in production as it'll impact a good bunch of users.<br>
<div class="HOEnZb"><div class="h5"><br>
> -----Original Message-----<br>
> From: <a href="mailto:enet-discuss-bounces@cubik.org">enet-discuss-bounces@cubik.org</a> [mailto:<a href="mailto:enet-discuss-">enet-discuss-</a><br>
> <a href="mailto:bounces@cubik.org">bounces@cubik.org</a>] On Behalf Of James B<br>
> Sent: Tuesday, June 19, 2012 3:54 PM<br>
> To: <a href="mailto:enet-discuss@cubik.org">enet-discuss@cubik.org</a><br>
> Subject: Re: [ENet-discuss] enet is dropping packets<br>
><br>
><br>
> why not just call enet_host_service with a timeout of 0, then if you<br>
haven't<br>
> received any packets in X seconds do your own sleep(1) so you don't eat<br>
all<br>
> the cpu.  also i don't know what platform you are on, but making enet<br>
sleep<br>
> is not a wise choice IMO, for example on windows it uses timeGetTime which<br>
> can be 5ms or more inaccurate, meaning you could only be processing the<br>
> event loop 200 times per second rather than 1000 as you think.  what's<br>
worse<br>
> in my testing is Sleep() and timegettime can be more inaccurate than that,<br>
> sometimes sleep will sleep 5ms or 30ms, no matter the argument passed,<br>
> which is why its much better to use an adaptive technique where you only<br>
> sleep during times of low load, and where you control the sleep.  a good<br>
> implementation might be to examine your current packets processed per<br>
> second, and if this is under some value then sleep(1), if not then<br>
sleep(0)<br>
><br>
> ----------------------------------------<br>
> > From: <a href="mailto:dreijer@echobit.net">dreijer@echobit.net</a><br>
> > To: <a href="mailto:enet-discuss@cubik.org">enet-discuss@cubik.org</a><br>
> > Date: Tue, 19 Jun 2012 15:30:14 -0500<br>
> > Subject: Re: [ENet-discuss] enet is dropping packets<br>
> ><br>
> > > Eh, it is an upper bound on the wait time if nothing is received!<br>
> ><br>
> > Are you absolutely sure about this? I seem to recall back when I started<br>
> > with enet that calling enet_host_service() with a high timeout would<br>
cause<br>
> > huge delays in receiving packets because enet_host_service() wouldn't<br>
> return<br>
> > until the timeout has expired. I'll verify that again, but I thought<br>
that<br>
> > was how it worked at least.<br>
> ><br>
> > I find it hard to believe that my dedicated thread cannot service<br>
packets<br>
> > for 124 users (who aren't really sending THAT much data) if the thread<br>
is<br>
> > running as fast as it can.<br>
><br>
><br>
> _______________________________________________<br>
> ENet-discuss mailing list<br>
> <a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
> <a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
<br>
_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
</div></div></blockquote></div><br></div></div>