in reply to No Performance gain with Parallel::ForkManager
Hi,
the execution time of your script without fork is very good. You should make a simple test, how much time is spent for Perl startup. Forking is a relative expensive action. So you have to be sure that it's worth it. In your case it seems to be not. Have a look at Devel::NYTProf to profile your code.
UPDATE: With your forking code you allow up to 50 childs of the main process. This seems to be much too much. The whole task you want to optimize is IO bound (scanning the directory tree, reading in files, writing the files). You don't gain much when many processes are fighting for the same resource. When you just want to optimize in terms of computing power I would allow as much subprocesses as you have CPU cores in your computer.
It would be interesting to test the following approach: Scan the whole directory tree and push all found mp3 files on a array (job queue), then split the queue into N parts (N = number of cores) and start N subprocesses working on their subqueue. In this case you do only fork once per subqueue and not for every file (which is expensive).
Best regards
McA
|
|---|