
Originally Posted by
brewbuck
It doesn't actually have to be that much bigger than needed to start making a difference. I recently worked on a project (CornedBee's game of life challenge, actually), where I discovered that using a better hash function actually led to worse iteration performance.
I could not believe it myself at first. Some investigation with a profiler revealed that the "smart" hash function was spreading things out better (as it was supposed to), but this caused performance to DECREASE when iterating over all the elements in the table, since so much time was spent looking in empty buckets. A good spread makes lookup/insertion more efficient but can actually hurt iteration. So there you go.
This was a normal set of affairs, not a pathological case. So I reverted back to the stupid hash function which didn't spread things out very well, and got the performance back up.