[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] optimize evutil_gettimeofday()'s Windows implementation



On Fri, Jun 15, 2012 at 8:17 PM, Dave Hart <davehart@xxxxxxxxx> wrote:
> The code for evutil_gettimeofday() on Windows is:
 [...]
> That substitutes a multiplication followed by subtraction in place of
> the modulo 1 million.  While I haven't tested it, I believe mul + sub
> will be faster than modulo (division).  I'm not actually using
> libevent on Windows at this point.

I agree, and I'd take a patch to do this, but I think the bigger win
would be to change how we handle time so that the
evutil_gettime_monotonic_() function is the one optimized; it should
be the one that gets called frequently now in 2.1.x.  Also, I think
there's a bigger win to be had if we change how we handle timeouts
internally so that times are kept internally in whatever format is
easiest for evutil_gettime_monotonic_() to generate, and converted to
and from struct timeval only at the edges of the Libevent loop API.
Or possibly, we should be storing times internally in terms of a
uint64_t, so that our heap comparisons always go quickly.  Some
analysis is needed!

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.