Probabilistic Data Structures in Go antonz.org · 14 points · 0 comments · HN thr...

@best

Probabilistic Data Structures in Go antonz.org · 14 points · 0 comments · HN thread

TL;DR The author introduces unsure, a dependency-free Go package implementing five probabilistic data structures: Bloom filter, count-min sketch, HyperLogLog, t-digest and Top-k. The post explains how each trades exactness for memory, describes the variants unsure uses (blocked Bloom filter, conservative update, Ertl's estimator, merging t-digest, HeavyKeeper with tweaks), and reports benchmarks against other Go libraries, claiming several-fold speedups at comparable accuracy and memory.

  • A Bloom filter for 1M 8-byte strings at a 1% false positive rate uses about 1.24 MB versus roughly 64 MB for a regular set.
  • A count-min sketch with estimates within 0.01% of the total count (99% probability) uses about 0.55 MB for 1M strings, and its size depends on accuracy rather than item count.
  • HyperLogLog at p=14 counts with about 0.81% standard error in 16 KB; unsure's Count is reported 270–83,000× faster than axiom's, with similar accuracy for large counts.
  • unsure's blocked Bloom filter keeps each add or check within one 512-bit cache line, and is reported about 4× faster than bits-and-blooms with 1–8% more memory.
  • The t-digest uses about 8 KB at compression 100 to estimate the 99th percentile within about 0.03% of rank, and the package claims 1.8× faster adds and 7–9× faster merges than influxdata/tdigest.
  • The Top-k sketch uses HeavyKeeper with two rows and decay base 0.8 (instead of the original ~0.93 and more rows), and is reported to be more precise than keiler and dgryski on flat (s=0.6) streams.
  • The benchmarks are the author's own and come from an excerpt of the full results, so the reported speedups have not been independently verified.

Discussion The HN thread has no comments yet, so there is no discussion to summarize. The post received 14 points and no responses at the time it was captured.

#Go #probabilisticDataStructures #algorithms #benchmarks #memoryEfficiency #unsure