In reply to Archie Cobbs who said
>
>
> Hmm... suppose you did the following...
>
> At any given time you keep a tree data structure in which each node
> represents a directory. At each node, those attributes for the directory
> which differ from those inherited from the parent directory are stored.
Store the complete attributes for the directory. That would be much quicker.
If the directory is in the cache then you can access that directories
attributes immediately with no further accesses. That really would speed
up general server response. With your representation you'd have still have
to check every directories attributes, even if they were all in the cache
that would still be slower.
> When a directory is requested, you branch down the tree, inheriting
> attributes as you go, until you either reach a node representing the
> directory or fall out of the tree (in which case you start looking
> for .htaccess files and updating the tree).
Using the above this would be slightly different. If the directory you're
trying to access isn't in the cache tree then get to the leaf of the cache
, get it's attributes, then go and search the filesystem from that point
down to the actual directory you want to access. Filling in the cache
for each directory you read.
>
> Add to each node a time stamp; if the data is sufficiently old,
> recheck that the corresponding .htaccess file (if any) hasn't changed.
> This guarantees the "tree cache" doesn't get out of date.
Hmm, hadn't thought about that. This would be an acceptable solution if
there was also a "force cache update" hook of some sort so if you change
a .htaccess file you can get the server to check cache coherency. I guess
a -HUP would do bu then you'd lose all your cached entries.
>
> Now add to this a maximum memory usage parameter; when we've used up
> the maximum allowed space representing the tree, we prune the least recently
> used node(s) (which will necessarily be leaves of the tree) until enough
> space remains. This can all be done in constant time per operation (given
> fixed sized nodes) using a simple free list scheme.
>
> I would claim that this would even make a heavily loaded server FASTER
> because of the cached .htaccess files, since in the common case you
> don't have to open *any* .htaccess file for an access.
>
> But most importantly (to me) it makes the semantics of the access scheme
> consistent and understandable.
I agree on both points, this may well speed up server performance since
for frequently accessed pages you wouldn't need to read .htaccess at all
and it would certainly be a nice addition to functionality.
Ok, do you want to go and implement it now :-)
--
Paul Richards, Bluebird Computer Systems. FreeBSD core team member.
Internet: paul@FreeBSD.org,
http://www.freebsd.org/~paul Phone: 0370 462071 (Mobile), +44 1222 457651 (home)