code wiki / (root) / sketch_kmv_jaccard_vs_naive_bench.nx

sketch_kmv_jaccard_vs_naive_bench.nx

buildroot/runtime/sketch_kmv_jaccard_vs_naive_bench.nx

4897 B156 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind benchtopic sketch
docsdependenciesstructsconstsfunctions

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

syscalls.nx sketch_kmv.nx sketch_comparator.nx sketch_types.nx sketch_kmv_jaccard_vs_naive_be

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

main nx_kmv_alloc write_bk nx_kmv_add nx_kmv_hash murmur3_32 mm_load_u32_le mm_rotl32 nx_kmv_jaccard_ppm iabs_kj nx_kmv_memory_bytes nx_cmp_memory nx_kmv_estimate nx_kmv_union nx_kmv_alloc ↻

structs

none

consts

none

functions

35func iabs_kj(x: i64) -> i64
called by 1: main
40func write_bk(buf: *u8, value: i64) -> i64
called by 1: main
51func main() -> i64