SMhasher

Alternative timings with a modern AMD Ryzen 3 3200U 3.5GHz laptop:

Hash function MiB/sec cycl./hash cycl./map size Quality problems
donothing32 9920542.19 3.54 - 13 test NOP
donothing64 14774153.98 3.41 - 13 test NOP
donothing128 14594855.23 3.29 - 13 test NOP
NOP_OAAT_read64 14696502.48 11.00 - 47 test NOP
BadHash 809.07 90.73 - 47 test FAIL
sumhash 8936.31 32.11 - 363 test FAIL
sumhash32 28739.90 21.03 - 863 UB, test FAIL
multiply_shift 5717.82 23.50 1022.25 (35) 345 fails all tests
pair_multiply_shift 3931.05 28.33 - 609 fails all tests

crc32 306.97 129.91 1176.81 (96) 422 insecure, 8590x collisions, distrib
md5_32 442.12 490.40 1179.63 (43) 4419
md5_64 442.33 496.72 - 4419
md5-128 295.62 544.45 - 4419
sha1_32 671.12 618.46 1292.71 (138) 5126 Sanity, collisions, 36.6% distrib
sha1_64 668.66 600.65 1262.21 (21)
sha1-160 659.09 620.36 1278.53 (30) 5126 Comb/Cyclic low3
sha2-224 285.42 689.48 - Cyclic low32
sha2-224_64 280.97 686.72 - Cyclic low32
sha2-256 286.38 677.81 -
sha2-256_64 285.85 683.77 -
sha1ni 1981.58 139.92 725.03 (10) 989 insecure,sanity, Permutation, Zeroes, amd epyc only
sha1ni_32 1970.45 137.90 734.13 (16) 989 insecure,sanity, Permutation, Zeroes, TwoBytes, amd epyc only
sha2ni-256 1910.31 149.60 731.14 (116) 4241 insecure,sanity, Permutation, Zeroes, amd epyc only
sha2ni-256_64 1866.97 147.62 725.08 (12) 4241 insecure,sanity, Permutation, Zeroes, TwoBytes, amd epyc only
blake3_c 1727.55 282.72 811.97 (12) no 32bit portability
rmd128 351.28 530.44 -
rmd160 239.32 793.88 -
rmd256 448.93 438.15 1084.31 (36)
edonr224 968.82 271.31 -
edonr256 1018.79 260.72 801.38 (4)
edonr224 968.82 271.31 -
edonr256 1018.79 260.72 801.38 (4)
blake2s-128 432.45 469.48 -
blake2s-160 435.87 473.78 -
blake2s-224 430.71 474.22 -
blake2s-256 433.48 475.57 -
blake2s-256_64 435.46 475.38 -
blake2b-160 721.37 565.58 1116.44 (28)
blake2b-224 719.65 567.53 -
blake2b-256 722.82 564.90 - Sparse high 32-bit
blake2b-256_64 715.70 569.00 -
asconhashv12 202.97 643.77 1066.58 (16) 6490
asconhashv12_64 203.16 304.43 744.25 (4) 4341
sha3-256 151.55 2544.82 - PerlinNoise
sha3-256_64 152.43 2963.84 - PerlinNoise
hasshe2 3467.08 51.25 899.79 (22) 445 Permutation,TwoBytes,Zeroes,Seed
poly_1_mersenne 1385.79 72.27 913.66 (57) 479 fails most tests
poly_2_mersenne 1568.27 56.16 - 479
poly_3_mersenne 1506.04 63.32 - 479
poly_4_mersenne 1512.29 88.03 905.16 (19) 479
tabulation32 7099.58 32.38 869.79 (26) 848 collisions
tabulation 3717.39 32.13 - 554
crc32_hw 5611.01 49.38 - 653 insecure, 100% bias, collisions, distrib, machine-specific (x86 SSE4.2)
crc32_hw1 6713.63 54.76 - 671 insecure, 100% bias, collisions, distrib, machine-specific (x86 SSE4.2)
crc64_hw 5256.51 48.43 760.34 (13) 652 insecure, 100% bias, collisions, distrib, machine-specific (x64 SSE4.2)
crc32_pclmul 7421.44 83.25 - 481 insecure, 100% bias, collisions, distrib, machine-specific (x86 PCLMUL)
crc64_jones1 insecure, 100% bias, collisions, distrib
crc64_jones2 insecure, 100% bias, collisions, distrib
crc64_jones3 insecure, 100% bias, collisions, distrib
crc64_jones insecure, 100% bias, collisions, distrib
o1hash 14721460.85 14.09 - 101 insecure, zeros, fails all tests
fibonacci 14769.82 26.21 803.18 (15) 1692 UB, zeros, fails all tests
FNV1a 726.59 73.45 - 204 zeros, fails all tests
FNV1A_Totenschiff 5279.45 26.65 - 270 UB, zeros, fails all tests
FNV1A_Pippip_Yurii 5279.46 32.01 - 147 UB, sanity, fails all tests
FNV1a_YT 15655.74 26.31 883.77 (32) 321 UB, fails all tests
FNV2 5279.55 33.80 781.54 (27) 278 fails all tests
FNV64 844.88 63.48 - 79 fails all tests
FNV128 407.61 133.68 - ?
k-hash32 1962.60 56.26 1054.45 (55) 808 UB, insecure, zeros, fails all tests
k-hash64 2105.08 57.63 860.37 (62) 609 UB, insecure, zeros, fails all tests
fletcher2 13078.62 24.05 - 248 UB, fails all tests
fletcher4 13749.64 21.73 - 371 UB, fails all tests
bernstein 896.15 46.81 - 41 fails all tests
sdbm 741.04 57.46 876.64 (36) 41 fails all tests
x17 960.14 69.51 899.27 (56) 79 99.98% bias, fails all tests
libiberty 524.12 69.34 873.94 (25) 37 insecure, 100% bias, fails all tests
gcc 539.23 70.28 - 39 insecure, 100% bias, fails all tests
JenkinsOOAT 519.18 102.15 878.09 (5) 153 53.5% bias, fails all tests
JenkinsOOAT_perl 611.48 82.72 893.23 (22) 65 1.5-11.5% bias, 7.2x collisions, LongNeighbors
MicroOAAT 920.45 77.09 - 68 100% bias, distrib
VHASH_32 16074.41 63.56 - 1231 sanity, Seed, MomentChi2
VHASH_64 11058.92 51.83 - 1231 sanity, Seed, Sparse
farsh32 23629.12 74.86 956.82 (31) 944 insecure: AppendedZeroes, collisions+bias, MomentChi2, LongNeighbors
farsh64 11815.51 106.59 - 944 insecure: AppendedZeroes, collisions+bias, MomentChi2, LongNeighbors
farsh128 7891.41 188.31 - ??
farsh256 3012.15 395.74 - ??
jodyhash32 1495.82 36.03 - 102 bias, collisions, distr, LongNeighbors
jodyhash64 4249.93 25.99 - 118 bias, collisions, distr, LongNeighbors
lookup3 3088.73 32.10 - 341 UB, 28% bias, collisions, 30% distr
superfast 2025.10 48.22 - 210 UB, 91% bias, 5273.01x collisions, 37% distr, BIC
MurmurOAAT 441.24 118.80 - 47 collisions, 99.998% distr., BIC, LongNeighbors
Crap8 3850.35 43.26 - 342 UB, 2.42% bias, collisions, 2% distrib
Murmur1 1748.36 57.09 - UB, fails all tests, 1 bad seed
Murmur2 3849.99 36.80 - 358 UB, 1.7% bias, 81x coll, 1.7% distrib, BIC
Murmur2A 3849.80 49.35 - 407 UB, 12.7% bias, LongNeighbors
Murmur2B 7696.99 44.27 - 433 UB, 1.8% bias, collisions, 3.4% distrib, BIC
Murmur2C 3270.47 42.91 - 444 UB, 91% bias, collisions, distr, BIC, LongNeighbors
Murmur3A 3565.43 39.02 - 351 UB, Moment Chi2 69
PMurHash32 2597.43 57.16 - 1862 Moment Chi2 69
Murmur3C 4146.55 66.92 - 859 UB, LongNeighbors, DiffDist
PMPML_32 8653.56 37.02 - 1084 Avalanche >512, unseeded: Seed, MomentChi2
PMPML_64 8707.46 56.45 - 1305 unseeded: Seed, MomentChi2
xxHash32 5082.19 56.03 1056.72 (130) 738 LongNeighbors, collisions with 4bit diff, MomentChi2 220
metrohash64_1 19456.87 39.84 - 624 UB, LongNeighbors, BIC, MomentChi2
metrohash64_2 13346.09 47.67 - 627 UB, LongNeighbors
metrohash64crc_1 6853.68 36.46 - 632 UB, cyclic collisions 8 byte, BIC, MomentChi2, machine-specific (x64 SSE4.2)
metrohash64crc_2 7445.95 49.94 - 632 UB, cyclic collisions 8 byte, BIC, machine-specific (x64 SSE4.2)
metrohash128_1 13334.22 86.11 - 773 UB, LongNeighbors
metrohash128_2 17137.91 58.91 - 773 UB, LongNeighbors
cmetrohash64_1o 19467.11 32.11 - 3506 LongNeighbors, MomentChi2
cmetrohash64_1 13339.87 45.18 - 652 LongNeighbors, BIC, MomentChi2
cmetrohash64_2 19227.72 32.54 - 655 LongNeighbors
City64noSeed 12091.66 38.48 - 1038 Avalanche, Sparse, TwoBytes, MomentChi2, Seed
City64 12085.05 41.35 - 1120 Sparse, TwoBytes
t1ha1_64le 11664.19 36.58 939.55 (137) 517 Avalanche
t1ha1_64be 14545.63 26.00 - 555 Avalanche
t1ha0_32le 6211.81 53.52 - 509 Sparse, LongNeighbors
t1ha0_32be 5489.66 59.56 - 533 Sparse, LongNeighbors
t1ha2_stream 17418.77 64.63 500.29 (130) 1665 Sparse, Permutation, LongNeighbors
t1ha2_stream128 17412.54 76.63 511.85 (2) 1665 Sparse, Permutation, LongNeighbors
aesnihash 4692.47 52.55 1022.91 (101) 1209 fails many tests, machine-specific (x64 AES-NI)
aesni-hash-peterrk 35244.97 23.99 481.13 (26) machine-specific (x64 AES-NI)
falkhash 62025.17 128.28 - 264 Sparse, LongNeighbors, machine-specific (x64 AES-NI)
MeowHash 25687.35 72.84 - 1764 Sparse, machine-specific (x64 AES-NI)
MeowHash64low 25702.14 75.66 - 1764 Sparse, machine-specific (x64 AES-NI)
MeowHash32low 25682.13 71.34 - 1764 Sparse, machine-specific (x64 AES-NI)
tifuhash_64 145.75 411.32 810.71 (19) 276
beamsplitter 681.49 852.53 - UB
floppsyhash 143.47 636.04 - 623
chaskey 978.77 129.37 - 1609 PerlinNoise
SipHash 809.06 152.32 338.74 (4) 1071
HalfSipHash 1376.89 65.27 479.68 (1) 700 zeroes
GoodOAAT 922.03 68.14 461.18 (1) 237
pearsonbhash64 1934.12 104.95 - 683
pearsonbhash128 1649.15 96.61 - 1134
pearsonbhash256 1744.77 114.23 1018.63 (68) 844
prvhash64_64m 3838.73 38.31 471.23 (23) 349
prvhash64_64 3720.87 39.07 479.33 (120) 384
prvhash64_128 3986.91 70.61 605.25 (86) 718
prvhash64s_64 7249.18 240.06 774.15 (19) 2640
prvhash64s_128 7002.12 289.49 - 2799
SipHash13 2261.48 76.97 467.06 (1) 778 0.9% bias
discohash1 3480.40 226.85 - 1294
discohash1-128 3479.20 267.76 - 1294
discohash2 3480.47 220.02 - 1294
discohash2-128 3479.45 270.83 - 1294
discoNONG 3096.62 440.12 - bad seeds
pearsonhash64 461.13 117.89 910.22 (69) Avalanche, Seed, SSSE3 only. broken MSVC
pearsonhash128 540.86 123.36 933.05 (85) Avalanche, Seed, SSSE3 only. broken MSVC
pearsonhash256 493.77 131.55 - Avalanche, Seed, SSSE3 only. broken MSVC
TSip 5371.30 41.88 474.18 (2) 519 !msvc
aesni 37340.59 26.87 - 519 machine-specific (x64 AES-NI)
aesni-low 25760.44 34.90 - 519 machine-specific (x64 AES-NI)
seahash 10048.09 45.22 476.88 (5) 871 PerlinNoise, !msvc
seahash32low 10021.55 45.22 487.35 (1) 871 PerlinNoise, !msvc
clhash 23095.27 52.83 491.27 (4) 1809 PerlinNoise, machine-specific (x64 SSE4.2)
HighwayHash64 10293.59 84.62 530.66 (3) 2546
Murmur3F 9666.27 38.31 436.97 (2) 699 UB
fasthash32 5277.46 46.25 - 566 UB
fasthash64 5278.56 35.78 - 509 UB, Moment Chi2 5159 !
MUM 12228.56 28.52 434.85 (1) 1912 UB, too many bad seeds, machine-specific (32/64 differs)
MUMlow 12100.34 28.36 458.00 (3) 1912 UB, 5 bad seeds
xmsx32 2039.10 46.39 249.30 (7) 192 2 bad seeds
mirhash 8197.76 30.26 402.05 (1) 1112 2^36 bad seeds, UB, LongNeighbors, machine-specific (32/64 differs)
mirhash32low 8229.50 30.25 452.15 (1) 1112 4 bad seeds, UB, Cyclic, LongNeighbors, machine-specific (32/64 differs)
mirhashstrict 4737.68 39.95 430.11 (1) 1112
mirhashstrict32low 4737.63 39.87 456.85 (5) 1112 1 bad seed, MomentChi2 9
mx3 11391.98 38.88 420.45 (1) 734 UB
pengyhash 16544.54 58.81 491.94 (1) 421
City32 4877.34 49.39 - 1319
City64low 17961.33 36.73 481.23 (3) 1120
City128 17422.69 69.62 506.56 (2) 1841
CityCrc128 9915.82 55.41 488.65 (1) 295
CityCrc256 19603.25 42.27 149.40 (4)
FarmHash32 27580.96 37.26 481.39 (2) 11489 machine-specific (x64 SSE4/AVX)
FarmHash64 18098.22 37.42 461.90 (2) 3758
FarmHash128 17481.30 55.16 483.56 (2) 163
farmhash32_c 27566.57 37.21 480.67 (2) 762 machine-specific (x64 SSE4/AVX)
farmhash64_c 18087.55 38.45 455.54 (1) 3688
farmhash128_c 17261.07 54.93 485.75 (2) 1890
metrohash64 19418.82 38.74 - 624 LongNeighbors
metrohash128 16436.14 85.77 - 624 UB
metrohash128crc_1 6844.36 92.25 - 723 UB, machine-specific (x64 SSE4.2)
metrohash128crc_2 6857.62 92.26 - 723 UB, machine-specific (x64 SSE4.2)
xxHash64 15340.14 39.33 409.54 (1) 1999
Spooky32 16521.68 62.11 463.49 (2) 2221 UB
Spooky64 16555.70 61.79 440.94 (4) 2221 UB
Spooky128 16565.11 63.45 441.99 (5) 2221 UB
SpookyV2_32 16816.08 45.12 472.80 (19) 2069
SpookyV2_64 16879.61 45.18 490.62 (35) 2069
SpookyV2_128 16326.13 48.59 486.83 (124) 2069
t1ha2_atonce 17705.49 30.49 448.85 (1) 541
t1ha2_atonce128 17636.67 42.52 476.14 (1) 613 LongNeighbors
t1ha0_aes_noavx 34530.80 29.34 443.11 (7) 925 LongNeighbors, machine-specific (x86 AES-NI)
t1ha0_aes_avx1 34532.21 29.34 438.07 (1) 843 LongNeighbors, machine-specific (x64 AVX)
t1ha0_aes_avx2 69583.42 29.34 440.99 (2) 792 LongNeighbors, machine-specific (x64 AVX2)
ahash64 14705.55 23.34 458.05 (14) 412 rust
xxh3 25867.89 23.60 433.96 (2) 744 Moment Chi2 14974, BIC
xxh3low 25877.21 23.58 467.69 (2) 756 Moment Chi2 1.8e+9 !
xxh128 23950.99 26.60 457.73 (2) 1012 Moment Chi2 14974
xxh128low 23935.79 26.93 459.01 (2) 1012 Moment Chi2 14974, BIC
MeowHash 25687.35 72.84 - 1764 Sparse low32, machine-specific (x64 AES-NI)
MeowHash32low 25682.13 71.34 - 1764 Sparse, machine-specific (x64 AES-NI)
wyhash 27093.03 22.05 428.98 (1) 474
wyhash32 2532.89 37.95 222.17 (4) 426 4 bad and broken seeds, 32-bit
wyhash32low 26979.48 22.32 466.74 (5) 474 5 bad seeds
w1hash 2532.89 37.95 222.17 (4)
rapidhash 23789.79 22.80 138.71 (7) 574
rapidhash_unrolled 23892.88 23.41 139.47 (12) 782
umash32 19106.63 46.69 473.08 (4) 1530
umash32_hi 28063.01 33.41 474.46 (7) 1530
umash64 19055.83 42.97 560.92 (138) 1530
umash128 11243.58 37.45 469.42 (9) 1530
halftime_hash64 7320.03 91.23 598.61 (22) 1530
halftime_hash128 21097.01 73.68 587.12 (21) 1530
halftime_hash256 21188.10 79.11 579.31 (15) 1530
halftime_hash512 12815.44 92.22 595.51 (25) 1530
nmhash32 15739.53 45.37 468.34 (5) 2445
nmhash32x 15983.31 34.12 456.67 (3) 1494
k-hashv32 11312.23 43.05 519.40 (10) 1280
k-hashv64 11309.15 42.69 515.67 (19) 1279
komihash 12341.32 33.90 249.42 (15) 728
gxhash32 736 AES only
gxhash64 1017.15 178.25 313.64 (9) 720 AES only
Other timings:

