This is about Parallel::ForkManager on 64 bit strawberryperl.
I need to process 1000s of images. Each totally independent of the others.
Processing has CPU intensive parts, and parts that hardly use the CPU, but the GPU instead. The hardware has 8 cores, so I think of 8 processes? Each process to start multi-thread programs.
Each image is of different size, and I know the processing time is different according to it. Therefore processes should run a different length.
If a process is finished, a new process should start. To always have 8 processes.
This should level the CPU usage after a few rounds due to the different time each process runs. But it doesn't.
Looking at the Windows 8 Resource Monitor I see that all 8 processes run perfectly synchronized even after a long time.
It looks like 8 process are started, then only after all 8 are finished 8 new processes are started?
Code is straight from: http://search.cpan.org/~szabgab/Parallel-ForkManager-1.06/lib/Parallel/ForkManager.pm
use Parallel::ForkManager; ... @links=( ["http://www.foo.bar/rulez.data","rulez_data.txt"], ["http://new.host/more_data.doc","more_data.doc"], ... ); ... # Max 30 processes for parallel download my $pm = Parallel::ForkManager->new(30); foreach my $linkarray (@links) { $pm->start and next; # do the fork my ($link,$fn) = @$linkarray; warn "Cannot get $fn from $link" if getstore($link,$fn) != RC_OK; $pm->finish; # do the exit in the child process } $pm->wait_all_children;
In reply to Parallel::ForkManager and CPU usage? by janmartin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |