In asm, load primes from globals rather than using macros This also improves the speed slightly. Maybe just because of smaller code size? benchmark old ns/op new ns/op delta BenchmarkHashes/xxhash,n=5b-4 9.69 9.23 -4.75% BenchmarkHashes/xxhash,n=20b-4 11.7 11.4 -2.56% BenchmarkHashes/xxhash,n=100b-4 24.4 23.6 -3.28% BenchmarkHashes/xxhash,n=4KB-4 384 375 -2.34% BenchmarkHashes/xxhash,n=10MB-4 1113137 1089693 -2.11% benchmark old MB/s new MB/s speedup BenchmarkHashes/xxhash,n=5b-4 515.96 541.56 1.05x BenchmarkHashes/xxhash,n=20b-4 1704.45 1761.10 1.03x BenchmarkHashes/xxhash,n=100b-4 4092.55 4245.48 1.04x BenchmarkHashes/xxhash,n=4KB-4 10406.76 10638.45 1.02x BenchmarkHashes/xxhash,n=10MB-4 8983.62 9176.89 1.02x
xxhash is a Go implementation of the 64-bit xxHash algorithm, XXH64. This is a high-quality hashing algorithm that is much faster than anything in the Go standard library.
On amd64 there is an even faster assembly implementation that runs at over 10 GB/s on my laptop.