Summary

I added some SSE assisted hashes and fast intel/arm CRC32-C and AES HW variants, but not the fastest crcutil yet. See our crcutil results. See also the old https://code.google.com/p/smhasher/w/list.

So the fastest hash functions on x86_64 without quality problems are:

Hash functions for symbol tables or hash tables typically use 32 bit hashes, for databases, file systems and file checksums typically 64 or 128bit, for crypto now starting with 256 bit.

Typical median key size in perl5 is 20, the most common 4. Similar for all other dynamic languages. See github.com/rurban/perl-hash-stats

When used in a hash table the instruction cache will usually beat the CPU and throughput measured here. In my tests the smallest FNV1A beats the fastest crc32_hw1 with Perl 5 hash tables. Even if those worse hash functions will lead to more collisions, the overall speed advantage and inline-ability beats the slightly worse quality. See e.g. A Seven-Dimensional Analysis of Hashing Methods and its Implications on Query Processing for a concise overview of the best hash table strategies, confirming that the simplest Mult hashing (bernstein, FNV*, x17, sdbm) always beat "better" hash functions (Tabulation, Murmur, Farm, ...) when used in a hash table.

The fast hash functions tested here are recommendable as fast for file digests and maybe bigger databases, but not for 32bit hash tables. The "Quality problems" lead to less uniform distribution, i.e. more collisions and worse performance, but are rarely related to real security attacks, just the 2nd sanity zeroes test against \0 invariance is security relevant.

