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

Comparing libev/ev.3 (file contents):
Revision 1.57 by root, Sat Dec 22 11:49:17 2007 UTC vs.
Revision 1.58 by root, Sat Dec 22 16:53:56 2007 UTC

451.el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4 451.el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4
452.IX Item "EVBACKEND_SELECT (value 1, portable select backend)" 452.IX Item "EVBACKEND_SELECT (value 1, portable select backend)"
453This is your standard \fIselect\fR\|(2) backend. Not \fIcompletely\fR standard, as 453This is your standard \fIselect\fR\|(2) backend. Not \fIcompletely\fR standard, as
454libev tries to roll its own fd_set with no limits on the number of fds, 454libev tries to roll its own fd_set with no limits on the number of fds,
455but if that fails, expect a fairly low limit on the number of fds when 455but if that fails, expect a fairly low limit on the number of fds when
456using this backend. It doesn't scale too well (O(highest_fd)), but its usually 456using this backend. It doesn't scale too well (O(highest_fd)), but its
457the fastest backend for a low number of fds. 457usually the fastest backend for a low number of (low\-numbered :) fds.
458.Sp
459To get good performance out of this backend you need a high amount of
460parallelity (most of the file descriptors should be busy). If you are
461writing a server, you should \f(CW\*(C`accept ()\*(C'\fR in a loop to accept as many
462connections as possible during one iteration. You might also want to have
463a look at \f(CW\*(C`ev_set_io_collect_interval ()\*(C'\fR to increase the amount of
464readyness notifications you get per iteration.
458.ie n .IP """EVBACKEND_POLL"" (value 2, poll backend, available everywhere except on windows)" 4 465.ie n .IP """EVBACKEND_POLL"" (value 2, poll backend, available everywhere except on windows)" 4
459.el .IP "\f(CWEVBACKEND_POLL\fR (value 2, poll backend, available everywhere except on windows)" 4 466.el .IP "\f(CWEVBACKEND_POLL\fR (value 2, poll backend, available everywhere except on windows)" 4
460.IX Item "EVBACKEND_POLL (value 2, poll backend, available everywhere except on windows)" 467.IX Item "EVBACKEND_POLL (value 2, poll backend, available everywhere except on windows)"
461And this is your standard \fIpoll\fR\|(2) backend. It's more complicated than 468And this is your standard \fIpoll\fR\|(2) backend. It's more complicated
462select, but handles sparse fds better and has no artificial limit on the 469than select, but handles sparse fds better and has no artificial
463number of fds you can use (except it will slow down considerably with a 470limit on the number of fds you can use (except it will slow down
464lot of inactive fds). It scales similarly to select, i.e. O(total_fds). 471considerably with a lot of inactive fds). It scales similarly to select,
472i.e. O(total_fds). See the entry for \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR, above, for
473performance tips.
465.ie n .IP """EVBACKEND_EPOLL"" (value 4, Linux)" 4 474.ie n .IP """EVBACKEND_EPOLL"" (value 4, Linux)" 4
466.el .IP "\f(CWEVBACKEND_EPOLL\fR (value 4, Linux)" 4 475.el .IP "\f(CWEVBACKEND_EPOLL\fR (value 4, Linux)" 4
467.IX Item "EVBACKEND_EPOLL (value 4, Linux)" 476.IX Item "EVBACKEND_EPOLL (value 4, Linux)"
468For few fds, this backend is a bit little slower than poll and select, 477For few fds, this backend is a bit little slower than poll and select,
469but it scales phenomenally better. While poll and select usually scale 478but it scales phenomenally better. While poll and select usually scale
470like O(total_fds) where n is the total number of fds (or the highest fd), 479like O(total_fds) where n is the total number of fds (or the highest fd),
471epoll scales either O(1) or O(active_fds). The epoll design has a number 480epoll scales either O(1) or O(active_fds). The epoll design has a number
472of shortcomings, such as silently dropping events in some hard-to-detect 481of shortcomings, such as silently dropping events in some hard-to-detect
473cases and rewiring a syscall per fd change, no fork support and bad 482cases and rewiring a syscall per fd change, no fork support and bad
474support for dup: 483support for dup.
475.Sp 484.Sp
476While stopping, setting and starting an I/O watcher in the same iteration 485While stopping, setting and starting an I/O watcher in the same iteration
477will result in some caching, there is still a syscall per such incident 486will result in some caching, there is still a syscall per such incident
478(because the fd could point to a different file description now), so its 487(because the fd could point to a different file description now), so its
479best to avoid that. Also, \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors might not work 488best to avoid that. Also, \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors might not work
480very well if you register events for both fds. 489very well if you register events for both fds.
481.Sp 490.Sp
482Please note that epoll sometimes generates spurious notifications, so you 491Please note that epoll sometimes generates spurious notifications, so you
483need to use non-blocking I/O or other means to avoid blocking when no data 492need to use non-blocking I/O or other means to avoid blocking when no data
484(or space) is available. 493(or space) is available.
494.Sp
495Best performance from this backend is achieved by not unregistering all
496watchers for a file descriptor until it has been closed, if possible, i.e.
497keep at least one watcher active per fd at all times.
498.Sp
499While nominally embeddeble in other event loops, this feature is broken in
500all kernel versions tested so far.
485.ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4 501.ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4
486.el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4 502.el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4
487.IX Item "EVBACKEND_KQUEUE (value 8, most BSD clones)" 503.IX Item "EVBACKEND_KQUEUE (value 8, most BSD clones)"
488Kqueue deserves special mention, as at the time of this writing, it 504Kqueue deserves special mention, as at the time of this writing, it
489was broken on all BSDs except NetBSD (usually it doesn't work reliably 505was broken on all BSDs except NetBSD (usually it doesn't work reliably
501kernel is more efficient (which says nothing about its actual speed, of 517kernel is more efficient (which says nothing about its actual speed, of
502course). While stopping, setting and starting an I/O watcher does never 518course). While stopping, setting and starting an I/O watcher does never
503cause an extra syscall as with \f(CW\*(C`EVBACKEND_EPOLL\*(C'\fR, it still adds up to 519cause an extra syscall as with \f(CW\*(C`EVBACKEND_EPOLL\*(C'\fR, it still adds up to
504two event changes per incident, support for \f(CW\*(C`fork ()\*(C'\fR is very bad and it 520two event changes per incident, support for \f(CW\*(C`fork ()\*(C'\fR is very bad and it
505drops fds silently in similarly hard-to-detect cases. 521drops fds silently in similarly hard-to-detect cases.
522.Sp
523This backend usually performs well under most conditions.
524.Sp
525While nominally embeddable in other event loops, this doesn't work
526everywhere, so you might need to test for this. And since it is broken
527almost everywhere, you should only use it when you have a lot of sockets
528(for which it usually works), by embedding it into another event loop
529(e.g. \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR) and using it only for
530sockets.
506.ie n .IP """EVBACKEND_DEVPOLL"" (value 16, Solaris 8)" 4 531.ie n .IP """EVBACKEND_DEVPOLL"" (value 16, Solaris 8)" 4
507.el .IP "\f(CWEVBACKEND_DEVPOLL\fR (value 16, Solaris 8)" 4 532.el .IP "\f(CWEVBACKEND_DEVPOLL\fR (value 16, Solaris 8)" 4
508.IX Item "EVBACKEND_DEVPOLL (value 16, Solaris 8)" 533.IX Item "EVBACKEND_DEVPOLL (value 16, Solaris 8)"
509This is not implemented yet (and might never be). 534This is not implemented yet (and might never be, unless you send me an
535implementation). According to reports, \f(CW\*(C`/dev/poll\*(C'\fR only supports sockets
536and is not embeddable, which would limit the usefulness of this backend
537immensely.
510.ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4 538.ie n .IP """EVBACKEND_PORT"" (value 32, Solaris 10)" 4
511.el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4 539.el .IP "\f(CWEVBACKEND_PORT\fR (value 32, Solaris 10)" 4
512.IX Item "EVBACKEND_PORT (value 32, Solaris 10)" 540.IX Item "EVBACKEND_PORT (value 32, Solaris 10)"
513This uses the Solaris 10 event port mechanism. As with everything on Solaris, 541This uses the Solaris 10 event port mechanism. As with everything on Solaris,
514it's really slow, but it still scales very well (O(active_fds)). 542it's really slow, but it still scales very well (O(active_fds)).
515.Sp 543.Sp
516Please note that solaris event ports can deliver a lot of spurious 544Please note that solaris event ports can deliver a lot of spurious
517notifications, so you need to use non-blocking I/O or other means to avoid 545notifications, so you need to use non-blocking I/O or other means to avoid
518blocking when no data (or space) is available. 546blocking when no data (or space) is available.
547.Sp
548While this backend scales well, it requires one system call per active
549file descriptor per loop iteration. For small and medium numbers of file
550descriptors a \*(L"slow\*(R" \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR backend
551might perform better.
519.ie n .IP """EVBACKEND_ALL""" 4 552.ie n .IP """EVBACKEND_ALL""" 4
520.el .IP "\f(CWEVBACKEND_ALL\fR" 4 553.el .IP "\f(CWEVBACKEND_ALL\fR" 4
521.IX Item "EVBACKEND_ALL" 554.IX Item "EVBACKEND_ALL"
522Try all backends (even potentially broken ones that wouldn't be tried 555Try all backends (even potentially broken ones that wouldn't be tried
523with \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). Since this is a mask, you can do stuff such as 556with \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). Since this is a mask, you can do stuff such as
524\&\f(CW\*(C`EVBACKEND_ALL & ~EVBACKEND_KQUEUE\*(C'\fR. 557\&\f(CW\*(C`EVBACKEND_ALL & ~EVBACKEND_KQUEUE\*(C'\fR.
558.Sp
559It is definitely not recommended to use this flag.
525.RE 560.RE
526.RS 4 561.RS 4
527.Sp 562.Sp
528If one or more of these are ored into the flags value, then only these 563If one or more of these are ored into the flags value, then only these
529backends will be tried (in the reverse order as given here). If none are 564backends will be tried (in the reverse order as given here). If none are
755overhead for the actual polling but can deliver many events at once. 790overhead for the actual polling but can deliver many events at once.
756.Sp 791.Sp
757By setting a higher \fIio collect interval\fR you allow libev to spend more 792By setting a higher \fIio collect interval\fR you allow libev to spend more
758time collecting I/O events, so you can handle more events per iteration, 793time collecting I/O events, so you can handle more events per iteration,
759at the cost of increasing latency. Timeouts (both \f(CW\*(C`ev_periodic\*(C'\fR and 794at the cost of increasing latency. Timeouts (both \f(CW\*(C`ev_periodic\*(C'\fR and
760\&\f(CW\*(C`ev_timer\*(C'\fR) will be not affected. Setting this to a non-null bvalue will 795\&\f(CW\*(C`ev_timer\*(C'\fR) will be not affected. Setting this to a non-null value will
761introduce an additional \f(CW\*(C`ev_sleep ()\*(C'\fR call into most loop iterations. 796introduce an additional \f(CW\*(C`ev_sleep ()\*(C'\fR call into most loop iterations.
762.Sp 797.Sp
763Likewise, by setting a higher \fItimeout collect interval\fR you allow libev 798Likewise, by setting a higher \fItimeout collect interval\fR you allow libev
764to spend more time collecting timeouts, at the expense of increased 799to spend more time collecting timeouts, at the expense of increased
765latency (the watcher callback will be called later). \f(CW\*(C`ev_io\*(C'\fR watchers 800latency (the watcher callback will be called later). \f(CW\*(C`ev_io\*(C'\fR watchers

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines