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

Comparing AnyEvent-Fork/Fork.pm (file contents):
Revision 1.42 by root, Mon Apr 8 05:44:23 2013 UTC vs.
Revision 1.43 by root, Thu Apr 18 10:47:48 2013 UTC

34This module only creates processes and lets you pass file handles and 34This module only creates processes and lets you pass file handles and
35strings to it, and run perl code. It does not implement any kind of RPC - 35strings to it, and run perl code. It does not implement any kind of RPC -
36there is no back channel from the process back to you, and there is no RPC 36there is no back channel from the process back to you, and there is no RPC
37or message passing going on. 37or message passing going on.
38 38
39If you need some form of RPC, you can either implement it yourself 39If you need some form of RPC, you could use the L<AnyEvent::Fork::RPC>
40in whatever way you like, use some message-passing module such 40companion module, which adds simple RPC/job queueing to a process created
41as L<AnyEvent::MP>, some pipe such as L<AnyEvent::ZeroMQ>, use 41by this module.
42L<AnyEvent::Handle> on both sides to send e.g. JSON or Storable messages, 42
43and so on. 43Or you can implement it yourself in whatever way you like, use some
44message-passing module such as L<AnyEvent::MP>, some pipe such as
45L<AnyEvent::ZeroMQ>, use L<AnyEvent::Handle> on both sides to send
46e.g. JSON or Storable messages, and so on.
44 47
45=head2 COMPARISON TO OTHER MODULES 48=head2 COMPARISON TO OTHER MODULES
46 49
47There is an abundance of modules on CPAN that do "something fork", such as 50There is an abundance of modules on CPAN that do "something fork", such as
48L<Parallel::ForkManager>, L<AnyEvent::ForkManager>, L<AnyEvent::Worker> 51L<Parallel::ForkManager>, L<AnyEvent::ForkManager>, L<AnyEvent::Worker>
371use AnyEvent::Util (); 374use AnyEvent::Util ();
372 375
373use IO::FDPass; 376use IO::FDPass;
374 377
375our $VERSION = 0.6; 378our $VERSION = 0.6;
376
377=over 4
378
379=back
380
381=cut
382 379
383# the early fork template process 380# the early fork template process
384our $EARLY; 381our $EARLY;
385 382
386# the empty template process 383# the empty template process
804So how can C<< AnyEvent->new >> be faster than a standard fork, even 801So how can C<< AnyEvent->new >> be faster than a standard fork, even
805though it uses the same operations, but adds a lot of overhead? 802though it uses the same operations, but adds a lot of overhead?
806 803
807The difference is simply the process size: forking the 5MB process takes 804The difference is simply the process size: forking the 5MB process takes
808so much longer than forking the 2.5MB template process that the extra 805so much longer than forking the 2.5MB template process that the extra
809overhead introduced is canceled out. 806overhead is canceled out.
810 807
811If the benchmark process grows, the normal fork becomes even slower: 808If the benchmark process grows, the normal fork becomes even slower:
812 809
813 1340 new processes, manual fork of a 20MB process 810 1340 new processes, manual fork of a 20MB process
814 731 new processes, manual fork of a 200MB process 811 731 new processes, manual fork of a 200MB process
913 910
914L<AnyEvent::Fork::Early> (to avoid executing a perl interpreter), 911L<AnyEvent::Fork::Early> (to avoid executing a perl interpreter),
915L<AnyEvent::Fork::Template> (to create a process by forking the main 912L<AnyEvent::Fork::Template> (to create a process by forking the main
916program at a convenient time). 913program at a convenient time).
917 914
918=head1 AUTHOR 915=head1 AUTHOR AND CONTACT INFORMATION
919 916
920 Marc Lehmann <schmorp@schmorp.de> 917 Marc Lehmann <schmorp@schmorp.de>
921 http://home.schmorp.de/ 918 http://software.schmorp.de/pkg/AnyEvent-Fork
922 919
923=cut 920=cut
924 921
9251 9221
926 923

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines