Re: [patch 2/7] lib/hashmod: Add modulo based hash mechanism

From: Thomas Gleixner
Date: Sun May 01 2016 - 04:37:48 EST


On Sat, 30 Apr 2016, George Spelvin wrote:
> Thomas Gleixner wrote:
> You say that
> > hash64 is slightly faster as the modulo prime as it does not have the
> > multiplication.
>
> Um... are you sure you benchmarked that right? The hash_64 code you
> used (Thomas Wang's 64->32-bit hash) has a critical path consisting of 6
> shifts and 7 adds. I can't believe that's faster than a single multiply.

Sorry I did not express myself clear enough.

hash64 (the single multiply with the adjusted golden ratio) is slightly faster
than the modulo one which has two mutiplications.

So here is the list:

hash_64(): (key * GOLDEN_RATIO) >> (64 - bits) 31Mio Ops/sec

modulo: 28Mio Ops/sec

Thomas Wangs 64 -> 32 bit 21Mio Ops/sec

Thanks,

tglx