Columns

MiB/sec: The average of the Bulk key speed test for alignments 0-7 with 262144-byte keys. The higher the better.

cycl./hash: The average of the Small key speed test for 1-31 byte keys. The smaller the better.

cycl./map: The result of the Hashmap test for /usr/dict/words with std::unordered_map get queries, with the standard deviation in brackets. This tests the inlinability of the hash function (see size). The smaller the better.

size: The object size in byte on AMD64. This affects the inlinability in e.g. hash tables. The smaller the better.

Quality problems: See the failures in the linked doc. The less the better.

Other

SECURITY

The hash table attacks described in SipHash against City, Murmur or Perl JenkinsOAAT or at Hash Function Lounge are not included here.

Such an attack avoidance cannot be the problem of the hash function, but only the hash table collision resolution scheme. You can attack every single hash function, even the best and most secure if you detect the seed, e.g. from language (mis-)features, side-channel attacks, collision timings and independly the sort-order, so you need to protect your collision handling scheme from the worst-case O(n), i.e. separate chaining with linked lists. Linked lists chaining allows high load factors, but is very cache-unfriendly. The only recommendable linked list scheme is inlining the key or hash into the array. Nowadays everybody uses fast open addressing, even if the load factor needs to be ~50%, unless you use Cuckoo Hashing.

