[plt-scheme] maintaining a cached list of modules

From: Eli Barzilay (eli at barzilay.org)
Date: Fri May 8 07:06:05 EDT 2009

On May  8, Jose A. Ortega Ruiz wrote:
> Neil Van Dyke <neil at neilvandyke.org> writes:
> > I think it would be easiest and least intrusive to check the mtime
> > on the parent directories on demand, to see if you need to rescan
> > them to build your caches.
> >
> > I think this will be fast enough to be imperceptible to an
> > interactive user.
> >
> > (Actually, building the list each time should be very fast on most
> > subsequent builds, given that contemporary computers typically
> > have enough RAM to cache directory info in RAM, so no disk I/O
> > typically required.)
> You're probably right here, but the list is big enough (around 3200
> entries) that there's a perceptible (if small) delay while emacs is
> talking with mzscheme to retrieve it, and i want to avoid also that
> delay.

I think that Neil suggests looking at the directory time, and only
scan the files if that time changes.  That reduces your number of
paths to check to about 400.  You can also look at the
"<collects-root>/info-domain/compiled/cache.ss" time, and if that didn't
chage you can assume that the whole collects root didn't change, which
should make it even smaller.  There are a number of planet meta-data
files that you can check in a similar way.

Another option is to do this check in a thread so there is no delay at
all for the user, and a minor chance that completion doesn't know
about the new file immediately after a change.  If you combine this
with the above, you can just scan for one file per collection root and
one for planet (usually three files total), and refresh the relevant
part of the cache on a change.

(This seems to me like a better solution than hooking the resolver: it
doesn't require that you control the mzscheme top level, and it
doesn't look right to refresh the cache whenever a file was required,
since that doesn't correspond to creating new module files.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.