in reply to Struggling with fork, waitpid, wait

You could use Parallel::ForkManager, which was designed for such cases.

But are you sure you will get any speed-up with this? If processing a text file is not much work (i.e. just a regex applied to every line for example), your program will spend most of its time waiting for the harddisk. Whether it is doing that in one process or in parallel won't change anything about its speed (if all machines and processes access the same data pool/hard disk)

One way to find out is to let your script run as a single process and measure the time. Then let it run with one single static text (without reload from disk) the same few thousand times. Only the time the second program runs can be reduced by parallelizing.

  • Comment on Re: Struggling with fork, waitpid, wait