New submission from Charles-François Natali: Currently, epoll.poll() allocates an epoll_event buffer every time/ this is bad, because it changes an O(number of ready FDs) syscall into a O(maxevents/FD_SETSIZE) complexity. The patch attached allocates a epoll events buffer per epoll instance, and it only gets reallocated when necessary (note that the reallocation heuristic will probably be improved in #16873 (and having a per instance maxevents count will likely be useful).
Here's a benchmark without patch: $ ./python -m timeit -s 'import select; ep = select.epoll(); ep.register(1, select.EPOLLOUT)' 'ep.poll()' 100000 loops, best of 3: 4.25 usec per loop With patch: $ ./python -m timeit -s 'import select; ep = select.epoll(); ep.register(1, select.EPOLLOUT)' 'ep.poll()' 100000 loops, best of 3: 3.38 usec per loop ---------- components: Extension Modules files: epoll_realloc.diff keywords: needs review, patch messages: 179167 nosy: neologix priority: normal severity: normal stage: patch review status: open title: epoll: reuse epoll_event buffer instead of allocating a new one at each poll() type: performance versions: Python 3.4 Added file: http://bugs.python.org/file28585/epoll_realloc.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16876> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com