ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.101 by root, Sun Apr 27 19:36:55 2008 UTC vs.
Revision 1.103 by root, Tue Apr 29 07:15:49 2008 UTC

1071file descriptor is dup()ed for each watcher. This shows that the dup() 1071file descriptor is dup()ed for each watcher. This shows that the dup()
1072employed by some adaptors is not a big performance issue (it does incur a 1072employed by some adaptors is not a big performance issue (it does incur a
1073hidden memory cost inside the kernel which is not reflected in the figures 1073hidden memory cost inside the kernel which is not reflected in the figures
1074above). 1074above).
1075 1075
1076C<POE>, regardless of underlying event loop (whether using its pure 1076C<POE>, regardless of underlying event loop (whether using its pure perl
1077perl select-based backend or the Event module, the POE-EV backend 1077select-based backend or the Event module, the POE-EV backend couldn't
1078couldn't be tested because it wasn't working) shows abysmal performance 1078be tested because it wasn't working) shows abysmal performance and
1079and memory usage: Watchers use almost 30 times as much memory as 1079memory usage with AnyEvent: Watchers use almost 30 times as much memory
1080EV watchers, and 10 times as much memory as Event (the high memory 1080as EV watchers, and 10 times as much memory as Event (the high memory
1081requirements are caused by requiring a session for each watcher). Watcher 1081requirements are caused by requiring a session for each watcher). Watcher
1082invocation speed is almost 900 times slower than with AnyEvent's pure perl 1082invocation speed is almost 900 times slower than with AnyEvent's pure perl
1083implementation.
1084
1083implementation. The design of the POE adaptor class in AnyEvent can not 1085The design of the POE adaptor class in AnyEvent can not really account
1084really account for this, as session creation overhead is small compared 1086for the performance issues, though, as session creation overhead is
1085to execution of the state machine, which is coded pretty optimally within 1087small compared to execution of the state machine, which is coded pretty
1086L<AnyEvent::Impl::POE>. POE simply seems to be abysmally slow. 1088optimally within L<AnyEvent::Impl::POE> (and while everybody agrees that
1089using multiple sessions is not a good approach, especially regarding
1090memory usage, even the author of POE could not come up with a faster
1091design).
1087 1092
1088=head3 Summary 1093=head3 Summary
1089 1094
1090=over 4 1095=over 4
1091 1096
1170 1175
1171=head3 Summary 1176=head3 Summary
1172 1177
1173=over 4 1178=over 4
1174 1179
1175=item * The pure perl implementation performs extremely well, considering 1180=item * The pure perl implementation performs extremely well.
1176that it uses select.
1177 1181
1178=item * Avoid Glib or POE in large projects where performance matters. 1182=item * Avoid Glib or POE in large projects where performance matters.
1179 1183
1180=back 1184=back
1181 1185
1210speed most when you have lots of watchers, not when you only have a few of 1214speed most when you have lots of watchers, not when you only have a few of
1211them). 1215them).
1212 1216
1213EV is again fastest. 1217EV is again fastest.
1214 1218
1215The C-based event loops Event and Glib come in second this time, as the 1219Perl again comes second. It is noticably faster than the C-based event
1216overhead of running an iteration is much smaller in C than in Perl (little 1220loops Event and Glib, although the difference is too small to really
1217code to execute in the inner loop, and perl's function calling overhead is 1221matter.
1218high, and updating all the data structures is costly).
1219
1220The pure perl event loop is much slower, but still competitive.
1221 1222
1222POE also performs much better in this case, but is is still far behind the 1223POE also performs much better in this case, but is is still far behind the
1223others. 1224others.
1224 1225
1225=head3 Summary 1226=head3 Summary

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines