xxhash

A pure-Go implementation of the 64-bit xxHash (XXH64) algorithm with hand-written amd64 and arm64 assembly for maximum throughput.

Library
Go
vv2.3.0
2,148 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
39 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
84 /100 Excellent
Architecture 80
Code Quality 85
Innovation 82
Learning Curve 90

xxhash implements XXH64, the 64-bit variant of the xxHash non-cryptographic hashing algorithm, as a small, dependency-free Go module. The package exposes a minimal API — a one-shot Sum64/Sum64String pair plus a Digest type implementing hash.Hash64 for streaming writes — so it drops into existing Go code with almost no integration cost. On amd64 and arm64 it dispatches to hand-tuned assembly for a significant throughput boost over the pure-Go path, while a purego build tag keeps a portable fallback available for every other architecture.

Because it is fast, allocation-free, and has zero third-party dependencies, xxhash/v2 has become a default choice for internal hashing needs across the Go ecosystem — it is vendored or imported directly by projects like InfluxDB, Prometheus, VictoriaMetrics, Badger, and Ristretto for tasks such as cache-key generation, sharding, and checksum computation where cryptographic strength is unnecessary and speed is the priority.

What You Get

  • A Sum64(b []byte) uint64 and Sum64String(s string) uint64 pair for one-shot hashing with no setup
  • A Digest type implementing the standard library’s hash.Hash64 interface for streaming/incremental hashing
  • Hand-written amd64 and arm64 assembly implementations for maximum throughput, selected automatically at build time
  • A purego build tag that forces the portable pure-Go path on any architecture, including ones without assembly support
  • MarshalBinary/UnmarshalBinary support on Digest for persisting and resuming hash state
  • A small xxhsum CLI utility (in xxhsum/) for hashing files or stdin from the command line

Common Use Cases

  • Generating fast, well-distributed cache keys for in-memory or distributed caches
  • Computing checksums for data integrity checks where cryptographic security is not required
  • Sharding or partitioning keys across nodes based on a fast, uniform hash distribution
  • Deduplicating byte slices or strings in high-throughput data pipelines
  • Implementing custom hash-map or bloom-filter style structures that need a fast non-cryptographic hash function

Under The Hood

Architecture

The package has a flat, single-package layout with no internal layering — xxhash.go holds the core algorithm state (Digest), the round/mergeRound helper functions, and the prime constants, while xxhash_asm.go and xxhash_other.go use Go build tags to select between assembly (xxhash_amd64.s, xxhash_arm64.s) and a portable Go implementation of the same two exported functions (Sum64, writeBlocks) at compile time — a build-tag dispatch pattern rather than a runtime branch, so choosing the fast path costs nothing at run time. The Digest struct carries only its four accumulator words, a small internal buffer, and a length counter, and both Write and Sum64 mutate this state directly with no heap allocations. Because the abstraction boundary is simply “these two functions must exist and agree,” changing the core hashing algorithm would require updating three parallel implementations — amd64 assembly, arm64 assembly, and the portable Go fallback — in lockstep.

Tech Stack

go.mod declares Go 1.11 compatibility with zero external dependencies; the module targets amd64 and arm64 via hand-written Go assembly fed straight to the Go toolchain’s own assembler, with xxhash_unsafe.go using unsafe.Pointer for zero-copy string-to-byte conversion on supported platforms and xxhash_safe.go as the non-unsafe counterpart used elsewhere. CI runs go test -bench across recent Go versions on Linux, macOS, and Windows for native amd64/arm64, plus a QEMU-emulated matrix covering 386/arm/arm64 to validate the pure-Go path on architectures without hand-written assembly. There is no build system beyond the standard go build/go test; the only shipped binary is the small xxhsum CLI in its own subdirectory.

Code Quality

Test files provide table-driven tests and benchmarks, and the CI matrix runs them under both the assembly and purego build tags to guarantee the fast and portable implementations stay bit-identical. Error handling is deliberately minimal — Write never fails, matching the hash.Hash contract — with errors reserved for MarshalBinary/UnmarshalBinary on malformed state. Naming follows standard-library hashing conventions (Sum64, Digest, Reset), and the internals favor small, individually documented helper functions over dense one-off code. No linter configuration is present, but the source is consistently gofmt-formatted and idiomatic.

API Design The public surface is intentionally tiny — two free functions (Sum64, Sum64String) plus one struct satisfying the standard library’s hash.Hash64 interface — so most callers need nothing beyond the package doc comment to get started, and existing code written against hash.Hash64 works unmodified. The build-tag-driven fast/portable dispatch and the purego escape hatch stay invisible to callers, so ergonomics never trade off against performance. The tradeoff is a narrow, unconfigurable scope: this package implements XXH64 only, not the newer XXH3 or 32-bit variants, so projects needing multiple hash families must reach for a different module.

Used by 18 apps in this directory

Go
79%
Apache 2.0

OpenMeter

Developer Tools · Invoicing Finance

2,401

Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.

View details
87
Repo Health
81
Technical
66
Dependency
Built with
Go 79%
TypeScript 16%
Updated 1 weeks ago
TypeScript
56%
AGPL 3.0

Prisme Analytics

Analytics

134

A self-hosted, privacy-focused web analytics platform built on Go and ClickHouse, with a ~2KB cookieless tracking script and Grafana-based dashboards for users, teams, and multi-organization access.

View details
38
Repo Health
61
Technical
76
Dependency
Built with
TypeScript 56%
Go 38%
Updated 8 months ago
Go
90%
AGPL 3.0

Pyroscope

Developer Tools · Devops · Monitoring

11,703

An open-source, horizontally scalable continuous profiling platform that pinpoints CPU, memory, and I/O bottlenecks down to the exact line of code, built by Grafana Labs alongside Loki, Tempo, and Mimir.

View details
92
Repo Health
89
Technical
65
Dependency
Built with
Go 90%
Updated 6 days ago
TypeScript
50%
Other

SigNoz

Analytics · Monitoring

32,429

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
64
Dependency
Built with
TypeScript 50%
Go 38%
Updated 1 weeks ago
Go
100%
Apache 2.0

SpiceDB

Authentication · Databases · Security

7,169

An open source, Google Zanzibar-inspired authorization database that models permissions as relationships and evaluates fine-grained access checks at massive scale with single-digit millisecond latency.

View details
89
Repo Health
89
Technical
67
Dependency
Built with
Go 100%
Updated 1 weeks ago
Go
90%
BSD 3

tau

Devops

5,180

Open-source, Git-native platform-as-a-service for building, deploying, and scaling fullstack apps on your own infrastructure with no DevOps required.

View details
71
Repo Health
82
Technical
65
Dependency
Built with
Go 90%
Updated 2 months ago
Go
54%
AGPL 3.0

Uptrace

Devops · Monitoring

4,305

Unified open-source APM that collects OpenTelemetry traces, metrics, and logs into a single self-hosted platform backed by ClickHouse.

View details
71
Repo Health
70
Technical
65
Dependency
Built with
Go 54%
Vue 34%
Updated 1 weeks ago
Go
79%
MIT

Wakapi

Analytics · Developer Tools

4,462

Self-hosted WakaTime-compatible coding statistics backend that gives developers full control over their coding activity data.

View details
89
Repo Health
77
Technical
72
Dependency
Built with
Go 79%
HTML 11%
Updated 1 weeks ago
Go
97%
BSD 3

Weaviate

Databases · Search

16,908

Open-source vector database combining semantic search, hybrid queries, RAG, and image search in a single cloud-native system built for production scale.

View details
91
Repo Health
85
Technical
68
Dependency
Built with
Go 97%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers