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)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_theta_alloc nx_hll_alloc write_bth nx_theta_add murmur3_32 mm_load_u32_le mm_rotl32 nx_hll_add murmur3_32 ↻ nx_clz32 nx_bits_clz32 nx_theta_intersect nx_theta_alloc ↻ nx_theta_min2 nx_theta_estimate nx_hll_estimate nx_hll_pow2_neg_q32 nx_hll_alpha_m_sq_q64 nx_hll_bias_table_n nx_hll_bias_table_get nx_hll_bias_lgk4 nx_hll_bias_lgk5 nx_hll_bias_lgk6 nx_hll_bias_lgk7 nx_hll_bias_lgk8 nx_hll_bias_lgk9 nx_hll_bias_lgk10 nx_hll_log2_ppm nx_hll_bias_correct nx_hll_bias_table_n ↻ nx_hll_bias_table_get ↻ nx_mulshl_div_i64 nx_i128_alloc nx_i128_mul_i64 nx_i128_mul_u64 nx_i128_neg nx_i128_shl nx_i128_div_i64 nx_i128_is_neg

structs

none

consts

none

functions

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