Charles-François Natali added the comment: Ross, the select() result for a large number of ready FDs was completely skewed because of a bug spotted by Antoine (complexity was much worse than it ought to be). Here are the results with the fix: """ $ ./python ~/selector_bench.py -r 10 -m 1000 -t socket Trying with 10 ready FDs out of 1000, type socket <class 'select.EpollSelector'> 0.05156186099338811 <class 'select.PollSelector'> 0.23772043800272513 <class 'select.SelectSelector'> 0.5181516080047004 $ ./python ~/selector_bench.py -r 100 -m 1000 -t socket Trying with 100 ready FDs out of 1000, type socket <class 'select.EpollSelector'> 0.47576940699946135 <class 'select.PollSelector'> 0.6458770600002026 <class 'select.SelectSelector'> 0.828609222000523 $ ./python ~/selector_bench.py -r 1000 -m 1000 -t socket Trying with 1000 ready FDs out of 1000, type socket <class 'select.EpollSelector'> 4.970445963997918 <class 'select.PollSelector'> 5.7709292660001665 <class 'select.SelectSelector'> 4.030775418999838 """
With a large number of FDs, many of which are ready, select can be faster. Here's the output of "strace -c -e select,poll,epoll_wait": """ % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 83.86 0.000421 0 1024 epoll_wait 16.14 0.000081 0 1024 poll 0.00 0.000000 0 1024 select ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000502 3072 total """ The systime is greater in epoll, but the systime is negligible, as show by 'time': """ real 0m14.856s user 0m14.289s sys 0m0.340s """ The time is really spent in the interpreter. I'll dig some more (even though I doubt having 1000/1000 ready FDs is a common use case). Note that it doesn't change anything when a small number of FDs are ready: """ $ ./python ~/selector_bench.py -r 10 -m 1000 -t socket Trying with 10 ready FDs out of 1000, type socket <class 'select.EpollSelector'> 0.05238822099636309 <class 'select.PollSelector'> 0.25595822899776977 <class 'select.SelectSelector'> 0.5156362060006359 """ ---------- Added file: http://bugs.python.org/file28564/selector-3.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16853> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com