Avoid function call overhead

This is not a good solution, but it'll do for the moment.

noasm:

 benchmark                            old MB/s     new MB/s     speedup
BenchmarkHashes/xxhash,n=5_B-4       383.10       596.40       1.56x
BenchmarkHashes/xxhash,n=100_B-4     3558.30      4301.40      1.21x
BenchmarkHashes/xxhash,n=4_KB-4      8778.69      8840.83      1.01x
BenchmarkHashes/xxhash,n=10_MB-4     7731.16      7736.64      1.00x

asm:

benchmark                            old MB/s     new MB/s     speedup
BenchmarkHashes/xxhash,n=5_B-4       539.76       711.11       1.32x
BenchmarkHashes/xxhash,n=100_B-4     4227.89      4598.95      1.09x
BenchmarkHashes/xxhash,n=4_KB-4      10590.16     10549.72     1.00x
BenchmarkHashes/xxhash,n=10_MB-4     9058.39      9024.04      1.00x
6 files changed
tree: b9d13b0340392beba56e84ccc72370173d4bcc66
  1. xxhsum/
  2. LICENSE.txt
  3. README.md
  4. xxhash.go
  5. xxhash_amd64.go
  6. xxhash_amd64.s
  7. xxhash_amd64_test.go
  8. xxhash_other.go
  9. xxhash_test.go
README.md

xxhash

GoDoc

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.

The API is very small, taking its cue from the other hashing packages in the standard library:

$ go doc github.com/cespare/xxhash                                                                                                                                                                                              !
package xxhash // import "github.com/cespare/xxhash"

Package xxhash implements the 64-bit variant of xxHash (XXH64) as described
at http://cyan4973.github.io/xxHash/.

func New() hash.Hash64
func Sum64(b []byte) uint64

This implementation provides a fast pure-Go implementation and an even faster assembly implementation for amd64.

Here are some quick benchmarks comparing the pure-Go and assembly implementations of Sum64 against another popular Go XXH64 implementation, github.com/OneOfOne/xxhash:

input sizeOneOfOnecespare (noasm)cespare
5 B438.34 MB/s596.40 MB/s711.11 MB/s
100 B3676.54 MB/s4301.40 MB/s4598.95 MB/s
4 KB8128.64 MB/s8840.83 MB/s10549.72 MB/s
10 MB7335.19 MB/s7736.64 MB/s9024.04 MB/s