From owner-freebsd-hackers Fri Apr 25 00:33:22 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id AAA29759 for hackers-outgoing; Fri, 25 Apr 1997 00:33:22 -0700 (PDT) Received: from parkplace.cet.co.jp (parkplace.cet.co.jp [202.32.64.1]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id AAA29754 for ; Fri, 25 Apr 1997 00:33:20 -0700 (PDT) Received: from localhost (michaelh@localhost) by parkplace.cet.co.jp (8.8.5/CET-v2.1) with SMTP id HAA18662; Fri, 25 Apr 1997 07:33:09 GMT Date: Fri, 25 Apr 1997 16:33:09 +0900 (JST) From: Michael Hancock To: Bakul Shah cc: FreeBSD Hackers Subject: Re: the namei cache... In-Reply-To: <199704250453.AAA15841@chai.plexuscom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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;