Mark []byte passed to Sum64 as noescape
The compiler cannot tell if arguments passed to an asm function escape
so it assumes that they always do. Mark arguments passed to Sum64 as
noescape so any temporary created from a []byte(string) conversion does
not escape.
% benchstat {old,new}.txt
name old time/op new time/op delta
StringHash-4 80.8ns ± 4% 20.8ns ± 0% -74.25% (p=0.000 n=10+9)
name old alloc/op new alloc/op delta
StringHash-4 16.0B ± 0% 0.0B ±NaN% -100.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
StringHash-4 1.00 ± 0% 0.00 ±NaN% -100.00% (p=0.000 n=10+10)
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.