Embarrassingly poor performance of regular point sets with std::unordered_set
Matthijs Sypkens Smit

Interesting read. It goes to show that one must be very careful with hashing functions, and what they do. A common misunderstanding is that a hash function will somehow “scramble” the input into some sort of unpredictable result. But no, a hash function will simply distribute input equally over hashes, and it may be very predictable.

In fact, you should be very suspicious of this line of code, that solved your problem:

const auto betterHash = std::hash<size_t>()(hash);

In case the variable hash is of type size_t, it is quite possible in some implementations that the hashing function is trivial, i.e. it simply maps an integer onto itself.

In my experience, it can pay off to just write your own hash function, so at least you know what is going on.

Show your support

Clapping shows how much you appreciated Mathijs Romans’s story.