This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (seeks while reading) Re: Performance, argh


Maciej Stachowiak <mstachow@alum.mit.edu> writes:

> Greg Badros <gjb@cs.washington.edu> writes:
> 
> > % time     seconds  usecs/call     calls    errors syscall
> > ------ ----------- ----------- --------- --------- ----------------
> >  42.89    0.184235        2193        84        70 access
> >  28.05    0.120460        2231        54        40 stat
> >  17.43    0.074850        1826        41           read
> >   6.63    0.028495         750        38        22 open
> >   3.17    0.013606        1512         9           fstat
> 
> That's a lot of access, stat and fstat calls there, and those are
> expensive as syscalls go.
> 
> This motivated me to find out where they are coming from (apologies
> for the csh shell syntax, and see below for analysis):
> 
> Using guile 1.3:
> 
> [mstx@207-172-216-87 ~/scwm]$ strace guile -c '(+ 1 2)' |& egrep 'access\(|stat\('

FWIW, you can do

strace -etrace=state,access guile -c '(+ 1 2)'

to more reliably and cheaply (and shell independently) get the
information you were looking for.

<snip strace output>

> Several problems are immediately apparent:
> 
> * Whenever Guile loads a file named "somefile.scm", it will also go
>   looking for "somefile.scm.scm". This is, IMO, semantically
>   incorrect, in addition to being a pessimization.

Agreed.

> * Whenever Guile loads a file by base name only (I am guessing that's
>   what's happening in the other cases) then in each directory it tries
>   to load ".scm", then "basename", then "basename.scm". Checking for
>   ".scm" is probably a bug. Maybe the basename loading code is a bad
>   thing in general. Being able to `(load "my-file")' and get
>   "my-file.scm" loaded is at best a miniscule convenience.

Agreed.

> * When Guile access(2)s a directory and finds it doesn't exist, it
>   will go ahead and try to call access on files in it anyway. That
>   seems fairly bogus.

Very bogus.

> * Many files are access'd and then stat'd, or vice versa. The
>   duplication should be investigated and removed (if `load' is trying
>   to do an access() or a stat() before open()ing the file that is
>   bogus, it should just do the open and check for an error return).

Yep.

> * A lot of files are checked for (uncucessfully) in guile/site/ice-9/
>   instead of guile/1.5/ice-9. Perhaps it should be reconsidered
>   whether the `site' directory should be first in the load path, as I
>   can't think of any good coming of a site shadowing, e.g., debug.scm
>   with something different.

I think you have to allow site shadowing, though.  If the site directory 
doesn't exist then those stat/opens should be skipped.

> I will try to send patches for at least the more obvious these
> problems if no one beats me to it.

Excellent... this should help quite a bit!

I'd really like to see a guile-1.3.1 with all of these performance
fixes; if for no other reason than for a nice package to work well with
Scwm (and who knows how far off guile-1.4 is;  Scwm 1.0 will target
guile-1.3.1).

Thanks,
Greg

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]