You're right that it's only putting some extra computation into it,
but I don't think there is any way that a prime modulo would make any
good hash function worse; the only problem is some wasted effort.

A problem is that I'm not sure of the quality of the hash functions we
use internally either. The string hash is a homebrew (afaik), and in
several other places pointers are used as hash values.

As for the string hash, I made an attempt to search for published
alternatives, but I couldn't find any that hashes in O(1) - all of
them hashes on the whole string. I think an O(1) hash function is very
important in our case. Anyway, it should be possible to sort this out.

Pointers are worse. They can contain all sorts of periodicity. An
obvious one is that the lowest one or two bits always are zero due to
alignment, but there might be more due to the malloc implementation
and its allocation patterns, and you'd never know about it (well, in
the case of all the block_alloc areas we do know a bit about it, but
it's different for each and every one of them). A prime modulo is very
effective to put all such concerns to rest. Maybe there are other
smart ideas on how to make good hashes out of pointers; I haven't
checked yet.

One more concern is also how it behaves for the ultimately bad hash
function, i.e. one that returns the same value all the time. In that
case the hash table is of course O(n) on lookup and store, but it
shouldn't try to grow the table all the time due to a reprobe limit. I
don't know if he found a clever way to avoid that.
  • Lock free hash map... Martin Stjernholm, Roxen IS @ Pike developers forum
    • Lock free has... Jonas Walld�n @ Pike developers forum
      • Lock free... Martin Stjernholm, Roxen IS @ Pike developers forum
        • Re: L... Stephen R. van den Berg
          • R... Martin Stjernholm, Roxen IS @ Pike developers forum
            • ... Stephen R. van den Berg
              • ... Henrik Grubbstr�m (Lysator) @ Pike (-) developers forum
                • ... Stephen R. van den Berg
              • ... Martin Stjernholm, Roxen IS @ Pike developers forum
                • ... Stephen R. van den Berg
                • ... Martin Stjernholm, Roxen IS @ Pike developers forum
    • Re: Lock free... Stephen R. van den Berg
      • Re: Lock ... Martin Stjernholm, Roxen IS @ Pike developers forum

Reply via email to