I just pushed a patch which optimises our hash function somewhat by using a hybrid approach, with an optimised OAATH for short keys (16 bytes or less), and Siphash 1-3, for the rest. For longer keys, say 50 byte or up, Siphash 1-3 makes a big difference. By the time you get to 1k keys or longer it makes a HUGE difference. For shorter keys I unrolled the OAATH logic so it doesn't have so much overhead. The new OAATH code is a touch different in that it hashes back to front. 32 bit builds should be unchanged, and continue to use the previous OAATH logic. Siphash 1-3 is used by Rust, and is faster than Siphash 2-4, while still being "secure enough". BTW, I apologise for pushing this without a smoke round, I got a little fast-finger-memory and pushed to blead when I should have pushed to a branch. Normally I would have discussed this a bit wider first. Here are the timings from the change using Porting/bench.pl for keys of length 1..24, 50, 100, and 1000. I believe most keys in a process are short, hence the bias in the benchmarks. The numbers represent relative counts per loop iteration, compared to blead at 100.0%. Higher is better: for example, using half as many instructions gives 200%, while using twice as many gives 50%. hash::set1k::len_0001 hash keys length 1 blead yves ------ ------ Ir 100.00 100.75 Dr 100.00 101.08 Dw 100.00 101.70 COND 100.00 101.61 IND 100.00 75.04 COND_m 100.00 97.92 IND_m 100.00 70.00 Ir_m1 100.00 4450.00 Dr_m1 100.00 100.09 Dw_m1 100.00 99.42 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0002 hash keys length 2 blead yves ------ ------ Ir 100.00 100.76 Dr 100.00 101.10 Dw 100.00 101.72 COND 100.00 101.64 IND 100.00 75.05 COND_m 100.00 99.39 IND_m 100.00 77.78 Ir_m1 100.00 4450.00 Dr_m1 100.00 100.07 Dw_m1 100.00 99.46 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0003 hash keys length 3 blead yves ------ ------ Ir 100.00 100.94 Dr 100.00 101.30 Dw 100.00 102.05 COND 100.00 102.05 IND 100.00 75.06 COND_m 100.00 101.72 IND_m 100.00 100.00 Ir_m1 100.00 1950.00 Dr_m1 100.00 99.78 Dw_m1 100.00 99.76 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0004 hash keys length 4 blead yves ------ ------ Ir 100.00 101.24 Dr 100.00 101.64 Dw 100.00 102.57 COND 100.00 102.74 IND 100.00 75.06 COND_m 100.00 100.66 IND_m 100.00 100.00 Ir_m1 100.00 1950.00 Dr_m1 100.00 99.40 Dw_m1 100.00 99.24 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0005 hash keys length 5 blead yves ------ ------ Ir 100.00 101.52 Dr 100.00 101.95 Dw 100.00 103.07 COND 100.00 103.43 IND 100.00 75.06 COND_m 100.00 95.62 IND_m 100.00 100.00 Ir_m1 100.00 1950.00 Dr_m1 100.00 99.66 Dw_m1 100.00 100.01 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0006 hash keys length 6 blead yves ------ ------ Ir 100.00 101.84 Dr 100.00 102.31 Dw 100.00 103.61 COND 100.00 104.12 IND 100.00 75.06 COND_m 100.00 102.58 IND_m 100.00 100.00 Ir_m1 100.00 1950.00 Dr_m1 100.00 100.18 Dw_m1 100.00 99.03 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0007 hash keys length 7 blead yves ------ ------ Ir 100.00 102.18 Dr 100.00 102.70 Dw 100.00 104.14 COND 100.00 104.94 IND 100.00 75.06 COND_m 100.00 100.29 IND_m 100.00 100.00 Ir_m1 100.00 93.98 Dr_m1 100.00 99.75 Dw_m1 100.00 99.09 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0008 hash keys length 8 blead yves ------ ------ Ir 100.00 102.40 Dr 100.00 102.93 Dw 100.00 104.63 COND 100.00 105.51 IND 100.00 75.06 COND_m 100.00 140.83 IND_m 100.00 100.00 Ir_m1 100.00 93.98 Dr_m1 100.00 99.40 Dw_m1 100.00 99.97 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0009 hash keys length 9 blead yves ------ ------ Ir 100.00 102.69 Dr 100.00 103.25 Dw 100.00 105.15 COND 100.00 106.24 IND 100.00 75.06 COND_m 100.00 140.16 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 99.93 Dw_m1 100.00 99.92 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0010 hash keys length 10 blead yves ------ ------ Ir 100.00 102.97 Dr 100.00 103.56 Dw 100.00 105.67 COND 100.00 106.94 IND 100.00 75.06 COND_m 100.00 146.64 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 99.82 Dw_m1 100.00 98.65 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0011 hash keys length 11 blead yves ------ ------ Ir 100.00 103.29 Dr 100.00 103.92 Dw 100.00 106.20 COND 100.00 107.72 IND 100.00 75.06 COND_m 100.00 144.43 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 100.20 Dw_m1 100.00 100.69 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0012 hash keys length 12 blead yves ------ ------ Ir 100.00 103.68 Dr 100.00 104.38 Dw 100.00 106.78 COND 100.00 108.64 IND 100.00 75.06 COND_m 100.00 154.50 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 100.61 Dw_m1 100.00 99.20 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0013 hash keys length 13 blead yves ------ ------ Ir 100.00 103.93 Dr 100.00 104.64 Dw 100.00 107.29 COND 100.00 109.32 IND 100.00 75.06 COND_m 100.00 150.58 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 101.69 Dw_m1 100.00 99.82 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0014 hash keys length 14 blead yves ------ ------ Ir 100.00 104.05 Dr 100.00 104.72 Dw 100.00 107.73 COND 100.00 109.76 IND 100.00 75.06 COND_m 100.00 147.02 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 100.09 Dw_m1 100.00 98.94 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0015 hash keys length 15 blead yves ------ ------ Ir 100.00 104.32 Dr 100.00 105.01 Dw 100.00 108.26 COND 100.00 110.48 IND 100.00 75.06 COND_m 100.00 145.46 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 100.46 Dw_m1 100.00 99.48 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0016 hash keys length 16 blead yves ------ ------ Ir 100.00 104.54 Dr 100.00 105.23 Dw 100.00 108.76 COND 100.00 111.09 IND 100.00 75.06 COND_m 100.00 139.15 IND_m 100.00 100.00 Ir_m1 100.00 47.85 Dr_m1 100.00 99.75 Dw_m1 100.00 99.67 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0017 hash keys length 17 blead yves ------ ------ Ir 100.00 100.44 Dr 100.00 96.60 Dw 100.00 100.49 COND 100.00 108.85 IND 100.00 75.06 COND_m 100.00 146.97 IND_m 100.00 100.00 Ir_m1 100.00 2600.00 Dr_m1 100.00 100.34 Dw_m1 100.00 99.26 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0018 hash keys length 18 blead yves ------ ------ Ir 100.00 100.96 Dr 100.00 97.36 Dw 100.00 100.92 COND 100.00 109.35 IND 100.00 75.06 COND_m 100.00 139.74 IND_m 100.00 100.00 Ir_m1 100.00 2600.00 Dr_m1 100.00 98.65 Dw_m1 100.00 99.59 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0019 hash keys length 19 blead yves ------ ------ Ir 100.00 101.58 Dr 100.00 98.26 Dw 100.00 101.41 COND 100.00 110.04 IND 100.00 75.06 COND_m 100.00 140.42 IND_m 100.00 100.00 Ir_m1 100.00 2600.00 Dr_m1 100.00 99.49 Dw_m1 100.00 100.01 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0020 hash keys length 20 blead yves ------ ------ Ir 100.00 102.22 Dr 100.00 99.18 Dw 100.00 101.91 COND 100.00 110.86 IND 100.00 75.06 COND_m 100.00 144.08 IND_m 100.00 100.00 Ir_m1 100.00 3900.00 Dr_m1 100.00 100.11 Dw_m1 100.00 99.57 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0021 hash keys length 21 blead yves ------ ------ Ir 100.00 102.85 Dr 100.00 100.08 Dw 100.00 102.40 COND 100.00 111.61 IND 100.00 75.06 COND_m 100.00 147.80 IND_m 100.00 100.00 Ir_m1 100.00 3900.00 Dr_m1 100.00 101.66 Dw_m1 100.00 100.23 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0022 hash keys length 22 blead yves ------ ------ Ir 100.00 103.41 Dr 100.00 100.89 Dw 100.00 102.87 COND 100.00 112.24 IND 100.00 75.06 COND_m 100.00 146.65 IND_m 100.00 100.00 Ir_m1 100.00 3900.00 Dr_m1 100.00 100.29 Dw_m1 100.00 99.47 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0023 hash keys length 23 blead yves ------ ------ Ir 100.00 103.97 Dr 100.00 101.70 Dw 100.00 103.33 COND 100.00 112.88 IND 100.00 75.06 COND_m 100.00 143.60 IND_m 100.00 100.00 Ir_m1 100.00 2600.00 Dr_m1 100.00 101.03 Dw_m1 100.00 99.85 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0024 hash keys length 24 blead yves ------ ------ Ir 100.00 102.44 Dr 100.00 99.50 Dw 100.00 103.26 COND 100.00 112.60 IND 100.00 75.06 COND_m 100.00 137.30 IND_m 100.00 100.00 Ir_m1 100.00 1950.00 Dr_m1 100.00 100.07 Dw_m1 100.00 99.68 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0050 hash keys length 50 blead yves ------ ------ Ir 100.00 110.70 Dr 100.00 110.30 Dw 100.00 113.87 COND 100.00 127.62 IND 100.00 75.06 COND_m 100.00 148.43 IND_m 100.00 100.00 Ir_m1 100.00 3900.00 Dr_m1 100.00 100.65 Dw_m1 100.00 99.66 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_0100 hash keys length 100 blead yves ------ ------ Ir 100.00 119.81 Dr 100.00 122.37 Dw 100.00 128.53 COND 100.00 147.72 IND 100.00 75.06 COND_m 100.00 99.89 IND_m 100.00 100.00 Ir_m1 100.00 913.70 Dr_m1 100.00 99.58 Dw_m1 100.00 100.08 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 hash::set1k::len_1000 hash keys length 1000 blead yves ------ ------ Ir 100.00 147.57 Dr 100.00 151.97 Dw 100.00 294.09 COND 100.00 330.60 IND 100.00 75.23 COND_m 100.00 100.60 IND_m 100.00 100.00 Ir_m1 100.00 560.33 Dr_m1 100.00 100.05 Dw_m1 100.00 99.98 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 AVERAGE blead yves ------ ------ Ir 100.00 104.47 Dr 100.00 103.97 Dw 100.00 107.63 COND 100.00 112.16 IND 100.00 75.07 COND_m 100.00 125.75 IND_m 100.00 97.42 Ir_m1 100.00 137.11 Dr_m1 100.00 100.10 Dw_m1 100.00 99.62 Ir_mm 100.00 100.00 Dr_mm 100.00 100.00 Dw_mm 100.00 100.00 Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Next