I.e. the usage of SipHash for their hash table in Python 3.4, ruby, rust, systemd, OpenDNS, Haskell and OpenBSD is pure security theatre. SipHash is not secure enough for security purposes and not fast enough for general usage. Brute-force generation of ~32k collisions need 2-4m for all these hashes. siphash being the slowest needs max 4m, other typically max 2m30s, with <10s for practical 16k collision attacks with all hash functions. Using Murmur is usually slower than a simple Mult, even in the worst case. Provable secure is only uniform hashing, i.e. 2-5 independent Mult or Tabulation, or using a guaranteed logarithmic collision scheme (a tree) or a linear collision scheme, such as Robin Hood or Cockoo hashing with collision counting.

One more note regarding security: Nowadays even SHA1 can be solved in a solver, like Z3 (or faster ones) for practical hash table collision attacks (i.e. 14-20 bits). All hash functions with less than 160 bits tested here cannot be considered "secure" at all.

The '' vulnerability attack with binary keys is tested in the 2nd Sanity Zero test.

CRYPTO

The official NIST hash function testsuite does not do such extensive statistical tests, to search for weak ranges in the bits. Also crypto does not change the initial state, which we do here for our random 32bit seed. Crypto mostly cares about unreversable key -> hash functions without changing the initial fixed state and timings/sidechannel attacks.

