--- AnyEvent/lib/AnyEvent.pm 2008/04/27 19:15:43 1.100 +++ AnyEvent/lib/AnyEvent.pm 2008/04/30 11:40:22 1.104 @@ -68,26 +68,6 @@ useful) and you want to force your users to use the one and only event model, you should I use this module. -#TODO# - -Net::IRC3 -AnyEvent::HTTPD -AnyEvent::DNS -IO::AnyEvent -Net::FPing -Net::XMPP2 -Coro - -AnyEvent::IRC -AnyEvent::HTTPD -AnyEvent::DNS -AnyEvent::Handle -AnyEvent::Socket -AnyEvent::FPing -AnyEvent::XMPP -AnyEvent::SNMP -Coro - =head1 DESCRIPTION L provides an identical interface to multiple event loops. This @@ -412,8 +392,8 @@ AnyEvent::Impl::CoroEvent based on Coro::Event, second best choice. AnyEvent::Impl::EV based on EV (an interface to libev, best choice). AnyEvent::Impl::Event based on Event, second best choice. + AnyEvent::Impl::Perl pure-perl implementation, fast and portable. AnyEvent::Impl::Glib based on Glib, third-best choice. - AnyEvent::Impl::Perl pure-perl implementation, inefficient but portable. AnyEvent::Impl::Tk based on Tk, very bad choice. AnyEvent::Impl::Qt based on Qt, cannot be autoprobed (see its docs). AnyEvent::Impl::EventLib based on Event::Lib, leaks memory and worse. @@ -481,24 +461,74 @@ =head1 OTHER MODULES -L itself comes with useful utility modules: +The following is a non-exhaustive list of additional modules that use +AnyEvent and can therefore be mixed easily with other AnyEvent modules +in the same program. Some of the modules come with AnyEvent, some are +available via CPAN. -To make it easier to do non-blocking IO the modules L -and L are provided. L provides -read and write buffers and manages watchers for reads and writes. -L provides means to do non-blocking connects. +=over 4 -Aside from those there are these modules that support AnyEvent (and use it -for non-blocking IO): +=item L -=over 4 +Contains various utility functions that replace often-used but blocking +functions such as C by event-/callback-based versions. + +=item L + +Provide read and write buffers and manages watchers for reads and writes. + +=item L + +Provides a means to do non-blocking connects, accepts etc. + +=item L + +Provides a simple web application server framework. + +=item L + +Provides asynchronous DNS resolver capabilities, beyond what +L offers. =item L +The fastest ping in the west. + =item L +AnyEvent based IRC client module family. + =item L +AnyEvent based XMPP (Jabber protocol) module family. + +=item L + +AnyEvent-based implementation of the Freenet Client Protocol, birthplace +of AnyEvent. + +=item L + +High level API for event-based execution flow control. + +=item L + +Has special support for AnyEvent. + +=item L + +The lambda approach to I/O - don't ask, look there. Can use AnyEvent. + +=item L + +Truly asynchronous I/O, should be in the toolbox of every event +programmer. Can be trivially made to use AnyEvent. + +=item L + +Truly asynchronous Berkeley DB access. Can be trivially made to use +AnyEvent. + =back =cut @@ -525,12 +555,12 @@ [Coro::Event:: => AnyEvent::Impl::CoroEvent::], [EV:: => AnyEvent::Impl::EV::], [Event:: => AnyEvent::Impl::Event::], - [Glib:: => AnyEvent::Impl::Glib::], [Tk:: => AnyEvent::Impl::Tk::], [Wx:: => AnyEvent::Impl::POE::], [Prima:: => AnyEvent::Impl::POE::], [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], # everything below here will not be autoprobed as the pureperl backend should work everywhere + [Glib:: => AnyEvent::Impl::Glib::], [Event::Lib:: => AnyEvent::Impl::EventLib::], # too buggy [Qt:: => AnyEvent::Impl::Qt::], # requires special main program [POE::Kernel:: => AnyEvent::Impl::POE::], # lasciate ogni speranza @@ -1043,17 +1073,22 @@ hidden memory cost inside the kernel which is not reflected in the figures above). -C, regardless of underlying event loop (whether using its pure -perl select-based backend or the Event module, the POE-EV backend -couldn't be tested because it wasn't working) shows abysmal performance -and memory usage: Watchers use almost 30 times as much memory as -EV watchers, and 10 times as much memory as Event (the high memory +C, regardless of underlying event loop (whether using its pure perl +select-based backend or the Event module, the POE-EV backend couldn't +be tested because it wasn't working) shows abysmal performance and +memory usage with AnyEvent: Watchers use almost 30 times as much memory +as EV watchers, and 10 times as much memory as Event (the high memory requirements are caused by requiring a session for each watcher). Watcher invocation speed is almost 900 times slower than with AnyEvent's pure perl -implementation. The design of the POE adaptor class in AnyEvent can not -really account for this, as session creation overhead is small compared -to execution of the state machine, which is coded pretty optimally within -L. POE simply seems to be abysmally slow. +implementation. + +The design of the POE adaptor class in AnyEvent can not really account +for the performance issues, though, as session creation overhead is +small compared to execution of the state machine, which is coded pretty +optimally within L (and while everybody agrees that +using multiple sessions is not a good approach, especially regarding +memory usage, even the author of POE could not come up with a faster +design). =head3 Summary @@ -1142,8 +1177,7 @@ =over 4 -=item * The pure perl implementation performs extremely well, considering -that it uses select. +=item * The pure perl implementation performs extremely well. =item * Avoid Glib or POE in large projects where performance matters. @@ -1182,12 +1216,9 @@ EV is again fastest. -The C-based event loops Event and Glib come in second this time, as the -overhead of running an iteration is much smaller in C than in Perl (little -code to execute in the inner loop, and perl's function calling overhead is -high, and updating all the data structures is costly). - -The pure perl event loop is much slower, but still competitive. +Perl again comes second. It is noticably faster than the C-based event +loops Event and Glib, although the difference is too small to really +matter. POE also performs much better in this case, but is is still far behind the others. @@ -1205,7 +1236,8 @@ =head1 FORK Most event libraries are not fork-safe. The ones who are usually are -because they are so inefficient. Only L is fully fork-aware. +because they rely on inefficient but fork-safe C