STINNER Victor added the comment:

> Any benchmarks?

Wait, it's easier to write a patch than to cook a benchmark :-)

Attached script bench_epoll_poll.py creates a lot of sockets and call 
epoll.poll() in non-blocking mode (timeout=0). You can decide to create or not 
events.

It looks like performance when epoll.poll() gets events are unchanged with my 
patch.

The performance are better when epoll.poll() doesn't get any event: between 6% 
and 20% faster.

I'm not completly sure that it's worth it since we are talking about 
nanoseconds. The largest seen difference was 94 nanoseconds: 420 ns => 326 ns.

My microbenchmark is unstable. Even if it runs the benchmark 25 or 50 times and 
take the minimum, I have to run it between 3 and 10 times to see the "real" 
minimum timing... It's a common problem for microbenchmarks with timing smaller 
than 1 ms.


Create read+events (10 sockets):

*  Without the patch: Best of 25 runs (100000 loops, 10 FDs): 1294 ns per call 
to epoll.poll()
*  With the patch: Best of 50 runs (100000 loops, 10 FDs): 1221 ns (-6%) per 
call to epoll.poll()

Create read+events (8000 sockets):

*  Without the patch: Best of 25 runs (10 loops, 16000 FDs): 4.6 ms per call to 
epoll.poll()
*  With the patch: Best of 25 runs (10 loops, 16000 FDs): 4.6 ms (same) per 
call to epoll.poll()

Don't create events (10 sockets):

*  Without the patch: Best of 50 runs (100000 loops, 10 FDs): 367 ns per call 
to epoll.poll()
*  With the patch: Best of 50 runs (100000 loops, 10 FDs): 343 ns (-7%) per 
call to epoll.poll()

Don't create events (1000 sockets):

*  Without the patch: Best of 50 runs (100000 loops, 1000 FDs): 420 ns per call 
to epoll.poll()
*  With the patch: Best of 50 runs (100000 loops, 1000 FDs): 326 ns (-22%) per 
call to epoll.poll()

Don't create events (16000 sockets):

*  Without the patch: Best of 50 runs (100000 loops, 16000 FDs): 422 ns per 
call to epoll.poll()
*  With the patch: Best of 50 runs (100000 loops, 16000 FDs): 338 ns (-20%) per 
call to epoll.poll()

----------
Added file: http://bugs.python.org/file41745/bench_epoll_poll.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26233>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to