Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^6: Script exponentially slower as number of files to process increases

by kikuchiyo (Hermit)
on Jan 28, 2023 at 17:44 UTC ( #11149987=note: print w/replies, xml ) Need Help??


in reply to Re^5: Script exponentially slower as number of files to process increases
in thread Script exponentially slower as number of files to process increases

You could run the script with strace -o /tmp/trace -ff -e trace=%file script.pl to see why the file opens fail.
  • Comment on Re^6: Script exponentially slower as number of files to process increases
  • Download Code

Replies are listed 'Best First'.
Re^7: Script exponentially slower as number of files to process increases
by marioroy (Parson) on Jan 28, 2023 at 18:38 UTC

    For the kikuchiyo.pl script, the fix is initializing subdircount to maxforks - 1. That ensures safety, as each worker sets $i using the same range (starting at 0).

    my $subdircount = $maxforks - 1;

    Update: Added results for threads and MCE::Child.

    Running with 512 workers:

    For cpu-bound task, there's no reason to run many-many workers; beyond physical limitation.

      Ran some more tests, your latest mceiter2.pl script is consistently faster (albeit by a small margin) than fork.pl, however the run time includes the output file merging which is a measurable gain.

        So nice of you to write back. That script you linked to is quite efficient, considering it factors out entirely the manager process having to merge (now handled by the workers, cooperatively).

Re^7: Script exponentially slower as number of files to process increases
by xnous (Sexton) on Jan 28, 2023 at 17:55 UTC
    Because $subdir doesn't reset to 0 after the 256th fork as in the OP script, which is incidentally the $subdircount value.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (1)
As of 2023-03-31 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (74 votes). Check out past polls.

    Notices?