code wiki / (root) / sketch_theta_intersect_vs_hll_bench.nx

sketch_theta_intersect_vs_hll_bench.nx

buildroot/runtime/sketch_theta_intersect_vs_hll_bench.nx

5089 B143 linesdepth 6pulls 14 transitivereach 0 importersview sourcekind benchtopic sketch
docsdependenciesstructsconstsfunctions

about

sketch_theta_intersect_vs_hll_bench.nx -- capability bench, Theta vs HLL. CLAIM TO VALIDATE: Theta sketch (Beyer-Haas-Reinwald-Sismanis-Gemulla 2007) supports set INTERSECTION via direct subspace pruning: A∩B is the keys below min(theta_A, theta_B) that appear in BOTH samples. HLL has NO direct intersection. The standard workaround is inclusion-exclusion: |A∩B| = |A| + |B| - |A∪B|. This is notoriously unstable -- variance grows quadratically with the underlying cardinalities even when the true |A∩B| is small. Substrate ships both; this bench DEMONSTRATES Theta's direct intersection beats HLL's inclusion-exclusion on the small-overlap regime where HLL's variance explodes. WORKLOAD: Two sets at MATCHED memory budgets (k vs lg_k chosen so byte footprints are within 25%): Set A: 10000 keys Set B: 10000 keys (disjoint except for 100 shared) True |A∩B| = 100 (heavy on |A| + |B|, light on intersection) MEASUREMENT: theta_inter = nx_theta_intersect(a, b) -> direct |A∩B| estimate hll_inter = max(0, |A| + |B| - |A∪B|) via inclusion-exclusion ACCURACY axis: closer to truth=100 wins.

dependencies 5 imports · 0 importers

syscalls.nx sketch_theta.nx sketch_hll.nx sketch_comparator.nx sketch_types.nx sketch_theta_intersect_vs_hll_

imports: syscalls.nxsketch_theta.nxsketch_hll.nxsketch_comparator.nxsketch_types.nx

imported by: nobody (leaf or entry point)

structs

none

consts

none

functions

35func iabs_th(x: i64) -> i64
40func write_bth(buf: *u8, value: i64) -> i64
51func main() -> i64