New issue
Advanced search Search tips

Issue 902789 link

Starred by 2 users

Issue metadata

Status: Untriaged
Owner: ----
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue 735674

Blocking:
issue 662253
issue 903973



Sign in to add a comment

Re-org hash functions in Chromium code base

Project Member Reported by cavalcantii@chromium.org, Nov 7

Issue description

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

 
Blockedon: 735674
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/
Blocking: 903973
Blocking: 662253

Sign in to add a comment