From: "Ara.T.Howard" Date: 2005-09-16T23:19:27+09:00 Subject: Re: bug in require? On Fri, 16 Sep 2005, Han Holl wrote: > [ahoward@localhost ~]$ cat a.rb >> 4.times{ require 'digest/md5' } >> >> [ahoward@localhost ~]$ strace ruby a.rb 2>&1 |grep open|grep md5 >> open("/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so", >> O_RDONLY|O_LARGEFILE) = 3 >> open("/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so", >> O_RDONLY|O_LARGEFILE) = 3 >> open("/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so", O_RDONLY) = 3 >> open("/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so", >> O_RDONLY|O_LARGEFILE) = 3 >> open("/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so", >> O_RDONLY|O_LARGEFILE) = 3 >> open("/usr/local/lib/ruby/1.8/i686-linux/digest/md5.so", >> O_RDONLY|O_LARGEFILE) = 3 >> >> why the difference? > > > 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... cheers. -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 ===============================================================================