🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12599

Re: % in hash table

#12599
From: Preston Briggs
Date: Wed, 04 Oct 1995 01:00
28 lines
1887 bytes
In article <jgkDFv094.JKJ@netcom.com> Joe Keane <jgk@netcom.com> writes:
>Whenever i find some important hash table, one of the changes that i make is:
>Take out that stupid `%' operator!
>
>People that don't have low-level knowledge of machines don't realize how slow
>that remainder operation is.  Of course, it depends on the machine, so it can
>range from rather slow to extremely slow.  With no exaggeration, a good hash
>table can do several lookups in the time it takes to compute one remainder.

_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.

>In many applications, various hash tables are just critical to performance.
>The most important thing for a hash table like this is for it to *go fast*;

Hash tables offer constant (expected) time access.  Thus, they're
almost always helpful asymptotically.  Getting a bad distribution of
keys can provoke O(n) time per lookup, where n is the number of keys
in the table.  I'm glad to spend a little constant factor to help
avoid that possibility.

On the other hand, for small data sets, where the possibility of
asymptotic explosion doesn't matter, then you can do as you please.

Preston Briggs
Technical Details
Message-ID: <44smb1$3km@firma.tera.com>
Path: arc1-ca.pugleaf.net!firma.tera.com!not-for-mail
References: <44c0gk$jq4@blather.cs.cornell.edu> <DFLzD9.Anx@uns.bris.ac.uk> <jgkDFv094.JKJ@netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!firma.tera.com!not-for-mail
From: preston@Tera.COM (Preston Briggs)
Newsgroups: comp.arch,comp.arch.arithmetic,comp.lang.c
Subject: Re: % in hash table
Date: 3 Oct 1995 18:00:17 -0700
Organization: Tera Computer Company, Seattle, WA
Message-ID: <44smb1$3km@firma.tera.com>
References: <44c0gk$jq4@blather.cs.cornell.edu> <DFLzD9.Anx@uns.bris.ac.uk> <jgkDFv094.JKJ@netcom.com>
NNTP-Posting-Host: firma.tera.com
Keywords: hash