lkml.org 
[lkml]   [1999]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: more on hash functions
On 8 Apr 1999, Andi Kleen wrote:
> > the buffer hash function i used is this:
> >
> > #define _hashfn(dev,block) \
> > ((((unsigned long)(block) * (40499UL * 65543UL)) >> 17) & bh_hash_mask)
> >
> > this is the same number of instructions as the old function, except that
> > one of the instructions is IMUL. i haven't looked up how expensive this
> > might be. however, i believe a fixed expense is better than a higher
> > loops/lookup average, since IMUL with a constant multiplier doesn't incur
> > any memory overhead once it's in the instruction cache, whereas an extra
> > iteration of find_buffer might be another 2 memory references, either or
> > both of which might be cache misses.
>
> This is correct for the x86 picture, but breaks e.g. on earlier sparcs
> or some m68ks where multiplication is very slow. Remember Linux is not x86
> only.

yes, i'm well aware of the other archs. :)

i think "breaks" is a little strong, though. perhaps it is slower on
older hardware. can you say *how* slow an integer multiplication by a
constant is on older SPARC CPUs or on, say, a 486, compared to memory
references on these machines? that's the real tradeoff here, and i think
it would be good to measure the difference under load before dismissing
the idea.

- Chuck Lever
--
corporate: <chuckl@netscape.com>
personal: <chucklever@netscape.net> or <cel@monkey.org>

The Linux Scalability project:
http://www.citi.umich.edu/projects/citi-netscape/


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site