[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

slow file access with mapped drives ?!

Rebhan, Gilbert

5/14/2007 9:39:00 AM


Hi,

running ruby 1.8.4 (2006-04-14) [i386-mswin32]
on Windows2000

i have a script that scans some directories for given filename patterns
and does string replacement in those found files.

it works fine, but when it comes to work with files on a mapped drive
the script hangs for about 20secs, afterwards does his work and all OK.

i tried with =

V:/path/to/files
and also with
//servername/c$/path/to/files

and it's both the same, no difference.

Any ideas how to speed up the file access ?
Are there general problems with unc path and ruby ?


Gilbert

4 Answers

Rebhan, Gilbert

5/14/2007 10:05:00 AM

0


Hi,

after some irb it shows the bottleneck lies in
the Dir.glob method

i do something like =

config['targetdirs'].each do |dir|

Dir.chdir("//servername/c$/targetdir")
Dir.glob("**/"<<config['targetfilepattern']).each do |file|
...
end
...
end


any alternatives to Dir.glob ?


Regards, Gilbert


-----Original Message-----
From: Rebhan, Gilbert [mailto:Gilbert.Rebhan@huk-coburg.de]
Sent: Monday, May 14, 2007 11:39 AM
To: ruby-talk ML
Subject: slow file access with mapped drives ?!


Hi,

running ruby 1.8.4 (2006-04-14) [i386-mswin32]
on Windows2000

i have a script that scans some directories for given filename patterns
and does string replacement in those found files.

it works fine, but when it comes to work with files on a mapped drive
the script hangs for about 20secs, afterwards does his work and all OK.

i tried with =

V:/path/to/files
and also with
//servername/c$/path/to/files

and it's both the same, no difference.

Any ideas how to speed up the file access ?
Are there general problems with unc path and ruby ?


Gilbert


Robert Klemme

5/14/2007 10:17:00 AM

0

On 14.05.2007 12:05, Rebhan, Gilbert wrote:
>
> Hi,
>
> after some irb it shows the bottleneck lies in
> the Dir.glob method
>
> i do something like =
>
> config['targetdirs'].each do |dir|
>
> Dir.chdir("//servername/c$/targetdir")
> Dir.glob("**/"<<config['targetfilepattern']).each do |file|

Why don't you just do

Dir.glob("//servername/c$/targetdir/**/"<<config['targetfilepattern']).each
do |file|

Btw, I don't see any reference to block variable "dir" is this on purpose?

> ...
> end
> ..
> end
>
>
> any alternatives to Dir.glob ?

Find.find - but don't expect that it's faster because the slowness lies
in file system accesses. Network drives are inherently slower than
local disks.

Kind regards

robert

Rebhan, Gilbert

5/14/2007 12:18:00 PM

0


Hi, Robert

-----Original Message-----
From: Robert Klemme [mailto:shortcutter@googlemail.com]
Sent: Monday, May 14, 2007 12:20 PM
To: ruby-talk ML
Subject: Re: slow file access with mapped drives ?!

/*
Why don't you just do

Dir.glob("//servername/c$/targetdir/**/"<<config['targetfilepattern']).e
ach
do |file|
*/

Because i need to have the targetdirs flexible, for example i have in
my yaml =

targetdirs:
- Y:/tempwork
- T:/rubytest
- //wvp10175/c$/SCM_Server

/*
Btw, I don't see any reference to block variable "dir" is this on
purpose?
*/

config['targetdirs'].each do |dir|
Dir.chdir(dir)
Dir.glob("**/"<<config['targetfilepattern']).each do |file
...
end
...end


> any alternatives to Dir.glob ?

/*
Find.find - but don't expect that it's faster because the slowness lies
in file system accesses. Network drives are inherently slower than
local disks.
*/

it runs in almost half the time, much quicker :-)
thanks for the pointer !! , now i have =

config['targetdirs'].each do |dir|
Find.find(dir) do |f|
if f =~ /#{config['targetfilepattern']}/
puts "... processing "<<f
filesed!(config['replacefrom'],s,f)
end
end
end

Best regards, Gilbert

Robert Klemme

5/14/2007 12:44:00 PM

0

On 14.05.2007 14:18, Rebhan, Gilbert wrote:
>
> Hi, Robert
>
> -----Original Message-----
> From: Robert Klemme [mailto:shortcutter@googlemail.com]
> Sent: Monday, May 14, 2007 12:20 PM
> To: ruby-talk ML
> Subject: Re: slow file access with mapped drives ?!
>
> /*
> Why don't you just do
>
> Dir.glob("//servername/c$/targetdir/**/"<<config['targetfilepattern']).e
> ach
> do |file|
> */
>
> Because i need to have the targetdirs flexible, for example i have in
> my yaml =
>
> targetdirs:
> - Y:/tempwork
> - T:/rubytest
> - //wvp10175/c$/SCM_Server

??? The code you posted had no dynamic piece there. Did you maybe mean
to write

Dir.chdir("//servername/c$/#{dir}")

> /*
> Btw, I don't see any reference to block variable "dir" is this on
> purpose?
> */
>
> config['targetdirs'].each do |dir|
> Dir.chdir(dir)
> Dir.glob("**/"<<config['targetfilepattern']).each do |file
> ..
> end
> ..end

That was not in the code you posted.

>> any alternatives to Dir.glob ?
>
> /*
> Find.find - but don't expect that it's faster because the slowness lies
> in file system accesses. Network drives are inherently slower than
> local disks.
> */
>
> it runs in almost half the time, much quicker :-)

.... which might be due to the fact that your new code doesn't do the
chdir! You changed multiple parameters at the same time so it's hard to
attribute the perceived performance change to any one parameter.

> thanks for the pointer !! , now i have =
>
> config['targetdirs'].each do |dir|
> Find.find(dir) do |f|
> if f =~ /#{config['targetfilepattern']}/
> puts "... processing "<<f
> filesed!(config['replacefrom'],s,f)
> end
> end
> end

Please make sure you post the code you are actually testing - otherwise
everybody else will have a hard time understanding what's going on let
alone come up with helpful replies.

Regards

robert