[llvm-dev] Default hashing function for integers (DenseMapInfo.h)

Francois Fayard via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 10 09:40:45 PST 2017


> On Jan 10, 2017, at 4:51 PM, mats petersson <mats at planetcatfish.com> wrote:
> 
> Yes, it seems to be "good". But it's always good to understand WHY.

I’ll be glad to understand how is has been crafted, especially where does to 9 come from. I would be glad to know if it is an experimental number or something that comes from thoughts around malloc?

I have also worked on the hashing for integers and my first test was trying to measure difference in performance when putting the worst hash function you can think of for integers : hash(k) = 0. It turns out that the difference I measured is below 0.5 %, which is below the noise of repeating experience. So, with my benchmark (compiling a .cpp file with clang with -O3), the quality of the hash for integers doe not matter at all. It seems that the usage of integers as keys is very low.

François Fayard


More information about the llvm-dev mailing list