Skip to content

v0.2.0 (Feb 24, 2022)

Compare
Choose a tag to compare
@fxamacker fxamacker released this 25 Feb 04:23
· 111 commits to main since this release
ac446d1

What's Changed

Seeded CircleHash64 reached 10GB/s at less than 64-byte inputs and 15GB/s at 256-byte inputs.

  • Optimize CircleHash64 without using assembly language by @fxamacker in #8
  • Update ci-go-cover.yml and add CircleHash128 to TODOs by @fxamacker in #9

Full Changelog: v0.1.0...v0.2.0

What is CircleHash?

CircleHash is a family of non-cryptographic hash functions. CircleHash64 uses the fractional digits of π as default constants (nothing up my sleeve). CircleHash64 is fast, simple, and easy to audit/maintain.

CircleHash64 uses CircleHash64f by default, which is based on Google's Abseil C++ library internal hash.

CircleHash64 Abseil C++ SipHash-2-4 xxh64
SAC worst-bit
0-128 byte inputs
(lower % is better)
0.791% 🥇
w/ 99 bytes
0.862%
w/ 67 bytes
0.852%
w/ 125 bytes
0.832%
w/ 113 bytes

☝️ Using demerphq/smhasher updated to test all input sizes 0-128 bytes (SAC test will take hours longer to run).

CircleHash64 is very fast at hashing short inputs with a 64-bit seed.

CircleHash64
(seeded)
XXH3
(seeded)
XXH64
(w/o seed)
SipHash
(seeded)
4 bytes 1.34 GB/s 1.21 GB/s 0.877 GB/s 0.361 GB/s
8 bytes 2.70 GB/s 2.41 GB/s 1.68 GB/s 0.642 GB/s
16 bytes 5.48 GB/s 5.21 GB/s 2.94 GB/s 1.03 GB/s
32 bytes 8.01 GB/s 7.08 GB/s 3.33 GB/s 1.46 GB/s
64 bytes 10.3 GB/s 9.33 GB/s 5.47 GB/s 1.83 GB/s
128 bytes 12.8 GB/s 11.6 GB/s 8.22 GB/s 2.09 GB/s
192 bytes 14.2 GB/s 9.86 GB/s 9.71 GB/s 2.17 GB/s
256 bytes 15.0 GB/s 8.19 GB/s 10.2 GB/s 2.22 GB/s
  • Using Go 1.17.7, darwin_amd64, i7-1068NG7 CPU.
  • Results from go test -bench=. -count=20 and benchstat
  • Fastest XXH64 (written in Go+Assembly) doesn't support seed.

CircleHash64 was created when I needed a very fast hash for input sizes typically <= 128 bytes.

ℹ️ Non-cryptographic hashes should only be used in software designed to properly handle hash collisions. If you require a secure hash, please use a cryptographic hash (like the ones in SHA-3 standard).