Wednesday, April 13, 2011

New Hash Function from Google

Google has just announced a new variant of Hash Function called CityHash.

Here's what the project's description taken from their site:
CityHash provides hash functions for strings. The functions mix the input bits thoroughly but are not suitable for cryptography. We provide reference implementations in C++, with a friendly MIT license: city.cc, city.h. To download the code with svn use these instructions.

CityHash64() and similar return a 64-bit hash. Inside Google, where CityHash was developed starting in 2010, we use variants of CityHash64() mainly in hash tables such as hash_map.

CityHash128() and similar return a 128-bit hash and are tuned for strings of at least a few hundred bytes. Depending on your compiler and hardware, it may be faster than CityHash64() on sufficiently long strings. It is known to be slower than necessary on shorter strings, but we expect that case to be relatively unimportant. Inside Google we use variants of CityHash128() mainly for code that wants to minimize collisions.
As usual, Google's approach of speed is so incredible. They have a lot of scientist working in Google and two of them (Geoff Pike and Jyrki Alakuijala) has just created another cool product.