Article View: comp.arch
Article #12627Re: % in hash table
From: Edmund Yuen
Date: Tue, 10 Oct 1995 07:53
Date: Tue, 10 Oct 1995 07:53
31 lines
2205 bytes
2205 bytes
zalman@macromedia.com (Zalman Stern) writes: >In article <44smb1$3km@firma.tera.com>, preston@Tera.COM (Preston Briggs) wrote: >> _I_ think you're exaggerating. I don't think you can handle a single >> successful lookup (or collision) in the amount of time it takes to do >> a remainder. If we're hashing strings, there's a string compare >> implied in either case, not to mention the possibility of 2 or more >> cache (tlb, ...) misses along the way. >Yes, a single cache or TLB miss will outweigh a divide. To make Joe's >claim closer to true, one has to cheat harder. In my case, key strings are >mostly (but not always) from a well known set but appear in many different >hash tables. The strings are kept in a single pool and a full 32 bit hash >value is stored immediately before the string. On entry to the lookup >routine, the code checks if the string points into this pool. If so, the >hash value is immediately available and the string comparison is a pointer >comparison. The hash value still must be reduced to the size of the hash >table which is done with an and operation. >Another advantage to 2^n sized tables is that one doesn't have to >redistribute *all* the hash entries across the table when its size >changes. I considered using a few prime number schemes, but they all >became more difficult for dynamically sized hash tables. (Dynamic sizing >seemed like more of a space and speed win than primes could make up for.) I thought that dynamic hashing schemes (based on Litwin's linear hashing) could start with any size of table. It seems feasable to start with a prime sized table and expand from there. Eddie
Technical Details
Message-ID:
<45d8pe$i5g@dingo.cc.uq.oz.au>Path:
arc1-ca.pugleaf.net!bunyip.cc.uq.oz.au!yuenReferences:
<44c0gk$jq4@blather.cs.cornell.edu> <DFLzD9.Anx@uns.bris.ac.uk> <jgkDFv094.JKJ@netcom.com> <44smb1$3km@firma.tera.com> <zalman-0410951549330001@198.95.245.190>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bunyip.cc.uq.oz.au!yuen From: yuen@elec.uq.oz.au (Edmund Yuen) Newsgroups: comp.arch,comp.arch.arithmetic,comp.lang.c Subject: Re: % in hash table Date: 10 Oct 1995 07:53:18 GMT Organization: University of Queensland Message-ID: <45d8pe$i5g@dingo.cc.uq.oz.au> References: <44c0gk$jq4@blather.cs.cornell.edu> <DFLzD9.Anx@uns.bris.ac.uk> <jgkDFv094.JKJ@netcom.com> <44smb1$3km@firma.tera.com> <zalman-0410951549330001@198.95.245.190> NNTP-Posting-Host: sparky.elec.uq.edu.au X-Newsreader: NN version 6.5.0 #5 (NOV)