The NIST "Cryptographic Algorithm Validation Program" (CAVP) involves the testing of the implementations of FIPS-approved and NIST-recommended cryptographic algorithms. During the NIST SHA-3 competition, the testing methodology was borrowed from the "CAVP", as the KATs and MCTs of the SHA-3 Competition Test Suite were based on the CAVP tests for SHA-2. In addition to this, the “Extremely Long Message Test,” not present in the CAVP for SHA-2, required the submitters to generate the hash value corresponding to a message with a length of 1 GiB. “NIST - Cryptographic Algorithm Validation Program (CAVP),” June 2017. Available: http://csrc.nist.gov/groups/STM/cavp (No testing source code provided, just high-level descriptions)

Two other independent third party testsuites found an extensive number of bugs and weaknesses in the SHA3 candidates. "Finding Bugs in Cryptographic Hash Function Implementations", Nicky Mouha, Mohammad S Raunak, D. Richard Kuhn, and Raghu Kacker, 2017. https://eprint.iacr.org/2017/891.pdf

Maybe independent researchers should come together to do a better public SHA-4 round, based on better and more testing methods, open source code for the tests, and using standard industry practices, such as valgrind, address-sanitizer and ubsan to detect obvious bugs.

PROBLEMS

Typical undefined behaviour (UB) problems: