octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

m file cache


From: John W. Eaton
Subject: m file cache
Date: Thu, 4 May 2006 10:55:27 -0400

On 27-Apr-2006, Tom Holroyd (NIH/NIMH) [E] wrote:

| Regarding the recent patch to cache path walks in kpse.cc;
| 
| There are two caches.  One for files that have been found, so their
| location in the path is known, and one for names that were searched
| for, but don't exist.  Modify times are still checked on the
| directories every time, I think (that's done someplace else).
| 
| Do we want to have "rehash"?  In a production environment, I
| wouldn't want it wasting any time doing anything twice, and
| everything is stable so there's no need for cache rebuilding.
| Explicit rehashes are meant for that sort of thing, but it's easier
| to just restart the interpreter.  So I think rehash should go, too.
| 
| Other issues: do we really need brace expansion in the path?  That
| is: a/{b,c}/d.  I would vote to get rid of that, since it can be
| done in other ways if you really want it.  Also the !! magic could
| go, I doubt anybody is even aware of it. Variable and ~ expansion
| are OK.

Looking at the code in kpse.cc, I think we can do better.  The
home-brew lists and hash tables should probably be replaced with a few
STL containers.  I'd guess that we can reduce the 2600 lines down to
something a bit more manageable, especially if we decide to skip the
more elaborate expansions in path elements as you suggest.

I'm not sure of the details yet, but I think the basic searching
algorithm could be changed so that we maintain some kind of map
(multimap? set? multiset?) of names to directories that allows a quick
search through the filesystem, updating the map elements for each
directory if the directory hasn't been cached before, or if a prompt
has been printed since the last cache update.

It's not clear to me whether there should be one large map (fast
lookups, but forces a rehash of the entire map at each prompt) or one
map for each directory (possibly slower lookups, but updates to each
per-directory map can happen only as needed) but I'm leaning toward
one map for each directory since that may also make it simpler to list
the complete contents of the path by directory (I'm thinking of what
is needed for the help list).

Probably this code should be merged with what is in fn-cache.{h,cc} as
that seems somehow redundant.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]