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

Comparing libev/ev.pod (file contents):
Revision 1.154 by root, Sun May 11 11:47:27 2008 UTC vs.
Revision 1.155 by root, Mon May 19 13:48:20 2008 UTC

336To get good performance out of this backend you need a high amount of 336To get good performance out of this backend you need a high amount of
337parallelity (most of the file descriptors should be busy). If you are 337parallelity (most of the file descriptors should be busy). If you are
338writing a server, you should C<accept ()> in a loop to accept as many 338writing a server, you should C<accept ()> in a loop to accept as many
339connections as possible during one iteration. You might also want to have 339connections as possible during one iteration. You might also want to have
340a look at C<ev_set_io_collect_interval ()> to increase the amount of 340a look at C<ev_set_io_collect_interval ()> to increase the amount of
341readyness notifications you get per iteration. 341readiness notifications you get per iteration.
342 342
343=item C<EVBACKEND_POLL> (value 2, poll backend, available everywhere except on windows) 343=item C<EVBACKEND_POLL> (value 2, poll backend, available everywhere except on windows)
344 344
345And this is your standard poll(2) backend. It's more complicated 345And this is your standard poll(2) backend. It's more complicated
346than select, but handles sparse fds better and has no artificial 346than select, but handles sparse fds better and has no artificial
425While this backend scales well, it requires one system call per active 425While this backend scales well, it requires one system call per active
426file descriptor per loop iteration. For small and medium numbers of file 426file descriptor per loop iteration. For small and medium numbers of file
427descriptors a "slow" C<EVBACKEND_SELECT> or C<EVBACKEND_POLL> backend 427descriptors a "slow" C<EVBACKEND_SELECT> or C<EVBACKEND_POLL> backend
428might perform better. 428might perform better.
429 429
430On the positive side, ignoring the spurious readyness notifications, this 430On the positive side, ignoring the spurious readiness notifications, this
431backend actually performed to specification in all tests and is fully 431backend actually performed to specification in all tests and is fully
432embeddable, which is a rare feat among the OS-specific backends. 432embeddable, which is a rare feat among the OS-specific backends.
433 433
434=item C<EVBACKEND_ALL> 434=item C<EVBACKEND_ALL>
435 435
1032If you must do this, then force the use of a known-to-be-good backend 1032If you must do this, then force the use of a known-to-be-good backend
1033(at the time of this writing, this includes only C<EVBACKEND_SELECT> and 1033(at the time of this writing, this includes only C<EVBACKEND_SELECT> and
1034C<EVBACKEND_POLL>). 1034C<EVBACKEND_POLL>).
1035 1035
1036Another thing you have to watch out for is that it is quite easy to 1036Another thing you have to watch out for is that it is quite easy to
1037receive "spurious" readyness notifications, that is your callback might 1037receive "spurious" readiness notifications, that is your callback might
1038be called with C<EV_READ> but a subsequent C<read>(2) will actually block 1038be called with C<EV_READ> but a subsequent C<read>(2) will actually block
1039because there is no data. Not only are some backends known to create a 1039because there is no data. Not only are some backends known to create a
1040lot of those (for example solaris ports), it is very easy to get into 1040lot of those (for example solaris ports), it is very easy to get into
1041this situation even with a relatively standard program structure. Thus 1041this situation even with a relatively standard program structure. Thus
1042it is best to always use non-blocking I/O: An extra C<read>(2) returning 1042it is best to always use non-blocking I/O: An extra C<read>(2) returning
1657calls your callback, which does something. When there is another update 1657calls your callback, which does something. When there is another update
1658within the same second, C<ev_stat> will be unable to detect it as the stat 1658within the same second, C<ev_stat> will be unable to detect it as the stat
1659data does not change. 1659data does not change.
1660 1660
1661The solution to this is to delay acting on a change for slightly more 1661The solution to this is to delay acting on a change for slightly more
1662than second (or till slightly after the next full second boundary), using 1662than a second (or till slightly after the next full second boundary), using
1663a roughly one-second-delay C<ev_timer> (e.g. C<ev_timer_set (w, 0., 1.02); 1663a roughly one-second-delay C<ev_timer> (e.g. C<ev_timer_set (w, 0., 1.02);
1664ev_timer_again (loop, w)>). 1664ev_timer_again (loop, w)>).
1665 1665
1666The C<.02> offset is added to work around small timing inconsistencies 1666The C<.02> offset is added to work around small timing inconsistencies
1667of some operating systems (where the second counter of the current time 1667of some operating systems (where the second counter of the current time
3003 3003
3004=item EV_USE_4HEAP 3004=item EV_USE_4HEAP
3005 3005
3006Heaps are not very cache-efficient. To improve the cache-efficiency of the 3006Heaps are not very cache-efficient. To improve the cache-efficiency of the
3007timer and periodics heap, libev uses a 4-heap when this symbol is defined 3007timer and periodics heap, libev uses a 4-heap when this symbol is defined
3008to C<1>. The 4-heap uses more complicated (longer) code but has a 3008to C<1>. The 4-heap uses more complicated (longer) code but has
3009noticable after performance with many (thousands) of watchers. 3009noticably faster performance with many (thousands) of watchers.
3010 3010
3011The default is C<1> unless C<EV_MINIMAL> is set in which case it is C<0> 3011The default is C<1> unless C<EV_MINIMAL> is set in which case it is C<0>
3012(disabled). 3012(disabled).
3013 3013
3014=item EV_HEAP_CACHE_AT 3014=item EV_HEAP_CACHE_AT
3015 3015
3016Heaps are not very cache-efficient. To improve the cache-efficiency of the 3016Heaps are not very cache-efficient. To improve the cache-efficiency of the
3017timer and periodics heap, libev can cache the timestamp (I<at>) within 3017timer and periodics heap, libev can cache the timestamp (I<at>) within
3018the heap structure (selected by defining C<EV_HEAP_CACHE_AT> to C<1>), 3018the heap structure (selected by defining C<EV_HEAP_CACHE_AT> to C<1>),
3019which uses 8-12 bytes more per watcher and a few hundred bytes more code, 3019which uses 8-12 bytes more per watcher and a few hundred bytes more code,
3020but avoids random read accesses on heap changes. This noticably improves 3020but avoids random read accesses on heap changes. This improves performance
3021performance noticably with with many (hundreds) of watchers. 3021noticably with with many (hundreds) of watchers.
3022 3022
3023The default is C<1> unless C<EV_MINIMAL> is set in which case it is C<0> 3023The default is C<1> unless C<EV_MINIMAL> is set in which case it is C<0>
3024(disabled). 3024(disabled).
3025 3025
3026=item EV_COMMON 3026=item EV_COMMON
3251 3251
3252Due to the many, low, and arbitrary limits on the win32 platform and 3252Due to the many, low, and arbitrary limits on the win32 platform and
3253the abysmal performance of winsockets, using a large number of sockets 3253the abysmal performance of winsockets, using a large number of sockets
3254is not recommended (and not reasonable). If your program needs to use 3254is not recommended (and not reasonable). If your program needs to use
3255more than a hundred or so sockets, then likely it needs to use a totally 3255more than a hundred or so sockets, then likely it needs to use a totally
3256different implementation for windows, as libev offers the POSIX readyness 3256different implementation for windows, as libev offers the POSIX readiness
3257notification model, which cannot be implemented efficiently on windows 3257notification model, which cannot be implemented efficiently on windows
3258(microsoft monopoly games). 3258(microsoft monopoly games).
3259 3259
3260=over 4 3260=over 4
3261 3261

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines