Skip to content

Commit

Permalink
Ease IMUL 5, h1 32 bits hash (~10 % for > 256 B).
Browse files Browse the repository at this point in the history
Replace by a left shift and an addition. Generated code for 64 bits
version already map to the even most adequate `LEA`.

On a mid-2012 MBA,

benchmark                    old MB/s     new MB/s     speedup
Benchmark32_1-4              90.18        91.08        1.01x
Benchmark32_2-4              168.26       168.55       1.00x
Benchmark32_4-4              342.13       338.26       0.99x
Benchmark32_8-4              587.46       584.68       1.00x
Benchmark32_16-4             981.80       990.72       1.01x
Benchmark32_32-4             1349.67      1370.62      1.02x
Benchmark32_64-4             1684.94      1696.83      1.01x
Benchmark32_128-4            1748.24      1746.80      1.00x
Benchmark32_256-4            1805.96      1933.24      1.07x
Benchmark32_512-4            1845.56      2019.75      1.09x
Benchmark32_1024-4           1856.36      2031.61      1.09x
Benchmark32_2048-4           1890.43      2032.47      1.08x
Benchmark32_4096-4           1881.13      2085.36      1.11x
Benchmark32_8192-4           1889.83      2103.02      1.11x
  • Loading branch information
Sébastien Paolacci committed Aug 19, 2017
1 parent 7d4be12 commit 9f5d223
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions murmur32.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (d *digest32) bmix(p []byte) (tail []byte) {

h1 ^= k1
h1 = (h1 << 13) | (h1 >> 19) // rotl32(h1, 13)
h1 = h1*5 + 0xe6546b64
h1 = h1*4 + h1 + 0xe6546b64
}
d.h1 = h1
return p[nblocks*d.Size():]
Expand Down Expand Up @@ -134,7 +134,7 @@ func Sum32WithSeed(data []byte, seed uint32) uint32 {

h1 ^= k1
h1 = (h1 << 13) | (h1 >> 19) // rotl32(h1, 13)
h1 = h1*5 + 0xe6546b64
h1 = h1*4 + h1 + 0xe6546b64
}

tail := data[nblocks*4:]
Expand Down

0 comments on commit 9f5d223

Please sign in to comment.