hashinit versus phashinit

Roman Divacky rdivacky at freebsd.org
Mon May 5 20:44:23 UTC 2008


hi

when we want to use a hash table in kernel we call "hashinit" which
initializes a hash table with power-of-2 size. There's also "phashinit"
that creates hash table of size that is a prime number. This was
added in 1995 by davidg@ but it is not used anywhere in the kernel.

phk@ commited rev. 1.30 of vfs_cache.c replacing phashinit with hashinit
stating that it's better because it replaces a division with logical and.
is this reason still valid today? (the commit was done almost 11 years ago)

is there still any reason why not use the phashinit instead of hashinit?
I believe using prime-sized hash table might have positive performance
impact...

do you have comments?

roman


More information about the freebsd-hackers mailing list