Re-org hash functions in Chromium code base |
|||
Issue descriptionCurrently Chromium/Blink is using at least 5 different hash functions (SuperFastHash, Murmur2, Murmur3, CityHash, CRC32) in its code base. Some of this code comes from third_party/smhasher that is included as DEPS submodule. In other cases, it is part of a sub-module (e.g. Blink and Skia). Main issue is that some of this hash functions are no longer the fastest (e.g. SuperFastHash dates from 2004) or better quality (i.e. collisions) in modern hardware. Modern CPUs also have some hash functions builtin in hardware (e.g. ARMv8 includes as part of the crypto module instructions for crc32, sha1, aes, etc) that could be leveraged for speed ups. Finally, it should be not up to client code to decide which hash function to use. We should instead provide a common method and let a hash library to decide what is the best suited function considering the CPU where the code is running. Something similar to (and variants for unsigned buffers): uint32_t chromiumHashFunction32(const char *buffer, size_t len, const HashQuality &q) uint64_t chromiumHashFunction64(const char *buffer, size_t len, const HashQuality &q) Where HashQuality could be: a) FAST: the fastest hash possible but with general good quality, no guarantees concerning generating the same hash value depending on the CPU. b) PORTABLE: the fastest *portable* hash function that will generate the same hash values in all CPUs. c) CRYPTOGRAPHIC: hash function with cryptographic features.
,
Nov 7
In my experiments the best portable hash functions (performance + quality) where: xxHash (https://cyan4973.github.io/xxHash/), CityHash. A potential candidate for cryptographically strong hash would be HighwayHash (https://github.com/google/highwayhash). An interesting article comparing a few hashes can be found here: https://aras-p.info/blog/2016/08/09/More-Hash-Function-Tests/
,
Nov 10
,
Nov 10
|
|||
►
Sign in to add a comment |
|||
Comment 1 by cavalcantii@chromium.org
, Nov 7