Does anyone have any data on what the typical key size is (i.e. the average input size for the hash)?
I have a couple of optimisations for the MurmurHash3 implementation that I think give another 10-40% speedup, particularly for smaller values (e.g. 30% speedup for buffer lengths under 256 bytes) and no worse for large values (tens of KB). These results were on a AMD Phenom II X6 1055T @ 2.80 GHz, under 64-bit Windows 7, Java 1.6.0_27.
Firstly, inline the rotl64 calls , e.g. so that
k1 = (k1 << 31) | (k1 >>> 33);
Secondly, rather than a large switch-case to handle the 'tail', use nested if-else to form a simple binary search. Particularly for relatively small inputs, handling the 'tail' is a significant part of the computation. E.g:
int ln = length & 15;
if (ln > 8)
if (ln > 12)
// etc for cases 13 - 15
// cases 11 and 12
// etc for cases 1-7
Will try to post a proper benchmark when I've tidied it up (run out of time today!) so anyone interested can try it on other hardware...
This latter optimisation is pretty verbose and ugly to look at - it might be just as fast, and much more concise, to lookup the offsets and shifts from an array, and deal with the special cases 1 and 9 as, well, special cases - but haven't benchmarked this alternative yet...