• Stars
    star
    411
  • Rank 101,370 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A native implementation of the excellent XXHash hashing algorithm.

xxhash GoDoc Build Status Coverage

This is a native Go implementation of the excellent xxhash* algorithm, an extremely fast non-cryptographic Hash algorithm, working at speeds close to RAM limits.

  • The C implementation is (Copyright (c) 2012-2014, Yann Collet)

Install

go get github.com/OneOfOne/xxhash

Features

  • On Go 1.7+ the pure go version is faster than CGO for all inputs.
  • Supports ChecksumString{32,64} xxhash{32,64}.WriteString, which uses no copies when it can, falls back to copy on appengine.
  • The native version falls back to a less optimized version on appengine due to the lack of unsafe.
  • Almost as fast as the mostly pure assembly version written by the brilliant cespare, while also supporting seeds.
  • To manually toggle the appengine version build with -tags safe.

Benchmark

Core i7-4790 @ 3.60GHz, Linux 4.12.6-1-ARCH (64bit), Go tip (+ff90f4af66 2017-08-19)

➤ go test -bench '64' -count 5 -tags cespare | benchstat /dev/stdin
name                          time/op

# https://github.com/cespare/xxhash
XXSum64Cespare/Func-8          160ns ± 2%
XXSum64Cespare/Struct-8        173ns ± 1%
XXSum64ShortCespare/Func-8    6.78ns ± 1%
XXSum64ShortCespare/Struct-8  19.6ns ± 2%

# this package (default mode, using unsafe)
XXSum64/Func-8                 170ns ± 1%
XXSum64/Struct-8               182ns ± 1%
XXSum64Short/Func-8           13.5ns ± 3%
XXSum64Short/Struct-8         20.4ns ± 0%

# this package (appengine, *not* using unsafe)
XXSum64/Func-8                 241ns ± 5%
XXSum64/Struct-8               243ns ± 6%
XXSum64Short/Func-8           15.2ns ± 2%
XXSum64Short/Struct-8         23.7ns ± 5%

CRC64ISO-8                    1.23µs ± 1%
CRC64ISOString-8              2.71µs ± 4%
CRC64ISOShort-8               22.2ns ± 3%

Fnv64-8                       2.34µs ± 1%
Fnv64Short-8                  74.7ns ± 8%

Usage

	h := xxhash.New64()
	// r, err := os.Open("......")
	// defer f.Close()
	r := strings.NewReader(F)
	io.Copy(h, r)
	fmt.Println("xxhash.Backend:", xxhash.Backend)
	fmt.Println("File checksum:", h.Sum64())

playground

TODO

  • Rewrite the 32bit version to be more optimized.
  • General cleanup as the Go inliner gets smarter.

License

This project is released under the Apache v2. license. See LICENSE for more details.

More Repositories

1

struct2ts

Generate Typescript classes/interfaces out of Go structs
Go
138
star
2

lfchan

A scalable lock-free channel.
Go
133
star
3

netchan

Go channels over a network.
Go
83
star
4

go-utils

Random Go Language utilities that don't warrant their own repos.
Go
50
star
5

cmap

A sharded map implementation to support fast concurrent access and swap/update operations.
Go
46
star
6

genx

GenX: Generics For Go, Yet Again.
Go
37
star
7

go-nfqueue

Go Wrapper For Creating IPTables NFQueue clients in Go
Go
29
star
8

xast

xast: ast rewriter with built-in clean up.
Go
26
star
9

pia-socks-proxy

An Alpine Linux container running a socks5 proxy (using dante) via Private Internet Access (OpenVPN).
Dockerfile
16
star
10

git-go-vendor

Simple go vendoring using git submodules.
Go
12
star
11

cch

cch: closable safe go channels
Go
7
star
12

radix

radix: a go radix tree with nearest matching
Go
6
star
13

resize

Pure golang image resizing
Go
4
star
14

generics.pw

source code for https://generics.pw
Go
4
star
15

dynamic-routes

Dynamic routes for Express.JS
JavaScript
4
star
16

cgoVSsyso

Go
3
star
17

genh

genh: generics helpers
Go
3
star
18

seahash

A SeaHash Implentation in Go
Go
2
star
19

vscode-save-runner

Save Runner for Visual Studio Code
TypeScript
2
star
20

bctx

context helpers
Go
2
star
21

wjsu

syscall/js wasm helper
Go
2
star
22

dvcs-helper

A helper to (dumb)-sync DVCS repos over php/ftp.
Python
2
star
23

gzippo

gzippo pronounced `g-zippo` is a nodejs gzip middleware for Connect and express js using Compress for improved performace.
JavaScript
1
star
24

Secure-Browser-Chat

1
star
25

closer

Go
1
star
26

otk

Go
1
star
27

stc

Go
1
star
28

rlog

Go
1
star
29

slowbolt

slowbolt: log slow update/view bolt calls
Go
1
star
30

jdb

A file-backed ACID in-memory k/v data store.
Go
1
star
31

limiter

Go
1
star
32

skiplist

a simple skiplist
Go
1
star
33

msgpack

Go
1
star
34

segmentedSlice

A fast, index-able, sort-able, grow-only Slice.
Go
1
star
35

mgo.ejson

A simple package to Marshal/Unmarshal MongoDB's EJson in Go.
Go
1
star
36

webview

Go
1
star
37

oerrs

Yet another go package with an error list
Go
1
star
38

td

TD Ameritrade unofficial Go API Client
Go
1
star
39

etc-fish

My Fish Shell configuration
Shell
1
star