… | |
… | |
66 | |
66 | |
67 | Of course, if you want lots of policy (this can arguably be somewhat |
67 | Of course, if you want lots of policy (this can arguably be somewhat |
68 | useful) and you want to force your users to use the one and only event |
68 | useful) and you want to force your users to use the one and only event |
69 | model, you should I<not> use this module. |
69 | model, you should I<not> use this module. |
70 | |
70 | |
|
|
71 | #TODO# |
|
|
72 | |
|
|
73 | Net::IRC3 |
|
|
74 | AnyEvent::HTTPD |
|
|
75 | AnyEvent::DNS |
|
|
76 | IO::AnyEvent |
|
|
77 | Net::FPing |
|
|
78 | Net::XMPP2 |
|
|
79 | Coro |
|
|
80 | |
|
|
81 | AnyEvent::IRC |
|
|
82 | AnyEvent::HTTPD |
|
|
83 | AnyEvent::DNS |
|
|
84 | AnyEvent::Handle |
|
|
85 | AnyEvent::Socket |
|
|
86 | AnyEvent::FPing |
|
|
87 | AnyEvent::XMPP |
|
|
88 | AnyEvent::SNMP |
|
|
89 | Coro |
71 | |
90 | |
72 | =head1 DESCRIPTION |
91 | =head1 DESCRIPTION |
73 | |
92 | |
74 | L<AnyEvent> provides an identical interface to multiple event loops. This |
93 | L<AnyEvent> provides an identical interface to multiple event loops. This |
75 | allows module authors to utilise an event loop without forcing module |
94 | allows module authors to utilise an event loop without forcing module |
… | |
… | |
944 | EV/EV 400000 244 0.56 0.46 0.31 EV native interface |
963 | EV/EV 400000 244 0.56 0.46 0.31 EV native interface |
945 | EV/Any 100000 244 2.50 0.46 0.29 EV + AnyEvent watchers |
964 | EV/Any 100000 244 2.50 0.46 0.29 EV + AnyEvent watchers |
946 | CoroEV/Any 100000 244 2.49 0.44 0.29 coroutines + Coro::Signal |
965 | CoroEV/Any 100000 244 2.49 0.44 0.29 coroutines + Coro::Signal |
947 | Perl/Any 100000 513 4.92 0.87 1.12 pure perl implementation |
966 | Perl/Any 100000 513 4.92 0.87 1.12 pure perl implementation |
948 | Event/Event 16000 516 31.88 31.30 0.85 Event native interface |
967 | Event/Event 16000 516 31.88 31.30 0.85 Event native interface |
949 | Event/Any 16000 936 39.17 33.63 1.43 Event + AnyEvent watchers |
968 | Event/Any 16000 590 35.75 31.42 1.08 Event + AnyEvent watchers |
950 | Glib/Any 16000 1357 98.22 12.41 54.00 quadratic behaviour |
969 | Glib/Any 16000 1357 98.22 12.41 54.00 quadratic behaviour |
951 | Tk/Any 2000 1860 26.97 67.98 14.00 SEGV with >> 2000 watchers |
970 | Tk/Any 2000 1860 26.97 67.98 14.00 SEGV with >> 2000 watchers |
952 | POE/Event 2000 6644 108.64 736.02 14.73 via POE::Loop::Event |
971 | POE/Event 2000 6644 108.64 736.02 14.73 via POE::Loop::Event |
953 | POE/Select 2000 6343 94.13 809.12 565.96 via POE::Loop::Select |
972 | POE/Select 2000 6343 94.13 809.12 565.96 via POE::Loop::Select |
954 | |
973 | |
… | |
… | |
958 | well. For example, a select-based event loop (such as the pure perl one) |
977 | well. For example, a select-based event loop (such as the pure perl one) |
959 | can never compete with an event loop that uses epoll when the number of |
978 | can never compete with an event loop that uses epoll when the number of |
960 | file descriptors grows high. In this benchmark, all events become ready at |
979 | file descriptors grows high. In this benchmark, all events become ready at |
961 | the same time, so select/poll-based implementations get an unnatural speed |
980 | the same time, so select/poll-based implementations get an unnatural speed |
962 | boost. |
981 | boost. |
|
|
982 | |
|
|
983 | Also, note that the number of watchers usually has a nonlinear effect on |
|
|
984 | overall speed, that is, creating twice as many watchers doesn't take twice |
|
|
985 | the time - usually it takes longer. This puts event loops tested with a |
|
|
986 | higher number of watchers at a disadvantage. |
|
|
987 | |
|
|
988 | To put the range of results into perspective, consider that on the |
|
|
989 | benchmark machine, handling an event takes roughly 1600 CPU cycles with |
|
|
990 | EV, 3100 CPU cycles with AnyEvent's pure perl loop and almost 3000000 CPU |
|
|
991 | cycles with POE. |
963 | |
992 | |
964 | C<EV> is the sole leader regarding speed and memory use, which are both |
993 | C<EV> is the sole leader regarding speed and memory use, which are both |
965 | maximal/minimal, respectively. Even when going through AnyEvent, it uses |
994 | maximal/minimal, respectively. Even when going through AnyEvent, it uses |
966 | far less memory than any other event loop and is still faster than Event |
995 | far less memory than any other event loop and is still faster than Event |
967 | natively. |
996 | natively. |
… | |
… | |
1043 | distribution. |
1072 | distribution. |
1044 | |
1073 | |
1045 | =head3 Explanation of the columns |
1074 | =head3 Explanation of the columns |
1046 | |
1075 | |
1047 | I<sockets> is the number of sockets, and twice the number of "servers" (as |
1076 | I<sockets> is the number of sockets, and twice the number of "servers" (as |
1048 | eahc server has a read and write socket end). |
1077 | each server has a read and write socket end). |
1049 | |
1078 | |
1050 | I<create> is the time it takes to create a socketpair (which is |
1079 | I<create> is the time it takes to create a socketpair (which is |
1051 | nontrivial) and two watchers: an I/O watcher and a timeout watcher. |
1080 | nontrivial) and two watchers: an I/O watcher and a timeout watcher. |
1052 | |
1081 | |
1053 | I<request>, the most important value, is the time it takes to handle a |
1082 | I<request>, the most important value, is the time it takes to handle a |
… | |
… | |
1123 | =head3 Discussion |
1152 | =head3 Discussion |
1124 | |
1153 | |
1125 | The benchmark tries to test the performance of a typical small |
1154 | The benchmark tries to test the performance of a typical small |
1126 | server. While knowing how various event loops perform is interesting, keep |
1155 | server. While knowing how various event loops perform is interesting, keep |
1127 | in mind that their overhead in this case is usually not as important, due |
1156 | in mind that their overhead in this case is usually not as important, due |
1128 | to the small absolute number of watchers. |
1157 | to the small absolute number of watchers (that is, you need efficiency and |
|
|
1158 | speed most when you have lots of watchers, not when you only have a few of |
|
|
1159 | them). |
1129 | |
1160 | |
1130 | EV is again fastest. |
1161 | EV is again fastest. |
1131 | |
1162 | |
1132 | The C-based event loops Event and Glib come in second this time, as the |
1163 | The C-based event loops Event and Glib come in second this time, as the |
1133 | overhead of running an iteration is much smaller in C than in Perl (little |
1164 | overhead of running an iteration is much smaller in C than in Perl (little |
1134 | code to execute in the inner loop, and perl's function calling overhead is |
1165 | code to execute in the inner loop, and perl's function calling overhead is |
1135 | high, and updating all the data structures is costly). |
1166 | high, and updating all the data structures is costly). |
1136 | |
1167 | |
1137 | The pure perl event loop is much slower, but still competitive. |
1168 | The pure perl event loop is much slower, but still competitive. |
1138 | |
1169 | |
1139 | POE also performs much better in this case, but is is stillf ar behind the |
1170 | POE also performs much better in this case, but is is still far behind the |
1140 | others. |
1171 | others. |
1141 | |
1172 | |
1142 | =head3 Summary |
1173 | =head3 Summary |
1143 | |
1174 | |
1144 | =over 4 |
1175 | =over 4 |