Clean up and improve the namecache.

1. We always keep one 16th of the vnodes on the freelist, so that the
namecache doesn't get trashed.  It used to be that it wasn't a problem, but
the only vnodes getting released these days are directories and things which
Clean up and improve the namecache.

1. We always keep one 16th of the vnodes on the freelist, so that the
namecache doesn't get trashed.  It used to be that it wasn't a problem, but
the only vnodes getting released these days are directories and things which
gets forced out of the VM/cache.  The latter is not numerous enough to keep
the pool of vnodes needed for the namecache sufficiently big.

2. Purge invalid entries in the namecache as soon as we notice them.  This
avoids a stale entry pushing out a valid entry on the LRU list.

3. Speed up the lookup in the namecache by avoid a special case branch.

4. Make the cache purge routines do the thing they're supposed to, and in
a decently efficient manner.

5. Make the size of the namecache follow the number of vnodes, so that we
can always point to all the vnodes we have in core.

6. Readability has gone way up.

7. Added a "options NCH_STATISTICS" feature that will gather more
detailed statistics on the performance of the namecache.

Reviewed by:    davidg
This commit is contained in:
phk 1995-03-09 20:27:21 +00:00
parent 5ac4500e79
commit 73699a95c4

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)namei.h 8.2 (Berkeley) 1/4/94
* $Id: namei.h,v 1.3 1994/09/27 20:33:41 phk Exp $
* $Id: namei.h,v 1.4 1995/03/06 06:45:47 phk Exp $
*/
#ifndef _SYS_NAMEI_H_
@ -154,7 +154,11 @@ struct nameidata {
* size is 15.
*/
#ifdef NCH_STATISTICS
#define NCHNAMLEN 23 /* maximum name segment length we bother with */
#else
#define NCHNAMLEN 31 /* maximum name segment length we bother with */
#endif
struct namecache {
LIST_ENTRY(namecache) nc_hash; /* hash chain */
@ -163,12 +167,17 @@ struct namecache {
u_long nc_dvpid; /* capability number of nc_dvp */
struct vnode *nc_vp; /* vnode the name refers to */
u_long nc_vpid; /* capability number of nc_vp */
#ifdef NCH_STATISTICS
u_long nc_nbr; /* a serial number */
u_long nc_hits; /* how many times we got hit */
#endif
char nc_nlen; /* length of name */
char nc_name[NCHNAMLEN]; /* segment name */
};
#ifdef KERNEL
u_long nextvnodeid;
u_long numvnodes, numcache;
int namei __P((struct nameidata *ndp));
int lookup __P((struct nameidata *ndp));
int relookup __P((struct vnode *dvp, struct vnode **vpp,