mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-01-16 14:21:03 +01:00
During tests it was noticed that the current hash is not that good on 4- and 5- bit hashes. About 7.5% of all the 32-bit primes were tested as candidates for the hash function, by submitting them 128 arrangements of N pointers among 40k extracted from haproxy's pools, and the average fill rates for 1- to 12- bit hashes were measured and compared. It was clear that some values do not provide great hashes and other ones are way more resistant. The current value is not bad at all but delivers 42.6% unique 2-bit outputs, 41.6% 3-bit, 38.0% 4-bit, 38.2% 5-bit and 37.1% 10-bit. Some values did perform significantly better, among which 0xacd1be85 which does 43.2% 2-bit, 42.5% 3-bit, 42.2% 4-bit, 39.2% 5-bit and 37.3% 10-bit. The reverse value used in the ptr2_hash() was really underperforming and was replaced with 0x9d28e4e9 which does 49.6%, 40.4%, 42.6%, 39.1%, and 37.2% respectvely. This should slightly improve the accuracy of the task and memory profiling, and will be useful for pools.