[issue20320] select.select(timeout) and select.kqueue.control(timeout) must round the timeout to the upper bound

Charles-François Natali report at bugs.python.org
Tue Feb 11 12:23:05 CET 2014


Charles-François Natali added the comment:

> STINNER Victor added the comment:
>
>> Just so it's clear, those bugs are theoretical: whether you pass
>> 1e-7/1e-10 or 0 to select/kqueue is exactly the same (entering/leaving the
>> syscall takes some time)...
>
> After many many tests with asyncio (last issue: #20505), I disagree with
> you. It has a real impact.

And I stand by my claim. Quoting your test results:
"""
asyncio: IocpProactor.select(10.0000 ms) took 9.486 ms
(monotonic=0.000 ms, clock res=15.600 ms)
asyncio: IocpProactor.select(0.0010 ms) took 0.942 ms (monotonic=0.000
ms, clock  res=15.600 ms)
asyncio: IocpProactor.select(0.0000 ms) took 0.553 ms (monotonic=0.000
ms, clock res=15.600 ms)
asyncio: IocpProactor.select(0.0000 ms) took 0.517 ms (monotonic=0.000
ms, clock res=15.600 ms)

asyncio: SelectSelector.select(0.1000 ms) took 2.276 ms
(monotonic=0.000 ms, clock res=15.600 ms)
asyncio: SelectSelector.select(1.0000 us) took 30.810 us
(monotonic=0.000 us, clock res=15600.100 us)
asyncio: SelectSelector.select(0.0100 us) took 30.350 us
(monotonic=0.000 us, clock res=15600.100 us)
asyncio: SelectSelector.select(0.0001 us) took 28.930 us
(monotonic=0.000 us, clock res=15600.100 us)
"""

As one can see, when passed a timeout lower than the resolution, e.g.
0.01 usec, select() takes around 30usec, *which is above the timeout*
(0.01usec), which is exactly what I claimed.

> These results are the expected behaviour: selectors should at least one unit of the monotonic time (15.6 ms).

That's just wrong.
The expected bahavior is that selector.select() should wait at least
the *timeout passed*, not the "unit of monotonic time" (which doesn't
mean anything by the way).

Now, rounding away from zero for select/kqueue is fine to me, just to
be consistent.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20320>
_______________________________________


More information about the Python-bugs-list mailing list