rurban / smhasher

Hash function quality and speed tests
https://rurban.github.io/smhasher/
Other
1.85k stars 178 forks source link

check speed tests against volatile len #85

Closed rurban closed 4 years ago

rurban commented 4 years ago

Realistic hashes and hashmaps do not know the len at runtime. Knowing the alignment is ok, but knowing the seed or len is not ok. The compiler does then optimize away costly runtime branches or switches.

Ensure that the len in the two speedtests are not const, known to the compiler. E.g. wyhash was found to be much slower than xxh3 with runtime len, because the len switch was optimized away

rurban commented 4 years ago

looked at the assembly. all hash calls in the speed tests are indirect, which is even worse. re benchmakring it's fair, but real world usage not. at least the len problem is not existing there.