[issue26233] select.epoll.poll() should away calling malloc() each time

STINNER Victor report at bugs.python.org
Thu Jan 28 12:09:05 EST 2016


STINNER Victor added the comment:

> Overallocating by 50% might be overkill here; I wouldn't imagine most users of epoll.poll would use anything but: (...)

See my second message:
"My patch also overallocates the buffer by 50% to avoid calling realloc() to many times. Using the selectors module, maxevents is the number of registered FD. Using asyncio, the number of registered FD changes a lot."

If you use selectors or asyncio, max_events depends on the current number of registered FD and it almost changes at each call to epoll.poll().

asyncio only registers an FD to listen for read events when the application starts to read on this FD. There is also an optimization: it first tries to read bytes in non-blocking mode. It only registers the FD if it receives 0 byte (if recv() fails with a "woud block" error). It's similar for write events.

----------

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


More information about the Python-bugs-list mailing list