1 | libev is modelled after libevent (http://monkey.org/~provos/libevent/), but aims |
1 | libev is modelled after libevent (http://monkey.org/~provos/libevent/), but aims |
2 | to be faster and more correct, and also more featureful. Examples: |
2 | to be faster and more correct, and also more featureful. Examples: |
3 | |
3 | |
4 | - multiple watchers can wait for the same event without deregistering others. |
4 | - multiple watchers can wait for the same event without deregistering others. |
5 | - fork() is supported and can be handled. |
5 | (registering two read events on fd 10 and unregistering one will not |
6 | - timers are handled as a priority queue (faster) |
6 | break the other) |
7 | - watchers use less memory (faster) |
|
|
8 | - less calls to epoll_ctl (faster) |
|
|
9 | |
7 | |
|
|
8 | - fork() is supported and can be handled |
|
|
9 | (there is no way to recover from a fork when libevent is active) |
|
|
10 | |
|
|
11 | - timers are handled as a priority queue |
|
|
12 | (libevent uses a less efficient red-black tree) |
|
|
13 | |
|
|
14 | - supports absolute (wallclock-based) timers in addition to relative ones, |
|
|
15 | i.e. can schedule timers to occur after n seconds, or at a specific time. |
|
|
16 | |
|
|
17 | - timers can be repeating (both absolute and relative ones) |
|
|
18 | |
|
|
19 | - detects time jumps and adjusts timers |
|
|
20 | (works for both forward and backward time jumps and also for absolute timers) |
|
|
21 | |
|
|
22 | - can correctly remove timers while executing callbacks |
|
|
23 | (libevent doesn't handle this reliably and can crash) |
|
|
24 | |
|
|
25 | - less calls to epoll_ctl |
|
|
26 | (stopping and starting an io watcher between two loop iterations will now |
|
|
27 | result in spuriois epoll_ctl calls) |
|
|
28 | |
|
|
29 | - usually less calls to gettimeofday and clock_gettime |
|
|
30 | (libevent calls it on every timer event change, libev twice per iteration) |
|
|
31 | |
|
|
32 | - watchers use less memory |
|
|
33 | (libevent on amd64: 152 bytes, libev: <= 56 bytes) |
|
|
34 | |
|
|
35 | - library uses less memory |
|
|
36 | (libevent allocates large data structures wether used or not, libev |
|
|
37 | scales all its data structures dynamically) |
|
|
38 | |
|
|
39 | - no hardcoded arbitrary limits |
|
|
40 | (libevent contains an off-by-one bug and sometimes hardcodes a limit of |
|
|
41 | 32000 fds) |
|
|
42 | |
|
|
43 | - libev separates timer, signal and io watchers from each other |
|
|
44 | (libevent combines them, but with libev you can combine them yourself |
|
|
45 | by reusing the same callback and still save memory) |
|
|
46 | |
|
|
47 | - simpler design, backends are potentially much simpler |
|
|
48 | (in libevent, backends have to deal with watchers, thus the problems) |
|
|
49 | (epoll backend in libevent: 366 lines, libev: 89 lines, and more features) |
|
|
50 | |
|
|
51 | whats missing? |
|
|
52 | |
|
|
53 | - evdns, evhttp, bufferevent are missing, libev is only an even library at |
|
|
54 | the moment. |
|
|
55 | |
|
|
56 | - no priority support at the moment. |
|
|
57 | |
|
|
58 | - kqueue, poll (libev currently implements epoll and select). |
|
|
59 | |