Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: No Performance gain with Parallel::ForkManager

by RichardK (Priest)
on Feb 23, 2014 at 17:59 UTC ( #1075899=note: print w/ replies, xml ) Need Help??


in reply to Re^2: No Performance gain with Parallel::ForkManager
in thread No Performance gain with Parallel::ForkManager

There's no need to be quite that verbose as Parallel::ForkManager handles the number of processes for you. So you can write that as :-

... my $pm = Parallel::ForkManager->new($num_of_cores); for my mp3 (@mp3s) { $pm->start and next; do_work($mp3); $pm->finish; } $pm->wait_all_children;


Comment on Re^3: No Performance gain with Parallel::ForkManager
Download Code
Re^4: No Performance gain with Parallel::ForkManager
by McA (Curate) on Feb 23, 2014 at 18:29 UTC

    Hi Richard,

    am I wrong or does your solution fork a child per file found?

    I wanted to give walto a snippet where I show how to spawn as many subprocesses as cores are available and the subprocesses working on a subqueue.

    The verbose code tries to show that the subprocesses iterate over the initially created array in a way that they can "share" (*) this array without doing work twice. Have I overseen something?

    UPDATE: It was an answer to the question "I can not find a simple way to split the loop into 2 (my no of cores) independent subprocesses...".

    Best regards
    McA

    (*) It's a copy in the subprocess.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1075899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-09-20 02:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls