zacc has asked for the wisdom of the Perl Monks concerning the following question:
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 ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ForkManager Running Real Slow
by BrowserUk (Patriarch) on Sep 03, 2009 at 22:36 UTC | |
by SuicideJunkie (Vicar) on Sep 04, 2009 at 13:28 UTC | |
by BrowserUk (Patriarch) on Sep 04, 2009 at 14:02 UTC | |
by SuicideJunkie (Vicar) on Sep 04, 2009 at 14:34 UTC | |
by roboticus (Chancellor) on Sep 04, 2009 at 16:17 UTC | |
|
Re: ForkManager Running Real Slow
by zacc (Novice) on Sep 04, 2009 at 17:18 UTC | |
by BrowserUk (Patriarch) on Sep 04, 2009 at 18:09 UTC |