code wiki / (root) / sketch_varopt_vs_reservoir_biased_bench.nx

sketch_varopt_vs_reservoir_biased_bench.nx

buildroot/runtime/sketch_varopt_vs_reservoir_biased_bench.nx

3694 B111 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind benchtopic sketch
docsdependenciesstructsconstsfunctions

about

sketch_varopt_vs_reservoir_biased_bench.nx -- weighted sampling capability. CLAIM TO VALIDATE: VarOpt sketch (Efraimidis-Spirakis A-ExpJ, Cohen et al. weighted- sampling) selects items with probability proportional to weight. Uniform Reservoir (Vitter 1985) samples uniformly regardless of weight. On a stream with one heavy-weighted item among many light-weighted items, VarOpt consistently retains the heavy item; Reservoir nearly always loses it. CAPABILITY EXCEED: weighted streaming sampling. DS ships Vitter reservoir but NOT VarOpt/A-ExpJ. Substrate offers both. WORKLOAD: - 1 HEAVY item (id=99999) with weight 1000 - 50 medium items (ids 100..149) with weight 100 - 5000 noise items (ids 1000..5999) with weight 1 - Total: 5051 items, 11000 total weight Run with 10 different seeds. Tally how often the heavy item appears in each sketch's sample. VarOpt should retain >=9/10. Reservoir should retain <=4/10. MEMORY: VarOpt k=100, entries 24 bytes each -> 2400 + header Reservoir cap=300, 8 bytes each -> 2400 + header Matched ~2400 bytes by construction.

dependencies 5 imports · 0 importers

syscalls.nx sketch_varopt.nx sketch_reservoir.nx sketch_comparator.nx sketch_types.nx sketch_varopt_vs_reservoir_bia

imports: syscalls.nxsketch_varopt.nxsketch_reservoir.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_varopt_alloc nx_reservoir_alloc nx_varopt_add nx_varopt_key nx_varopt_rng_next nx_varopt_bitlen nx_varopt_entry_at nx_reservoir_add nx_reservoir_rng_below nx_reservoir_rng_next nx_varopt_n_items nx_varopt_entry_at ↻ nx_cmp_accuracy nx_cmp_iabs

structs

none

consts

35const NX_VOB_HEAVY_ID: i64 = 99999

functions

37func main() -> i64