… | |
… | |
499 | 0.1ms) and so on. The biggest issue is fork races, however - if a program |
499 | 0.1ms) and so on. The biggest issue is fork races, however - if a program |
500 | forks then I<both> parent and child process have to recreate the epoll |
500 | forks then I<both> parent and child process have to recreate the epoll |
501 | set, which can take considerable time (one syscall per file descriptor) |
501 | set, which can take considerable time (one syscall per file descriptor) |
502 | and is of course hard to detect. |
502 | and is of course hard to detect. |
503 | |
503 | |
504 | Epoll is also notoriously buggy - embedding epoll fds I<should> work, but |
504 | Epoll is also notoriously buggy - embedding epoll fds I<should> work, |
505 | of course I<doesn't>, and epoll just loves to report events for totally |
505 | but of course I<doesn't>, and epoll just loves to report events for |
506 | I<different> file descriptors (even already closed ones, so one cannot |
506 | totally I<different> file descriptors (even already closed ones, so |
507 | even remove them from the set) than registered in the set (especially |
507 | one cannot even remove them from the set) than registered in the set |
508 | on SMP systems). Libev tries to counter these spurious notifications by |
508 | (especially on SMP systems). Libev tries to counter these spurious |
509 | employing an additional generation counter and comparing that against the |
509 | notifications by employing an additional generation counter and comparing |
510 | events to filter out spurious ones, recreating the set when required. Last |
510 | that against the events to filter out spurious ones, recreating the set |
|
|
511 | when required. Epoll also errornously rounds down timeouts, but gives you |
|
|
512 | no way to know when and by how much, so sometimes you have to busy-wait |
|
|
513 | because epoll returns immediately despite a nonzero timeout. And last |
511 | not least, it also refuses to work with some file descriptors which work |
514 | not least, it also refuses to work with some file descriptors which work |
512 | perfectly fine with C<select> (files, many character devices...). |
515 | perfectly fine with C<select> (files, many character devices...). |
513 | |
516 | |
514 | Epoll is truly the train wreck analog among event poll mechanisms, |
517 | Epoll is truly the train wreck among event poll mechanisms, a frankenpoll, |
515 | a frankenpoll, cobbled together in a hurry, no thought to design or |
518 | cobbled together in a hurry, no thought to design or interaction with |
516 | interaction with others. |
519 | others. Oh, the pain, will it ever stop... |
517 | |
520 | |
518 | While stopping, setting and starting an I/O watcher in the same iteration |
521 | While stopping, setting and starting an I/O watcher in the same iteration |
519 | will result in some caching, there is still a system call per such |
522 | will result in some caching, there is still a system call per such |
520 | incident (because the same I<file descriptor> could point to a different |
523 | incident (because the same I<file descriptor> could point to a different |
521 | I<file description> now), so its best to avoid that. Also, C<dup ()>'ed |
524 | I<file description> now), so its best to avoid that. Also, C<dup ()>'ed |