Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Apr 1997 16:33:09 +0900 (JST)
From:      Michael Hancock <michaelh@cet.co.jp>
To:        Bakul Shah <bakul@torrentnet.com>
Cc:        FreeBSD Hackers <hackers@freebsd.org>
Subject:   Re: the namei cache... 
Message-ID:  <Pine.SV4.3.95.970425163021.18617B-100000@parkplace.cet.co.jp>
In-Reply-To: <199704250453.AAA15841@chai.plexuscom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 25 Apr 1997, Bakul Shah wrote:

> A few years ago, in some usenet group, Chris Torek compared a number
> of hash functions and with each one he hashed the entire web2 (or
> some such) list of words to check collisions.  The best one from
> this list goes something like
> 
> 	unsigned hash = 0x31fe;	/* not sure of this init value */
> 	while (*cp)
> 		hash = hash*33 + *cp++;
> 

If you're daring you might try this out on 2.2.

Index: vfs_cache.c
===================================================================
RCS file: /jaz/cvs/src/sys/kern/vfs_cache.c,v
retrieving revision 1.20
diff -r1.20 vfs_cache.c
144c144
< 	ncpp = &nchashtbl[(dvp->v_id + cnp->cn_hash) % nchash];
---
> 	ncpp = &nchashtbl[(dvp->v_id + cnp->cn_hash) & nchash];
249c249
< 	ncpp = &nchashtbl[(dvp->v_id + cnp->cn_hash) % nchash];
---
> 	ncpp = &nchashtbl[(dvp->v_id + cnp->cn_hash) & nchash];
262c262
< 	nchashtbl = phashinit(desiredvnodes, M_CACHE, &nchash);
---
> 	nchashtbl = hashinit(desiredvnodes, M_CACHE, &nchash);
Index: vfs_lookup.c
===================================================================
RCS file: /jaz/cvs/src/sys/kern/vfs_lookup.c,v
retrieving revision 1.11.4.1
diff -r1.11.4.1 vfs_lookup.c
271a272
> 	u_long hash;
299c300
< 	cnp->cn_hash = 0;
---
> 	hash = 0;
301c302,303
< 		cnp->cn_hash += (unsigned char)*cp;
---
> 		hash = hash * 33 + (unsigned char)*cp;
> 	cnp->cn_hash = hash;





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SV4.3.95.970425163021.18617B-100000>