On Sun, Nov 03, 2002 at 02:28:33AM +0800, George Chung wrote:
> I encountered a performance problem in using POE.
> 
> main program
> ------------------
> POE::Component::Server::TCP->new(
> .....
> $wheel = POE::Wheel::Run->new
>                             ( Program     => 'program_b.pl',
>                               StdoutEvent => "event_reply",
>                               StdioFilter => POE::Filter::Line->new(),
>                             );
> 
> .....
> 
> );
> 
> program_b.pl
> ----------------------
> ........
>     $wheel = POE::Wheel::ReadWrite->new
>              ( InputHandle  => \*STDIN,
>                OutputHandle => \*STDOUT,
>                InputEvent   => "event_input",
>                Filter       => POE::Filter::Line->new(),
>              );
> .......
> ----------------------------------------------------------------------------
> -
> 
> A client will connect to the main program by TP connection and send some
> data to it.
> The main program accept the data and fork/exec a program_b to start the job
> processing by POE::Wheel::Run.
> The program_b.pl will use POE::Wheel::ReadWrite to connect the pipe, accept
> data from main program and
> send some data to the main program via the pipe.
> The client will continue to send data until it's finished.

[...]

Program b probably doesn't need to be a POE program, especially if
it's only handling data via STDIN and STDOUT.  For example:

  #!/usr/bin/perl
  # Program B.

  use warnings;
  use strict;
  $| = 1;

  while (<STDIN>) {
    print reverse;
  }
  exit 0;

.... is all you need to process I/O in the child program.

You may be seeing performance problems, especially on startup or
shutdown, because you're using more resources (memory, CPU) than
necessary.  Simplifying the child program (if it's possible) will
probably help.

Please let us know if you need other suggestions.

-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to