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