Murmur3 - Website

Work in Progress. It's inner-loop is the fastest of the three Murmur hashes, but it's mixing, both before and after the post-processing, is the worst of the three.

Tests

Performance

Implementation

finline u32 fastcall Murmur3( const u8 *key, u32 len, u32 seed ) {
	#define mmix3(h,k) { k *= m1; k = rot(k,r1); k *= m2; h *= 3; h ^= k; }

	const u32 m1 = 0x0acffe3d, m2 = 0x0e4ef5f3, m3 = 0xa729a897;
	const u32 r1 = 11, r2 = 18, r3 = 18;

	u32 h = len + seed, k = 0;

	const u32 *dwords = (const u32 *)key;
	while( len >= 4 ) {
		k = *dwords++;
		mmix3(h,k);
		len -= 4;
	}

	const u8 *tail = (const u8 *)dwords;
	switch( len ) {
		case 3: k ^= tail[2] << 16;
		case 2: k ^= tail[1] << 8;
		case 1: k ^= tail[0];
			mmix3(h,k);
	};

	h ^= h >> r2;
	h *= m3;
	h ^= h >> r3;
	return h;
}