1 | libev is modelled after libevent (http://monkey.org/~provos/libevent/), but aims |
1 | libev is a high-performanc3 event loop/event model with lots of features. |
|
|
2 | |
|
|
3 | It is modelled (very losely) after libevent |
|
|
4 | (http://monkey.org/~provos/libevent/) and the Event perl module, but aims |
2 | to be faster and more correct, and also more featureful. Examples: |
5 | to be faster and more correct, and also more featureful. |
|
|
6 | |
|
|
7 | DIFFERENCES AND COMPARISON TO LIBEVENT: |
3 | |
8 | |
4 | (comparisons relative to libevent-1.3e and libev-0.00) |
9 | (comparisons relative to libevent-1.3e and libev-0.00) |
5 | |
10 | |
6 | - multiple watchers can wait for the same event without deregistering others, |
11 | - multiple watchers can wait for the same event without deregistering others, |
7 | both for file descriptors as well as signals. |
12 | both for file descriptors as well as signals. |
8 | (registering two read events on fd 10 and unregistering one will not |
13 | (registering two read events on fd 10 and unregistering one will not |
9 | break the other) |
14 | break the other). |
10 | |
15 | |
11 | - fork() is supported and can be handled |
16 | - fork() is supported and can be handled |
12 | (there is no way to recover from a fork when libevent is active) |
17 | (there is no way to recover from a fork when libevent is active). |
13 | |
18 | |
14 | - timers are handled as a priority queue (important operations are O(1)) |
19 | - timers are handled as a priority queue (important operations are O(1)) |
15 | (libevent uses a much less efficient but more complex red-black tree) |
20 | (libevent uses a much less efficient but more complex red-black tree). |
16 | |
21 | |
17 | - supports absolute (wallclock-based) timers in addition to relative ones, |
22 | - supports absolute (wallclock-based) timers in addition to relative ones, |
18 | i.e. can schedule timers to occur after n seconds, or at a specific time. |
23 | i.e. can schedule timers to occur after n seconds, or at a specific time. |
19 | |
24 | |
20 | - timers can be repeating (both absolute and relative ones) |
25 | - timers can be repeating (both absolute and relative ones). |
21 | |
26 | |
22 | - detects time jumps and adjusts timers |
27 | - detects time jumps and adjusts timers |
23 | (works for both forward and backward time jumps and also for absolute timers) |
28 | (works for both forward and backward time jumps and also for absolute timers). |
24 | |
29 | |
25 | - can correctly remove timers while executing callbacks |
30 | - can correctly remove timers while executing callbacks |
26 | (libevent doesn't handle this reliably and can crash) |
31 | (libevent doesn't handle this reliably and can crash). |
27 | |
32 | |
28 | - race-free signal processing |
33 | - race-free signal processing |
29 | (libevent may delay processing signals till after the next event) |
34 | (libevent may delay processing signals till after the next event). |
30 | |
35 | |
31 | - less calls to epoll_ctl |
36 | - less calls to epoll_ctl |
32 | (stopping and starting an io watcher between two loop iterations will now |
37 | (stopping and starting an io watcher between two loop iterations will now |
33 | result in spuriois epoll_ctl calls) |
38 | result in spuriois epoll_ctl calls). |
34 | |
39 | |
35 | - usually less calls to gettimeofday and clock_gettime |
40 | - usually less calls to gettimeofday and clock_gettime |
36 | (libevent calls it on every timer event change, libev twice per iteration) |
41 | (libevent calls it on every timer event change, libev twice per iteration). |
37 | |
42 | |
38 | - watchers use less memory |
43 | - watchers use less memory |
39 | (libevent on amd64: 152 bytes, libev: <= 56 bytes) |
44 | (libevent on amd64: 152 bytes, libev: <= 56 bytes). |
40 | |
45 | |
41 | - library uses less memory |
46 | - library uses less memory |
42 | (libevent allocates large data structures wether used or not, libev |
47 | (libevent allocates large data structures wether used or not, libev |
43 | scales all its data structures dynamically) |
48 | scales all its data structures dynamically). |
44 | |
49 | |
45 | - no hardcoded arbitrary limits |
50 | - no hardcoded arbitrary limits |
46 | (libevent contains an off-by-one bug and sometimes hardcodes a limit of |
51 | (libevent contains an off-by-one bug and sometimes hardcodes a limit of |
47 | 32000 fds) |
52 | 32000 fds). |
48 | |
53 | |
49 | - libev separates timer, signal and io watchers from each other |
54 | - libev separates timer, signal and io watchers from each other |
50 | (libevent combines them, but with libev you can combine them yourself |
55 | (libevent combines them, but with libev you can combine them yourself |
51 | by reusing the same callback and still save memory) |
56 | by reusing the same callback and still save memory). |
52 | |
57 | |
53 | - simpler design, backends are potentially much simpler |
58 | - simpler design, backends are potentially much simpler |
54 | (in libevent, backends have to deal with watchers, thus the problems) |
59 | (in libevent, backends have to deal with watchers, thus the problems) |
55 | (epoll backend in libevent: 366 lines, libev: 90 lines, and more features) |
60 | (epoll backend in libevent: 366 lines, libev: 90 lines, and more features). |
56 | |
61 | |
57 | - libev handles EBADF gracefully by removing the offending fds. |
62 | - libev handles EBADF gracefully by removing the offending fds. |
58 | |
63 | |
|
|
64 | - doesn't rely on nonportable BSD header files. |
|
|
65 | |
|
|
66 | - a event.h compatibility header exists, and can be used to run a wide |
|
|
67 | range of libevent programs unchanged (such as evdns.c). |
|
|
68 | |
59 | whats missing? |
69 | whats missing? |
60 | |
70 | |
61 | - evdns, evhttp, bufferevent are missing, libev is only an even library at |
71 | - evbuffer, evhttp, bufferevent are missing. |
62 | the moment. |
|
|
63 | |
72 | |
64 | - no priority support at the moment |
73 | - no priority support at the moment (but likely to be delivered later). |
65 | |
74 | |
66 | - kqueue, poll (libev currently implements epoll and select) |
75 | - kqueue, poll (libev currently implements epoll and select). |
67 | |
76 | |
68 | - windows support (whats windows?) |
77 | - windows support (whats windows?). |
69 | |
78 | |