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

Re: Execution hangs on File::Find

by jahero (Pilgrim)
on Dec 04, 2017 at 11:51 UTC ( [id://1204841]=note: print w/replies, xml ) Need Help??


in reply to Execution hangs on File::Find

I have encountered similar behaviour when iterating over rather large directory tree over network, and I believe this *might* help a bit... Although it is hard to say, if your problem is the same, as mine was.
sub Get_FileList{ @files=(); @todel=(); ####### WORKAROUND START my $sloppy = ${^WIN32_SLOPPY_STAT}; ${^WIN32_SLOPPY_STAT} = 1; ####### WORKAROUND END find(sub {push @files,$File::Find::name if (-f $File::Find::name a +nd /\.*$/ and stat($File::Find::name)->mtime > $lastepoch);}, $indir) +; find(sub {push @todel,$File::Find::name if (-d $File::Find::name); + }, $indir); $lastepoch = time; #Update last execution time for the next run $logger->info("New execution time update: $lastepoch."); $proccount = scalar(@files); $logger->info("Found $proccount new files since last run."); ####### REVERT WORKAROUND ${^WIN32_SLOPPY_STAT} = $sloppy; ####### REVERT WORKAROUND END }
See ${^WIN32_SLOPPY_STAT}

Replies are listed 'Best First'.
Re^2: Execution hangs on File::Find
by Dallaylaen (Chaplain) on Dec 04, 2017 at 12:00 UTC
    ++ed the workaround, but I'm wondering whether it's possible to use local ${^WIN32_SLOPPY_STAT} = 1; instead of saving/restoring the value manually?
      It should be possible (might test it in my code later on).
Re^2: Execution hangs on File::Find
by colox (Sexton) on Dec 04, 2017 at 12:00 UTC

    thanks for the share. i quickly tried, however, it didn't make any diff; still stuck on the top directory without logging or throwing anything =(

      Then I guess next step should be testing yout code over smaller directory tree, see if it hangs, and/or where it did spend most of the time.

      I find it hard to believe that File::Find would freeze, although can hardly backup this claim with concrete evidence, so I would probably profile the run (Devel::NYTProf) on something small first.

      Good luck, perhaps someone with more knowledge then humble me shall help.

        hi, after giving it a little more patience to run & wait, you are indeed correct. it is just "S L O W"... but based on the logging (see below), the "overhead" only occurs on the top folder. as you can see from the logs, it took nearly half an hour for it to start traversing the subfolder. i wonder if any other optimization i can do?..

        04-12-2017 05:00:33:917 DEBUG Reached Z: 04-12-2017 05:09:56:199 DEBUG Reached Z:A6C335 04-12-2017 05:09:57:820 DEBUG Reached Z:A6C335/A6C335.4.12 04-12-2017 05:09:58:001 DEBUG Reached Z:A6C335/A6C335.5.09 04-12-2017 05:09:58:182 DEBUG Reached Z:A6C335/A6C335.5.10
      What does "dir maped" return from cmd Exe?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-04-23 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found