xxhash
A pure-Go implementation of the 64-bit xxHash (XXH64) algorithm with hand-written amd64 and arm64 assembly for maximum throughput.
Repository Health
Technical Analysis
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) uint64andSum64String(s string) uint64pair for one-shot hashing with no setup - A
Digesttype implementing the standard library’shash.Hash64interface for streaming/incremental hashing - Hand-written amd64 and arm64 assembly implementations for maximum throughput, selected automatically at build time
- A
puregobuild tag that forces the portable pure-Go path on any architecture, including ones without assembly support MarshalBinary/UnmarshalBinarysupport onDigestfor persisting and resuming hash state- A small
xxhsumCLI utility (inxxhsum/) 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
agentgateway
AI Development · Developer Tools
An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.
Caddy
Devops · Security
The only web server that obtains and renews TLS certificates automatically, with HTTP/1-2-3 support and zero dependency on external runtimes.
Coder
Devops · Developer Tools · Code Editors
Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.
Dolt
Databases · Data Engineering · Developer Tools
The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.
Flipt
Devops · Developer Tools
Git-native feature flag platform that stores, versions, and deploys feature toggles directly in your own Git repositories with no external database required.
Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.
Mattermost
Team Chat · Collaboration · Devops
Open core, self-hosted team collaboration with chat, AI agents, voice calling, and deep DevOps integrations — all under your control.
MinIO
File Storage
High-performance, S3-compatible object storage built for AI/ML and analytics workloads — run it anywhere from a laptop to a petabyte-scale cluster.
Netdata
Monitoring · Devops
Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.