When a Go service tracks millions of keys or latency samples, plain maps and slices blow up quickly: one million float64 values eat 8 MB right away, and string keys push the heap toward OOMKilled. Classics like Bloom filters, HyperLogLog, and t-digest save memory, yet at scale they still waste RAM or miss badly on tail outliers. Let's look at four modern replacements in the Go module nalgeon/unsure v0.2.0 (MIT, zero dependencies, Go 1.25+).
Binary Fuse Filter and UltraLogLog: tighter filters and counters
For static key sets (SSTables, leaked password lists, cache dictionaries), a Binary Fuse Filter beats Bloom on size. Instead of a bit array, it stores 8-, 16-, or 32-bit fingerprints across three slots whose XOR equals the key's fingerprint. At 8 bits, the false-positive rate (FPR) is 0.39% with zero false negatives, using just ~9 bits per key: 1.13 MB per million keys vs 1.51 MB for Bloom (and up to 36% savings at 16 bits). Lookups take 7.0 ns vs 9.3 ns for FastFilter/xorfilter, though construction is 2–2.5× slower than Bloom and you can't insert new keys later:
// 8-bit fingerprints: ~9 bits/key, ~0.39% FPR
keys := [][]byte{[]byte("user:42"), []byte("user:108")}
filter := fuse.New[uint8](slices.Values(keys), len(keys))
ok := filter.Contains([]byte("user:42")) // true
The constructor takes iter.Seq[[]byte], and the built filter is safe for lock-free concurrent reads.
For DAU counting, UltraLogLog succeeds HyperLogLog. It packs two bits of history about previous ranks into each 1-byte register. In Go, that cuts memory by ~43% at the same accuracy: 9.1 KB and 0.86% error vs 16.3 KB and 0.79% for HLL (or 24–28% smaller than 6-bit HLL):
// Default p=13: ~0.86% error in 9.1 KB of RAM
home, docs := ull.New(), ull.New()
home.Add([]byte("user:42"))
docs.Add([]byte("user:777"))
if err := home.Merge(docs); err != nil {
panic(err)
}
dau := home.Count()
An inline histogram speeds Count up to 161 ns vs 348,000 ns in axiomhq/hyperloglog. The trade-off is CPU: Add is 40% slower than HLL, and Count/Merge are 2.5× slower.
Log-linear histogram and MinHash: accurate tails and deduplication
Teams often use t-digest for API percentiles, yet t-digest bounds rank error rather than value error. On heavy-tailed (Pareto) distributions, that produces 67% error at p99.9 and 868% at p99.99. A log-linear histogram works like a slide rule: it splits ranges into power-of-two octaves with equal sub-buckets, extracting bucket indexes straight from float64 bits without math.Log. One million samples at 0.39% precision fit in 14 KB vs 264 KB for HdrHistogram/hdrhistogram-go, tail error stays under 0.78%, and Add (4 ns) is 5× faster than DataDog/sketches-go.
For near-duplicate text detection via Jaccard similarity (shared elements from 0 to 1), classic MinHash like dgryski/go-minhash computes k hashes per token. unsure uses One Permutation Hashing with Optimal Densification—one hash in 5 ns instead of 115–358 ns (6–70× faster)—and fills empty buckets inside Signature() without mutating state:
// A 256-entry signature takes exactly 1 KB
sA, sB := minhash.New(256), minhash.New(256)
for w := range strings.FieldsSeq(docA) {
sA.Add([]byte(w))
}
for w := range strings.FieldsSeq(docB) {
sB.Add([]byte(w))
}
sim := sA.Signature().Similarity(sB.Signature())
A 1 KB signature works equally well for a short note or a huge file, comparing in 104 ns. At k=256, mid-scale error is ±3.1 percentage points, and mismatched k values panic.
Choosing the right structure without production surprises
| Use case | Modern structure | When classic or mature wins |
| --- | --- | --- | --- |
| Cache filter | Binary Fuse Filter | Dynamic inserts → Bloom; prod → FastFilter/xorfilter |
| DAU counting | UltraLogLog | Few sketches → HLL; serialization → axiomhq/hyperloglog |
| p99.9 tails | Log-linear histogram | Smooth tails → t-digest; prod → DataDog/sketches-go |
| Near-duplicates | MinHash (OPH) | Small sets & 100% accuracy → plain map |
Keep four caveats in mind before shipping. None of these structures support deleting or listing keys. unsure v0.2.0 has no MarshalBinary for Redis or network transport, and ull, loghist, and minhash aren't goroutine-safe (use sync.Mutex or per-worker sketches plus Merge). Finally, it uses wyhash with a fixed seed, so untrusted external inputs could craft collisions—stick to the mature packages in the table for public-facing production.



