tree: f21be2db04e39681bfea3b7b2677386b54d180c0 [path history] [tgz]
  1. LICENSE.txt
  3. go.mod
  4. go.sum
  5. rotate.go
  6. rotate19.go
  7. xxhash.go
  8. xxhash_amd64.go
  9. xxhash_amd64.s
  10. xxhash_other.go
  11. xxhash_safe.go
  12. xxhash_unsafe.go



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                                                                                                                                                                                              !
package xxhash // import ""

Package xxhash implements the 64-bit variant of xxHash (XXH64) as described

func New() hash.Hash64
func Sum64(b []byte) uint64
func Sum64String(s string) 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,

input sizeOneOfOnecespare (purego)cespare
5 B416 MB/s720 MB/s872 MB/s
100 B3980 MB/s5013 MB/s5252 MB/s
4 KB12727 MB/s12999 MB/s13026 MB/s
10 MB9879 MB/s10775 MB/s10913 MB/s

These numbers were generated with:

$ go test -benchtime 10s -bench '/OneOfOne,'
$ go test -tags purego -benchtime 10s -bench '/xxhash,'
$ go test -benchtime 10s -bench '/xxhash,'

Projects using this package