Am using Parallel::ForkManager using ActiveState Perl 5.10.1 (1006) on Vista Home Premium SP1 and have been getting something rather strange happen.
When initiated in "debug"
my $pm = new Parallel::ForkManager(0);
the code runs in about 11 seconds to run - but if I tell it to run any number of instances (including 1)
my $pm = new Parallel::ForkManager(1); my $pm = new Parallel::ForkManager(5);
then the run time INCREASES ("1" takes seconds and "5" takes many hours to run) rather than the expected decrease (given that I'm running the code on a quad core system doing naff all otherwise ... and the Windows Performance Monitor suggests that the other cores come alive as expected).
Which suggests that I'm doing summat odd - but I've tried to implement code that is based on reference model provided in the ForkManager documentation.
sub scoring { return 1; } my @results = (); $pm->run_on_finish( sub { my ($pid, $exit_code, $ident ) = @_; $results[$ident] = $exit_code; } ); for ( my $i = 0; $i < 1000000; $i++ ) { my $pid = $pm->start($i) and next; my $result = scoring(); $pm->finish($result); } $pm->wait_all_children;
This is cut down PoC code - the real version does much more processing in the child, but the runtime issue is the same... massively increased run-time when actually forking.
Any ideas ?
In reply to ForkManager Running Real Slow by zacc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |