benchmarking Perl client hash functions

Larry Leszczynski larryl@emailplus.org
Mon, 19 Jul 2004 15:07:36 -0400 (Eastern Daylight Time)


On Sun, 18 Jul 2004, Brad Fitzpatrick wrote:

> How about we try and make every client either use CRC32 or optionally
> support CRC32.  The defaults can be whatever, as long as CRC32 can be
> switched to.

I've got an almost-done patch for the Perl client that does this, should
be able to post shortly.  I'd guess the default should be to use the
existing algorithm, for backward compatibility.


> Some languages (PHP, Java, Ruby?) seem to have their own fast internal
> hashes available, so let's not interfere with their fast code for
> non-mixed cases.

Do all the clients currently support (or could they support) the hashfunc
from the Perl client?  i.e.:
    foreach (split //, shift) {
        $hash = $hash*33 + ord($_);
    }

If so, might be nice to support three hash method options something like:
   'builtin' meaning like the current Perl client
             (probably need a better name)
   'crc32'   meaning "(crc32(shift) >> 16) & 0x7fff"
   'native'  meaning internal language-dependent
             (if there is one, otherwise use builtin)

That way in a mixed-client environment you could interoperate if they're
all set to 'builtin' or they're all set to 'crc32'.

Or maybe that's overkill and just having 'crc32' and 'native' are enough,
with 'crc32' being the one to use in a mixed-client environment?


Larry