Default timings with a modern AMD Ryzen 5 PRO 3350G 3.6GHz workstation:
Hash function | MiB/sec | cycl./hash | cycl./map | size | Quality problems |
---|---|---|---|---|---|
donothing32 | 11536809.55 | 4.00 | - | 13 | test NOP |
donothing64 | 12269832.97 | 4.00 | - | 13 | test NOP |
donothing128 | 11961841.48 | 4.08 | - | 13 | test NOP |
NOP_OAAT_read64 | 11652662.97 | 14.00 | - | 47 | test NOP |
BadHash | 794.68 | 72.80 | - | 47 | test FAIL |
sumhash | 10184.67 | 29.40 | - | 363 | test FAIL |
sumhash32 | 44755.87 | 23.46 | - | 863 | UB, test FAIL |
multiply_shift | 8286.63 | 25.39 | 209.06 (2) | 345 | fails all tests |
pair_multiply_shift | 5728.05 | 39.67 | 218.48 (12) | 609 | fails all tests |
crc32 | 369.88 | 142.33 | 396.81 (101) | 422 | insecure, 8590x collisions, distrib |
md5_32 | 359.43 | 638.92 | 865.21 (6) | 4419 | |
md5_64 | 360.20 | 640.38 | 869.55 (6) | 4419 | |
md5-128 | 344.63 | 669.59 | 856.34 (5) | 4419 | |
sha1_32 | 581.56 | 727.61 | 1006.74 (15) | 5126 | Sanity, collisions, 36.6% distrib |
sha1_64 | 574.08 | 763.85 | 1023.04 (8) | 5126 | Sanity, collisions, 36.6% distrib |
sha1-160 | 583.43 | 804.38 | 1073.46 (5) | 5126 | Comb/Cyclic low3 |
sha2-224 | 233.93 | 913.20 | 1138.44 (5) | Cyclic low32 | |
sha2-224_64 | 231.39 | 919.76 | 1155.33 (4) | Cyclic low32 | |
sha2-256 | 231.65 | 916.38 | 1125.80 (5) | ||
sha2-256_64 | 238.41 | 914.98 | 1156.78 (11) | ||
sha1ni | 1632.88 | 170.77 | 379.84 (5) | 989 | insecure,sanity, Permutation, Zeroes, amd epyc only |
sha1ni_32 | 1583.50 | 172.17 | 387.70 (4) | 989 | insecure,sanity, Permutation, Zeroes, TwoBytes, amd epyc only |
sha2ni-256 | 1556.66 | 180.75 | 393.79 (5) | 4241 | insecure,sanity, Permutation, Zeroes, amd epyc only |
sha2ni-256_64 | 1508.82 | 184.89 | 393.07 (6) | 4241 | insecure,sanity, Permutation, Zeroes, TwoBytes, amd epyc only |
blake3_c | 1298.04 | 354.25 | 563.63 (4) | no 32bit portability | |
rmd128 | 294.42 | 712.67 | 930.65 (4) | ||
rmd160 | 188.73 | 1065.27 | 1302.59 (4) | ||
rmd256 | 366.21 | 615.39 | 830.04 (7) | ||
edonr224 | 863.77 | 304.76 | 496.66 (3) | ||
edonr256 | 870.97 | 296.40 | 517.82 (6) | ||
blake2s-128 | 342.97 | 638.83 | 814.87 (4) | ||
blake2s-160 | 341.74 | 659.29 | 852.11 (6) | ||
blake2s-224 | 338.62 | 663.16 | 810.94 (4) | ||
blake2s-256 | 341.65 | 645.77 | 817.15 (3) | ||
blake2s-256_64 | 338.46 | 672.72 | 823.38 (5) | ||
blake2b-160 | 578.32 | 780.45 | 975.69 (4) | ||
blake2b-224 | 578.57 | 767.44 | 904.19 (7) | ||
blake2b-256 | 582.49 | 757.63 | 949.62 (4) | Sparse high 32-bit | |
blake2b-256_64 | 579.28 | 765.02 | 953.39 (5) | ||
asconhashv12 | 162.99 | 840.29 | 904.60 (4) | 6490 | |
asconhashv12_64 | 159.33 | 402.54 | 473.15 (4) | 4341 | |
sha3-256 | 125.98 | 3120.58 | 3384.96 (6) | PerlinNoise | |
sha3-256_64 | 124.64 | 3107.12 | 3392.77 (6) | PerlinNoise | |
hasshe2 | 2879.93 | 62.47 | 272.34 (2) | 445 | Permutation,TwoBytes,Zeroes,Seed |
poly_1_mersenne | 1278.37 | 63.42 | 244.41 (1) | 479 | fails most tests |
poly_2_mersenne | 1391.90 | 69.97 | 255.44 (3) | 479 | |
poly_3_mersenne | 1320.15 | 80.81 | 263.12 (2) | 479 | |
poly_4_mersenne | 1393.93 | 89.07 | 262.97 (2) | 479 | |
tabulation32 | 5819.40 | 40.16 | 233.00 (3) | 848 | collisions |
tabulation | 7407.94 | 39.83 | 240.25 (4) | 554 | |
crc32_hw | 5537.79 | 40.80 | 225.65 (3) | 653 | insecure, 100% bias, collisions, distrib, machine-specific (x86 SSE4.2) |
crc32_hw1 | 7626.17 | 50.21 | 228.50 (2) | 671 | insecure, 100% bias, collisions, distrib, machine-specific (x86 SSE4.2) |
crc64_hw | 5579.17 | 40.87 | 202.19 (1) | 652 | insecure, 100% bias, collisions, distrib, machine-specific (x64 SSE4.2) |
crc32_pclmul | 7963.20 | 106.02 | 567.70 (3) | 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 | 11530366.92 | 18.40 | 206.94 (1) | 101 | insecure, zeros, fails all tests |
fibonacci | 15409.62 | 22.67 | 872.83 (3) | 1692 | UB, zeros, fails all tests |
FNV1a | 754.70 | 75.28 | 226.30 (2) | 204 | zeros, fails all tests |
FNV1A_Totenschiff | 6166.85 | 26.60 | 235.71 (2) | 270 | UB, zeros, fails all tests |
FNV1A_Pippip_Yurii | 6115.29 | 28.03 | 233.52 (2) | 147 | UB, sanity, fails all tests |
FNV1a_YT | 13481.70 | 30.67 | 233.71 (7) | 321 | UB, fails all tests |
FNV2 | 5630.87 | 32.09 | 207.08 (1) | 278 | fails all tests |
FNV64 | 747.70 | 74.18 | 189.18 (1) | 79 | fails all tests |
FNV128 | 408.59 | 130.82 | 299.47 (20) | 171 | fails all tests |
k-hash32 | 2227.90 | 53.85 | 255.78 (2) | 808 | UB, insecure, zeros, fails all tests |
k-hash64 | 2492.66 | 48.18 | 242.58 (2) | 609 | UB, insecure, zeros, fails all tests |
fletcher2 | 15410.12 | 20.72 | 345.55 (5) | 248 | UB, fails all tests |
fletcher4 | 15603.68 | 21.24 | 320.09 (2) | 371 | UB, fails all tests |
bernstein | 1032.00 | 59.04 | 225.09 (3) | 41 | fails all tests |
sdbm | 772.01 | 71.67 | 220.09 (2) | 41 | fails all tests |
x17 | 765.01 | 75.61 | 225.81 (2) | 79 | 99.98% bias, fails all tests |
libiberty | 618.39 | 86.58 | 220.95 (2) | 37 | insecure, 100% bias, fails all tests |
gcc | 612.10 | 88.44 | 224.62 (2) | 39 | insecure, 100% bias, fails all tests |
JenkinsOOAT | 615.60 | 111.23 | 251.08 (2) | 153 | 53.5% bias, fails all tests |
JenkinsOOAT_perl | 631.79 | 93.13 | 232.44 (1) | 65 | 1.5-11.5% bias, 7.2x collisions, LongNeighbors |
MicroOAAT | 730.89 | 78.25 | 236.07 (3) | 68 | 100% bias, distrib |
VHASH_32 | 13084.37 | 65.45 | 280.14 (2) | 1231 | sanity, Seed, MomentChi2 |
VHASH_64 | 13217.64 | 64.90 | 270.04 (2) | 1231 | sanity, Seed, Sparse |
farsh32 | 27583.89 | 65.65 | 266.64 (2) | 944 | insecure: AppendedZeroes, collisions+bias, MomentChi2, LongNeighbors |
farsh64 | 13558.69 | 113.74 | 327.26 (3) | 944 | insecure: AppendedZeroes, collisions+bias, MomentChi2, LongNeighbors |
farsh128 | 7055.39 | 229.42 | 375.57 (4) | ?? | |
farsh256 | 3466.26 | 444.74 | 610.23 (4) | ?? | |
jodyhash32 | 1762.46 | 42.66 | 236.09 (2) | 102 | bias, collisions, distr, LongNeighbors |
jodyhash64 | 4861.84 | 44.05 | 234.35 (2) | 118 | bias, collisions, distr, LongNeighbors |
lookup3 | 2474.09 | 40.19 | 238.22 (3) | 341 | UB, 28% bias, collisions, 30% distr |
superfast | 2085.79 | 49.89 | 230.76 (3) | 210 | UB, 91% bias, 5273.01x collisions, 37% distr, BIC |
MurmurOAAT | 513.75 | 105.23 | 244.81 (4) | 47 | collisions, 99.998% distr., BIC, LongNeighbors |
Crap8 | 3081.04 | 37.15 | 234.94 (2) | 342 | UB, 2.42% bias, collisions, 2% distrib |
Murmur1 | 1955.36 | 48.84 | 236.25 (2) | UB, fails all tests, 1 bad seed | |
Murmur2 | 3082.03 | 41.62 | 250.72 (4) | 358 | UB, 1.7% bias, 81x coll, 1.7% distrib, BIC |
Murmur2A | 2850.40 | 46.60 | 284.58 (13) | 407 | UB, 12.7% bias, LongNeighbors |
Murmur2B | 6039.96 | 38.70 | 212.23 (1) | 433 | UB, 1.8% bias, collisions, 3.4% distrib, BIC |
Murmur2C | 3802.68 | 49.82 | 220.13 (2) | 444 | UB, 91% bias, collisions, distr, BIC, LongNeighbors |
Murmur3A | 3027.30 | 48.99 | 234.49 (2) | 351 | UB, Moment Chi2 69 |
PMurHash32 | 3001.44 | 48.99 | 240.35 (3) | 1862 | Moment Chi2 69 |
Murmur3C | 4824.95 | 57.39 | 243.91 (2) | 859 | UB, LongNeighbors, DiffDist |
PMPML_32 | 6904.30 | 44.25 | 233.59 (2) | 1084 | Avalanche >512, unseeded: Seed, MomentChi2 |
PMPML_64 | 10030.67 | 49.22 | 239.07 (5) | 1305 | unseeded: Seed, MomentChi2 |
xxHash32 | 6064.37 | 48.86 | 234.27 (3) | 738 | LongNeighbors, collisions with 4bit diff, MomentChi2 220 |
metrohash64_1 | 14495.30 | 40.83 | 213.00 (2) | 624 | UB, LongNeighbors, BIC, MomentChi2 |
metrohash64_2 | 14359.39 | 41.09 | 215.53 (2) | 627 | UB, LongNeighbors |
metrohash64crc_1 | 8010.90 | 44.43 | 213.94 (2) | 632 | UB, cyclic collisions 8 byte, BIC, MomentChi2, machine-specific (x64 SSE4.2) |
metrohash64crc_2 | 7939.65 | 44.84 | 222.01 (2) | 632 | UB, cyclic collisions 8 byte, BIC, machine-specific (x64 SSE4.2) |
metrohash128_1 | 15556.40 | 73.49 | 259.05 (2) | 773 | UB, LongNeighbors |
metrohash128_2 | 15408.56 | 74.36 | 259.57 (2) | 773 | UB, LongNeighbors |
cmetrohash64_1o | 14678.56 | 40.33 | 216.44 (2) | 3506 | LongNeighbors, MomentChi2 |
cmetrohash64_1 | 14332.75 | 41.04 | 216.05 (2) | 652 | LongNeighbors, BIC, MomentChi2 |
cmetrohash64_2 | 14498.20 | 40.87 | 219.65 (2) | 655 | LongNeighbors |
City64noSeed | 14023.27 | 33.37 | 223.59 (2) | 1038 | Avalanche, Sparse, TwoBytes, MomentChi2, Seed |
City64 | 14390.09 | 46.69 | 231.99 (2) | 1120 | Sparse, TwoBytes |
t1ha1_64le | 13425.03 | 31.37 | 221.97 (2) | 517 | Avalanche |
t1ha1_64be | 12002.50 | 31.57 | 226.52 (2) | 555 | Avalanche |
t1ha0_32le | 7276.16 | 49.11 | 236.39 (2) | 509 | Sparse, LongNeighbors |
t1ha0_32be | 6860.87 | 50.16 | 241.26 (2) | 533 | Sparse, LongNeighbors |
t1ha2_stream | 13673.22 | 81.12 | 263.88 (3) | 1665 | Sparse, Permutation, LongNeighbors |
t1ha2_stream128 | 13913.43 | 94.60 | 296.15 (4) | 1665 | Sparse, Permutation, LongNeighbors |
aesnihash | 5365.60 | 57.21 | 255.87 (3) | 1209 | fails many tests, machine-specific (x64 AES-NI) |
aesni-hash-peterrk | 29107.73 | 28.86 | 217.57 (1) | machine-specific (x64 AES-NI) | |
falkhash | 52401.48 | 122.70 | 316.79 (4) | 264 | Sparse, LongNeighbors, machine-specific (x64 AES-NI) |
MeowHash | 29969.81 | 64.90 | 273.79 (8) | 1764 | Sparse, machine-specific (x64 AES-NI) |
MeowHash64low | 29438.45 | 63.76 | 269.41 (4) | 1764 | Sparse, machine-specific (x64 AES-NI) |
MeowHash32low | 30562.54 | 63.77 | 283.26 (3) | 1764 | Sparse, machine-specific (x64 AES-NI) |
tifuhash_64 | 160.97 | 506.35 | 531.87 (8) | 276 | |
beamsplitter | 572.71 | 806.67 | 920.45 (4) | UB | |
floppsyhash | 154.90 | 578.30 | 598.75 (5) | 623 | |
chaskey | 1142.38 | 113.98 | 288.04 (1) | 1609 | PerlinNoise |
SipHash | 953.51 | 147.32 | 332.02 (5) | 1071 | |
HalfSipHash | 1128.85 | 80.48 | 260.42 (2) | 700 | zeroes |
GoodOAAT | 744.67 | 87.23 | 243.36 (2) | 237 | |
pearsonbhash64 | 1749.98 | 99.84 | 257.11 (2) | 683 | |
pearsonbhash128 | 1656.68 | 106.78 | 276.92 (3) | 1134 | |
pearsonbhash256 | 1418.61 | 123.68 | 301.26 (3) | 844 | |
prvhash64_64m | 3107.77 | 47.31 | 236.76 (2) | 349 | |
prvhash64_64 | 3057.79 | 47.83 | 244.16 (2) | 384 | |
prvhash64_128 | 3340.87 | 67.90 | 264.44 (2) | 718 | |
prvhash64s_64 | 6724.41 | 266.09 | 438.90 (3) | 2640 | |
prvhash64s_128 | 6703.66 | 326.46 | 508.67 (3) | 2799 | |
SipHash13 | 1803.96 | 107.93 | 304.05 (3) | 778 | 0.9% bias |
discohash1 | 4152.62 | 202.14 | 414.34 (4) | 1294 | bad seeds |
discohash1-128 | 4064.39 | 231.06 | 430.94 (6) | 1294 | |
discohash2 | 4026.84 | 204.37 | 408.13 (6) | 1294 | |
discohash2-128 | 4153.48 | 226.54 | 429.24 (4) | 1294 | |
discoNONG | 3661.23 | 397.81 | 651.23 (54) | bad seeds | |
pearsonhash64 | 439.85 | 123.07 | 213.68 (1) | Avalanche, Seed, SSSE3 only. broken MSVC | |
pearsonhash128 | 438.49 | 123.81 | 212.89 (2) | Avalanche, Seed, SSSE3 only. broken MSVC | |
pearsonhash256 | 440.63 | 120.72 | 224.63 (2) | Avalanche, Seed, SSSE3 only. broken MSVC | |
TSip | 4330.87 | 52.43 | 245.31 (2) | 519 | !msvc |
aesni | 31185.98 | 29.45 | 226.75 (2) | 519 | machine-specific (x64 AES-NI) |
aesni-low | 31027.39 | 29.47 | 232.54 (2) | 519 | machine-specific (x64 AES-NI) |
seahash | 8240.58 | 58.61 | 260.35 (1) | 871 | PerlinNoise, !msvc |
seahash32low | 8245.91 | 58.61 | 264.07 (2) | 871 | PerlinNoise, !msvc |
clhash | 22932.36 | 67.22 | 262.78 (2) | 1809 | PerlinNoise, machine-specific (x64 SSE4.2) |
HighwayHash64 | 10293.59 | 84.62 | 530.66 (3) | 2546 | |
Murmur3F | 7104.08 | 52.69 | 216.34 (2) | 699 | UB |
fasthash32 | 6107.05 | 40.49 | 237.83 (2) | 566 | UB |
fasthash64 | 5600.11 | 38.04 | 219.71 (2) | 509 | UB, Moment Chi2 5159 ! |
MUM | 9631.26 | 34.78 | 219.14 (2) | 1912 | UB, too many bad seeds, machine-specific (32/64 differs) |
MUMlow | 8532.17 | 35.95 | 238.37 (2) | 1912 | UB, 5 bad seeds |
xmsx32 | 2105.03 | 45.35 | 238.92 (3) | 192 | 2 bad seeds |
mirhash | 5793.85 | 38.15 | 212.91 (2) | 1112 | 2^36 bad seeds, UB, LongNeighbors, machine-specific (32/64 differs) |
mirhash32low | 6168.04 | 38.35 | 234.32 (2) | 1112 | 4 bad seeds, UB, Cyclic, LongNeighbors, machine-specific (32/64 differs) |
mirhashstrict | 3587.79 | 49.85 | 219.49 (2) | 1112 | |
mirhashstrict32low | 3642.77 | 50.16 | 233.34 (3) | 1112 | 1 bad seed, MomentChi2 9 |
mx3 | 9332.99 | 47.07 | 221.61 (2) | 734 | UB |
pengyhash | 13347.17 | 74.79 | 278.74 (3) | 421 | |
City32 | 5745.83 | 52.44 | 242.69 (2) | 1319 | |
City64low | 13119.17 | 47.92 | 251.81 (2) | 1120 | |
City128 | 14472.20 | 88.71 | 285.61 (10) | 1841 | |
CityCrc128 | 12255.05 | 89.25 | 281.85 (2) | 295 | |
CityCrc256 | 12428.45 | 164.93 | 358.73 (2) | ||
FarmHash32 | 22136.14 | 46.75 | 258.73 (2) | 11489 | machine-specific (x64 SSE4/AVX) |
FarmHash64 | 12929.54 | 46.82 | 238.50 (2) | 3758 | |
FarmHash128 | 14454.12 | 68.09 | 254.04 (2) | 163 | |
farmhash32_c | 22150.13 | 46.08 | 251.43 (3) | 762 | machine-specific (x64 SSE4/AVX) |
farmhash64_c | 12925.73 | 46.76 | 239.47 (2) | 3688 | |
farmhash128_c | 14284.69 | 68.80 | 256.66 (3) | 1890 | |
metrohash64 | 14209.14 | 40.85 | 225.16 (2) | 624 | LongNeighbors |
metrohash128 | 15847.63 | 72.33 | 266.54 (2) | 624 | UB |
metrohash128crc_1 | 8182.02 | 77.38 | 256.80 (2) | 723 | UB, machine-specific (x64 SSE4.2) |
metrohash128crc_2 | 7996.33 | 78.81 | 262.53 (2) | 723 | UB, machine-specific (x64 SSE4.2) |
xxHash64 | 11176.72 | 49.67 | 230.24 (6) | 1999 | |
Spooky32 | 13623.84 | 55.45 | 248.11 (3) | 2221 | UB |
Spooky64 | 13400.95 | 55.06 | 244.86 (3) | 2221 | UB |
Spooky128 | 13621.00 | 59.05 | 235.42 (2) | 2221 | UB |
SpookyV2_32 | 13626.51 | 56.19 | 256.57 (19) | 2069 | |
SpookyV2_64 | 13401.13 | 56.18 | 246.33 (11) | 2069 | |
SpookyV2_128 | 12252.64 | 58.94 | 235.46 (2) | 2069 | |
t1ha2_atonce | 14275.60 | 37.02 | 224.12 (2) | 541 | |
t1ha2_atonce128 | 14059.85 | 56.44 | 251.53 (3) | 613 | LongNeighbors |
t1ha0_aes_noavx | 27335.47 | 37.34 | 230.59 (2) | 925 | LongNeighbors, machine-specific (x86 AES-NI) |
t1ha0_aes_avx1 | 27881.52 | 36.78 | 227.13 (2) | 843 | LongNeighbors, machine-specific (x64 AVX) |
t1ha0_aes_avx2 | 56581.83 | 36.51 | 223.59 (1) | 792 | LongNeighbors, machine-specific (x64 AVX2) |
ahash64 | 14705.55 | 23.34 | 458.05 (14) | 412 | rust |
xxh3 | 20853.74 | 29.46 | 220.07 (2) | 744 | Moment Chi2 14974, BIC |
xxh3low | 20568.96 | 29.98 | 243.82 (5) | 756 | Moment Chi2 1.8e+9 ! |
xxh128 | 19259.99 | 31.58 | 228.84 (2) | 1012 | Moment Chi2 14974 |
xxh128low | 19555.88 | 30.85 | 227.83 (2) | 1012 | Moment Chi2 14974, BIC |
MeowHash | 29969.81 | 64.90 | 273.79 (8) | 1764 | Sparse low32, machine-specific (x64 AES-NI) |
MeowHash32low | 30562.54 | 63.77 | 283.26 (3) | 1764 | Sparse, machine-specific (x64 AES-NI) |
wyhash | 22640.53 | 28.91 | 229.00 (2) | 474 | |
wyhash32 | 2532.89 | 37.95 | 222.17 (4) | 426 | 4 bad and broken seeds, 32-bit |
wyhash32low | 23104.85 | 28.56 | 239.71 (4) | 474 | 5 bad seeds |
w1hash | 14208.56 | 26.85 | 221.76 (2) | ||
rapidhash | 22147.09 | 29.07 | 214.80 (2) | 574 | |
rapidhash_unrolled | 21723.13 | 29.40 | 220.97 (3) | 782 | |
umash32 | 21999.19 | 41.14 | 239.07 (2) | 1530 | |
umash32_hi | 22347.33 | 41.22 | 251.12 (4) | 1530 | |
umash64 | 21963.54 | 41.12 | 228.34 (1) | 1530 | |
umash128 | 13629.66 | 41.65 | 228.25 (1) | 1530 | |
halftime_hash64 | 4801.79 | 99.05 | 310.02 (2) | 1530 | |
halftime_hash128 | 18220.34 | 94.31 | 307.50 (1) | 1530 | |
halftime_hash256 | 18249.32 | 97.56 | 322.85 (2) | 1530 | |
halftime_hash512 | 10906.18 | 118.54 | 326.76 (3) | 1530 | |
nmhash32 | 12676.08 | 57.09 | 255.20 (2) | 2445 | |
nmhash32x | 13072.64 | 42.09 | 288.12 (3) | 1494 | |
k-hashv32 | 8393.09 | 53.95 | 252.98 (3) | 1280 | |
k-hashv64 | 9251.05 | 51.72 | 251.83 (2) | 1279 | |
komihash | 12179.74 | 33.23 | 224.80 (2) | 1323 | |
polymur | 9913.53 | 41.68 | 232.56 (3) | 1128 | |
komihash | 12179.74 | 33.23 | 224.80 (2) | 728 | |
gxhash32 | 47943.08 | 37.71 | 251.38 (2) | 736 | AES only |
gxhash64 | 48919.73 | 36.61 | 236.98 (3) | 720 | AES only |
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.
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.
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.
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.
Typical undefined behaviour (UB) problems:
Misaligned
Many word-wise hashes (in opposite to safe byte-wise processing)
don't check the input buffer for proper word alignment, which will
fail with ubsan or Sparc. word being int32_t
or int64_t
or even
more. On some old RISC hardware this will be a BUS error, you can
even let Intel HW generate such a bus error by setting some CPU
flag. But generally using misaligned accesses is fine.
These are: mx3, Spooky, mirhash (but not strict), MUM, fasthash, Murmur3*, Murmur2*, metrohash* (all but cmetro*), Crap8, beamsplitter, lookup3, fletcher4, fletcher2, all sanmayce FNV1a_ variants (FNV1a_YT, FNV1A_Pippip_Yurii, FNV1A_Totenschiff, ...), fibonacci
The usual mitigation is to check the buffer alignment either in the caller, provide a pre-processing loop for the misaligned prefix, or copy the whole buffer into a fresh aligned area.
oob - Out of bounds
Some hash function assume a padded input buffer which can be accessed past its length up to the word size. This allows for faster loop processing, as no 2nd loop or switch table for the rest is needed, but it requires a cooperative calling enviroment and is as such considered cheating.
Signed integer overflow
A simple type error, this hash needs to use unsigned integer types internally, to avoid undefined and inconsistent behaviour. i.e. SuperFastHash: signed integer overflow: -2147483641 + -113 cannot be represented in type 'int'
shift exponent overflow
With: FNV1A_Pippip_Yurii, FNV1A_Totenschiff, pair_multiply_shift, sumhash32 shift exponent 64 is too large for 64-bit type 'long unsigned int'