I use the regular Parallel::ForkManager module in Perl. I execute around 10 children processes. 'passes_thresholds' function take few milliseconds or nanoseconds (checked it). In case i run all processes one by one (without Parallel::ForkManager) the whole process took 80-250 milliseconds. In case i run them as parallel, the whole process takes at lease 1 second. I found that the Fork spend 1 second to start the 'finish' function. I put a timer when the child process finished his job and should go to 'finish' function. One second is too much for my development.
sub parallel_execute {
my $this = shift;
foreach my $a (@a_array) {
my $pid = $this->{fork_manager}->start and next;
my $res = $a->passes_thresholds();
$a->{timer} = Benchmark::Timer->new();
$svc->{timer}->start;
$this->{fork_manager}->finish(0,{a => $a, plugin_result => $re
+s});
}
}
$this->{fork_manager}->run_on_finish( sub {
my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_stru
+cture_reference) = @_;
my $a = $data_structure_reference->{a};
if (exists $a->{timer}) {
$a->{timer}->stop;
debug "took: " . $a->{timer}->report;
}
});
Do you have any idea why it took at least 1 second to start the 'finish' command?
(I am using Unix server, and perl 5.10)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.