Re: machine-dependent hash_any vs the regression tests - Mailing list pgsql-hackers

From Tom Lane
Subject Re: machine-dependent hash_any vs the regression tests
Date
Msg-id 11205.1207435448@sss.pgh.pa.us
Whole thread Raw
In response to Re: machine-dependent hash_any vs the regression tests  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
Gregory Stark <stark@enterprisedb.com> writes:
> Why do we have this hash function anyways? Is hashany faster than a decent
> crc32 implementation?

Yes, significantly.  Times to hash 32K bytes 100000 times on a Xeon EM64T:

hash_crc(32K): 11.388755 s
hash_any_old(32K): 4.401945 s
hash_any(32K): 3.862427 s

hash_crc is our src/include/utils/pg_crc.h code, hash_any_old is current
CVS HEAD, hash_any is the word-wide version.  For just 8 bytes (100M
repetitions)

hash_crc(8 bytes): 2.587647 s
hash_any_old(8 bytes): 1.581826 s
hash_any(8 bytes): 1.294480 s

so in both setup and per-byte terms CRC is more expensive.  But the
bigger problem is that CRC isn't necessarily designed to have the
properties we need, in particular that all bits of the hash are about
equally random.  It's designed to attack other problems.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: machine-dependent hash_any vs the regression tests
Next
From: Hannu Krosing
Date:
Subject: Adding pipelining support to set returning functions