email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna
If you look at the stracefile, you'll notice that the last three times it
just open and closes the file, without reading. I'm very interested in this,
because I've noticed the same behaviour with my Rails application, and there
the search path is _huge_.
Han Holl
-a
···
--
===============================================================================
> email :: ara [dot] t [dot] howard [at] noaa [dot] gov
> phone :: 303.497.6469
> Your life dwells amoung the causes of death
> Like a lamp standing in a strong breeze. --Nagarjuna
static int
file_load_ok(const char *file)
{
FILE *f;
if (!file) return 0;
f = fopen(file, "r");
if (f == NULL) return 0;
fclose(f);
return 1;
}
(file.c)
···
On Fri, Sep 16, 2005 at 07:14:21PM +0900, Han Holl wrote:
If you look at the stracefile, you'll notice that the last three times it
just open and closes the file, without reading. I'm very interested in this,
because I've noticed the same behaviour with my Rails application, and there
the search path is _huge_.
yeah exactly - i'm trying to speed up acgi running strace's and was seeing md5
get opened like 20 times. this sure could slow something like rails down
alright.
guess this is the point where it's be smart to look at the source for
rb_require...
If you look at the stracefile, you'll notice that the last three times it
just open and closes the file, without reading. I'm very interested in this,
because I've noticed the same behaviour with my Rails application, and there
the search path is _huge_.
--
email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna
Yes, that's answering where it happens.
Remains the question why.
Han
···
On 9/16/05, Mauricio Fernández <mfp@acm.org> wrote:
On Fri, Sep 16, 2005 at 07:14:21PM +0900, Han Holl wrote:
> If you look at the stracefile, you'll notice that the last three times
it
> just open and closes the file, without reading. I'm very interested in
this,
> because I've noticed the same behaviour with my Rails application, and
there
> the search path is _huge_.
static int
file_load_ok(const char *file)
{
FILE *f;
if (!file) return 0;
f = fopen(file, "r");
if (f == NULL) return 0;
fclose(f);
return 1;
}
In message "Re: bug in require?" on Fri, 16 Sep 2005 20:56:38 +0900, Han Holl <han.holl@gmail.com> writes:
Yes, that's answering where it happens.
Remains the question why.
It was the easiest way to check if a file is loadable (i.e. a file
exists and has proper permissions). Maybe it's possible to replace it
with access(3).
commandline and from a script.
Only now I see that the difference is that from the commandline he requires
"digest/md5.so", and from the file
'digest/md5', without the extension.
Which means that you get a considerable perfomance penalty by omitting the
extension. In a gem-installed rails environment the seachpath can easily be
25 directories. Multiple requires withou extension can be costly there.
Cheers,
Han
···
On 9/16/05, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,
In message "Re: bug in require?" > on Fri, 16 Sep 2005 20:56:38 +0900, Han Holl <han.holl@gmail.com> writes:
>Yes, that's answering where it happens.
>Remains the question why.
It was the easiest way to check if a file is loadable (i.e. a file
exists and has proper permissions). Maybe it's possible to replace it
with access(3).
matz.
Ara's question was what the difference was between execution from the
On 9/16/05, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,
In message "Re: bug in require?" >> on Fri, 16 Sep 2005 20:56:38 +0900, Han Holl <han.holl@gmail.com> writes:
>Yes, that's answering where it happens.
>Remains the question why.
It was the easiest way to check if a file is loadable (i.e. a file
exists and has proper permissions). Maybe it's possible to replace it
with access(3).
matz.
Ara's question was what the difference was between execution from the
commandline and from a script. Only now I see that the difference is that
from the commandline he requires "digest/md5.so", and from the file
'digest/md5', without the extension. Which means that you get a
considerable perfomance penalty by omitting the extension. In a
gem-installed rails environment the seachpath can easily be 25 directories.
Multiple requires withou extension can be costly there.
--
email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna
At Fri, 16 Sep 2005 23:24:16 +0900,
Han Holl wrote in [ruby-talk:156435]:
Ara's question was what the difference was between execution from the
commandline and from a script.
Only now I see that the difference is that from the commandline he requires
"digest/md5.so", and from the file
'digest/md5', without the extension.
Which means that you get a considerable perfomance penalty by omitting the
extension. In a gem-installed rails environment the seachpath can easily be
25 directories. Multiple requires withou extension can be costly there.
If md5.rb exists in loadpath, it should be loaded even if
md5.so has been loaded.
Yes, that's one way of dealing with it.
Another approach that I find attractive is autoload. I think in the case of
the Digest namespace, one could write:
module Digest
autoload :MD5, 'digest/md5'
end
Autoloading also has the advantage of looser coupling, lazy loading and
auto-determining load order in case of (almost cyclic) dependencies.
It should perform better than redundant requires as well, but I doubt this
is noticeable.
Cheers,
Han Holl
···
On 9/16/05, Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:
I don't doubt for a minute that you are right, but in practice this will of
course hardly ever occur, and with the gem-induced explosion of the search
path it is probably worthwhile to do something about it: rewriting require,
or introducing a specialized require with a different name, or autoloading.
Intuitively, if I say: require 'some/feature' , I would expect (almost)
nothing to happen if this feature had been required before. About 50 failing
lookups in directories is not almost nothing.
Maybe we could have some global flag meaning: I don't need this overly
correct behaviour, please do nothing if either .rb of .so (or .dll) has been
loaded ?
Cheers,
Han Holl
···
On 9/16/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
If md5.rb exists in loadpath, it should be loaded even if
md5.so has been loaded.
In article <7348fe71050916123626c96aa4@mail.gmail.com>,
han.holl@gmail.com says...
I don't doubt for a minute that you are right, but in practice this will of
course hardly ever occur, and with the gem-induced explosion of the search
path it is probably worthwhile to do something about it: rewriting require,
or introducing a specialized require with a different name, or autoloading.
I was noticing this too the other day; Windows file opens are much
slower than Linux, and even small rails apps can spend a second or two
on Windows just waiting for the file system while it goes searching for
gems at startup. Makes unit testing a good bit less fun.
···
--
Jay Levitt |
Wellesley, MA | I feel calm. I feel ready. I can only
Faster: jay at jay dot fm | conclude that's because I don't have a http://www.jay.fm | full grasp of the situation. - Mark Adler