… | |
… | |
384 | =item C<EVBACKEND_EPOLL> (value 4, Linux) |
384 | =item C<EVBACKEND_EPOLL> (value 4, Linux) |
385 | |
385 | |
386 | For few fds, this backend is a bit little slower than poll and select, |
386 | For few fds, this backend is a bit little slower than poll and select, |
387 | but it scales phenomenally better. While poll and select usually scale |
387 | but it scales phenomenally better. While poll and select usually scale |
388 | like O(total_fds) where n is the total number of fds (or the highest fd), |
388 | like O(total_fds) where n is the total number of fds (or the highest fd), |
389 | epoll scales either O(1) or O(active_fds). The epoll design has a number |
389 | epoll scales either O(1) or O(active_fds). |
390 | of shortcomings, such as silently dropping events in some hard-to-detect |
390 | |
391 | cases and requiring a system call per fd change, no fork support and bad |
391 | The epoll syscalls are the most misdesigned of the more advanced |
392 | support for dup. |
392 | event mechanisms: probelsm include silently dropping events in some |
|
|
393 | hard-to-detect cases, requiring a system call per fd change, no fork |
|
|
394 | support, problems with dup and so on. |
393 | |
395 | |
394 | Epoll is also notoriously buggy - embedding epoll fds should work, but |
396 | Epoll is also notoriously buggy - embedding epoll fds should work, but |
395 | of course doesn't, and epoll just loves to report events for totally |
397 | of course doesn't, and epoll just loves to report events for totally |
396 | I<different> file descriptors (even already closed ones) than registered |
398 | I<different> file descriptors (even already closed ones, so one cannot |
397 | in the set (especially on SMP systems). Libev tries to counter these |
399 | even remove them from the set) than registered in the set (especially |
398 | spurious notifications by employing an additional generation counter and |
400 | on SMP systems). Libev tries to counter these spurious notifications by |
399 | comparing that against the events to filter out spurious ones. |
401 | employing an additional generation counter and comparing that against the |
|
|
402 | events to filter out spurious ones. |
400 | |
403 | |
401 | While stopping, setting and starting an I/O watcher in the same iteration |
404 | While stopping, setting and starting an I/O watcher in the same iteration |
402 | will result in some caching, there is still a system call per such incident |
405 | will result in some caching, there is still a system call per such incident |
403 | (because the fd could point to a different file description now), so its |
406 | (because the fd could point to a different file description now), so its |
404 | best to avoid that. Also, C<dup ()>'ed file descriptors might not work |
407 | best to avoid that. Also, C<dup ()>'ed file descriptors might not work |