Dramatically improve the **lame** nfs_hash(). This is based on the

Fowler / Noll / Vo Hash (http://www.isthe.com/chongo/tech/comp/fnv/).

This improves hash coverage a *massive* amount.  We were seeing one
set of machines that were using 0.84% of their 131072 entry nfsnode
hash buckets with maximum chain lengths of up to ~500 entries.  The
machine was spending nearly 100% of its time in 'system'.
A test with this has pushed the coverage from a few perCent up to 91%
utilization with a max chain length of 11.

Submitted by:  David Filo
This commit is contained in:
Peter Wemm 2001-03-17 05:43:01 +00:00
parent d383383e6f
commit be1d4058eb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74381
2 changed files with 32 additions and 16 deletions

View File

@ -73,21 +73,29 @@ nfs_nhinit()
/*
* Compute an entry in the NFS hash table structure
*
* Hash based on: http://www.isthe.com/chongo/tech/comp/fnv/
* by Glenn Fowler, Phong Vo and Landon Curt Noll
* aka the "Fowler / Noll / Vo Hash" (FNV)
*/
#define FNV_32_PRIME ((u_int32_t) 0x01000193UL)
#define FNV1_32_INIT ((u_int32_t) 33554467UL)
u_long
nfs_hash(fhp, fhsize)
register nfsfh_t *fhp;
nfsfh_t *fhp;
int fhsize;
{
register u_char *fhpp;
register u_long fhsum;
register int i;
u_char *fhpp;
u_int32_t hval;
int i;
fhpp = &fhp->fh_bytes[0];
fhsum = 0;
for (i = 0; i < fhsize; i++)
fhsum += *fhpp++;
return (fhsum);
hval = FNV1_32_INIT;
for (i = 0; i < fhsize; i++) {
hval *= FNV_32_PRIME;
hval ^= (u_int32_t)*fhpp++;
}
return (hval);
}
/*

View File

@ -73,21 +73,29 @@ nfs_nhinit()
/*
* Compute an entry in the NFS hash table structure
*
* Hash based on: http://www.isthe.com/chongo/tech/comp/fnv/
* by Glenn Fowler, Phong Vo and Landon Curt Noll
* aka the "Fowler / Noll / Vo Hash" (FNV)
*/
#define FNV_32_PRIME ((u_int32_t) 0x01000193UL)
#define FNV1_32_INIT ((u_int32_t) 33554467UL)
u_long
nfs_hash(fhp, fhsize)
register nfsfh_t *fhp;
nfsfh_t *fhp;
int fhsize;
{
register u_char *fhpp;
register u_long fhsum;
register int i;
u_char *fhpp;
u_int32_t hval;
int i;
fhpp = &fhp->fh_bytes[0];
fhsum = 0;
for (i = 0; i < fhsize; i++)
fhsum += *fhpp++;
return (fhsum);
hval = FNV1_32_INIT;
for (i = 0; i < fhsize; i++) {
hval *= FNV_32_PRIME;
hval ^= (u_int32_t)*fhpp++;
}
return (hval);
}
/*