sketch_kmv_jaccard_vs_naive_bench.nx
buildroot/runtime/sketch_kmv_jaccard_vs_naive_bench.nx
about
sketch_kmv_jaccard_vs_naive_bench.nx -- KMV Jaccard vs naive O(N).
CLAIM TO VALIDATE:
KMV sketch (Bar-Yossef-Jayram-Kumar-Sivakumar-Trevisan 2002, popular
form Beyer et al. 2007) supports JACCARD similarity in O(k) memory
regardless of set size. Naive baseline must materialize both sets,
sort them, and compute |A∩B| / |A∪B| -- O(|A|+|B|) memory.
Apache DataSketches ships Theta sketch with Jaccard, so KMV here
is INTERNAL family completion + MEMORY axis vs naive. Both KMV
and Theta are streaming approaches; naive is the materialized
baseline.
WORKLOAD:
Set A: 1000 keys (ids 1..1000)
Set B: 1000 keys (ids 500..1500)
|A∩B| = 501, |A∪B| = 1500. True Jaccard = 501/1500 = 0.334.
In PPM: 334000.
MEASUREMENT:
- KMV Jaccard estimate via nx_kmv_jaccard_ppm
- Naive exact Jaccard from sorted sets
- ACCURACY axis: closer to truth wins
- MEMORY axis: KMV vs naive set storage
HARD-WIN GATE:
MEMORY BEATS by >50%
KMV's Jaccard within 15% of truth
dependencies 4 imports · 0 importers
imports: syscalls.nxsketch_kmv.nxsketch_comparator.nxsketch_types.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 35 | func iabs_kj(x: i64) -> i64 called by 1: main |
| 40 | func write_bk(buf: *u8, value: i64) -> i64 called by 1: main |
| 51 | func main() -> i64 |