ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.202 by root, Fri Oct 24 08:30:01 2008 UTC vs.
Revision 1.205 by root, Mon Oct 27 12:20:32 2008 UTC

384=item C<EVBACKEND_EPOLL> (value 4, Linux) 384=item C<EVBACKEND_EPOLL> (value 4, Linux)
385 385
386For few fds, this backend is a bit little slower than poll and select, 386For few fds, this backend is a bit little slower than poll and select,
387but it scales phenomenally better. While poll and select usually scale 387but it scales phenomenally better. While poll and select usually scale
388like O(total_fds) where n is the total number of fds (or the highest fd), 388like O(total_fds) where n is the total number of fds (or the highest fd),
389epoll scales either O(1) or O(active_fds). The epoll design has a number 389epoll scales either O(1) or O(active_fds).
390of shortcomings, such as silently dropping events in some hard-to-detect 390
391cases and requiring a system call per fd change, no fork support and bad 391The epoll syscalls are the most misdesigned of the more advanced
392support for dup. 392event mechanisms: probelsm include silently dropping events in some
393hard-to-detect cases, requiring a system call per fd change, no fork
394support, problems with dup and so on.
395
396Epoll is also notoriously buggy - embedding epoll fds should work, but
397of course doesn't, and epoll just loves to report events for totally
398I<different> file descriptors (even already closed ones, so one cannot
399even remove them from the set) than registered in the set (especially
400on SMP systems). Libev tries to counter these spurious notifications by
401employing an additional generation counter and comparing that against the
402events to filter out spurious ones.
393 403
394While stopping, setting and starting an I/O watcher in the same iteration 404While stopping, setting and starting an I/O watcher in the same iteration
395will result in some caching, there is still a system call per such incident 405will result in some caching, there is still a system call per such incident
396(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
397best to avoid that. Also, C<dup ()>'ed file descriptors might not work 407best to avoid that. Also, C<dup ()>'ed file descriptors might not work
398very well if you register events for both fds. 408very well if you register events for both fds.
399
400Please note that epoll sometimes generates spurious notifications, so you
401need to use non-blocking I/O or other means to avoid blocking when no data
402(or space) is available.
403 409
404Best performance from this backend is achieved by not unregistering all 410Best performance from this backend is achieved by not unregistering all
405watchers for a file descriptor until it has been closed, if possible, 411watchers for a file descriptor until it has been closed, if possible,
406i.e. keep at least one watcher active per fd at all times. Stopping and 412i.e. keep at least one watcher active per fd at all times. Stopping and
407starting a watcher (without re-setting it) also usually doesn't cause 413starting a watcher (without re-setting it) also usually doesn't cause
531responsibility to either stop all watchers cleanly yourself I<before> 537responsibility to either stop all watchers cleanly yourself I<before>
532calling this function, or cope with the fact afterwards (which is usually 538calling this function, or cope with the fact afterwards (which is usually
533the easiest thing, you can just ignore the watchers and/or C<free ()> them 539the easiest thing, you can just ignore the watchers and/or C<free ()> them
534for example). 540for example).
535 541
536Note that certain global state, such as signal state, will not be freed by 542Note that certain global state, such as signal state (and installed signal
537this function, and related watchers (such as signal and child watchers) 543handlers), will not be freed by this function, and related watchers (such
538would need to be stopped manually. 544as signal and child watchers) would need to be stopped manually.
539 545
540In general it is not advisable to call this function except in the 546In general it is not advisable to call this function except in the
541rare occasion where you really need to free e.g. the signal handling 547rare occasion where you really need to free e.g. the signal handling
542pipe fds. If you need dynamically allocated loops it is better to use 548pipe fds. If you need dynamically allocated loops it is better to use
543C<ev_loop_new> and C<ev_loop_destroy>). 549C<ev_loop_new> and C<ev_loop_destroy>).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines