Hi!

The current value of IntervalEpsilon is way too low for poll, often resulting
in repeated (10 or 100 or more) calls the poll with a timeout of 0.

The reason is that the current IntervalEpsilon is lower than the poll
resolution (which is 1ms) and Event rounds down, so it might see that
it hasn't slept long enough but then calls poll with a zero timeout because
its less than 1ms, resulting in a busy waiting loop.

rounding up in poll might help some, but that doesn't help the generic case
and does not seem correct, except in the case where timeout > 0 but < 1ms.

Now, being configurable (at runtime) is a good thing for IntervalEpsilon,
as one might simply have custom ideas about time resolution.

As for the default, thatsalmost certainly wrong for poll, as poll has an
inherent resolution of >= 1ms.

If clock_getres is available, it might provide a good default resolution
(it probably should be checked for <= 0.01 and >= 0.0001 or so), but that
might be overkill.

Now, when I increase IntervalEpsilon to 0.001, I still occasionally see
a few calls with timeout 0, and a lot of calls with timeout 1 or 2, and
it seems Event slowly builds up a deficiency, which would be unexpected,
too, as I would expect poll to return early either deterministically or
randomly, but not returning earlier on every call, so there might be other
rounding issues within event.

-- 
                The choice of a
      -----==-     _GNU_
      ----==-- _       generation     Marc Lehmann
      ---==---(_)__  __ ____  __      [EMAIL PROTECTED]
      --==---/ / _ \/ // /\ \/ /      http://schmorp.de/
      -=====/_/_//_/\_,_/ /_/\_\      XX11-RIPE

Reply via email to