Warner Losh <[EMAIL PROTECTED]> wrote:
>In message <[EMAIL PROTECTED]> Tony Finch writes:
>: Dag-Erling Smorgrav <[EMAIL PROTECTED]> wrote:
>: >
>: >If you only have half a million users, pick a prime number K close to
>: >the square root of the expected number of users (724 in your case -
>: >closest primes are 719 and 727), create that many bucket directories,
>: >and place each user in bucket ID mod K.
>:
>: Why a prime number? All you need is an even spread, and given that
>: user IDs are usually allocated sequentially any modulus will do.
>
>Because Knuth has shown that prime numbers give the best spread in
>hash lookup tables.
Yes, I know that, but we aren't talking about normal hash tables. The
aim of the prime number is to avoid hash collisions, but in this
application you are deliberately aiming for about 700 items in each
bucket instead of about one. Whether the modulus is prime or not will
make no detectable difference with this degree of hash collision.
Tony.
--
f.a.n.finch [EMAIL PROTECTED] [EMAIL PROTECTED]
"If I didn't see it with my own eyes I would never have believed it!"
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message