Q about Coro file::find

Aleksandar Lazic al-anyevent at none.at
Wed Feb 1 11:27:09 CET 2012


Hi,

On 31-01-2012 22:16, Aleksandar Lazic wrote:
> On 31-01-2012 20:19, Marc Lehmann wrote:
>> On Tue, Jan 31, 2012 at 07:49:49PM +0100, Aleksandar Lazic
>> <al-anyevent at none.at> wrote:
>>> I want to use more then one process which goes sequentially thru 
>>> the
>>> directories.
>>
>> Coro gives you threads, not processes, and furthermore, they all 
>> block when
>> perl blocks on I/O (e.g. via File::Find).
>>
>> However, you can use IO::AIO, which offers aio_readdir and aio_stat,
>> which will be done in parallel. There is also an example program
>> "treescan" installed that walks a directory hierarchy and optionally 
>> stats
>> everything.
>
> Thank you I have totally overseen this program.
>
>> You can try:
>>
>>    treescan -sq /NFS-SHARE/dir1
>>
>> This will more or less do the same work as "du -s", but will not 
>> actually
>> display anything. It allows you to assess any possible speed 
>> improvement
>> though.
>
> I will definitely give it a try.

WOHA, after I have called the treescan the runtime was amazing.

960822 dirs (789.381/s) 881076 files (723.865/s) 881076 stats 
(723.865/s)
Total Elapsed :00:20:17

I'am not sure if this is the 'best' but much much better then > x 
HOURS.

Thanks Marc for your Development on IO::AIO.

Can I change the following line

  aio_lstat [$wd, $_] for @$files;

to

  aio_lstat $wd, sub {$outhash->{'bytes'} += -s _} for @$files;

to calculate the bytes in the directory as

du -sm /NFS-SHARE/dir1/*

or is there a better way?

OT: Is there a better way to print the elapsed time then this?

%T = %H:%M:%S
POSIX::strftime("%T",Time::HiRes::time-$tgesammt ,0,0,0,0,0)

Thanks for help.

BR
Aleks



More information about the anyevent mailing list