sketch_varopt_vs_reservoir_biased_bench.nx
buildroot/runtime/sketch_varopt_vs_reservoir_biased_bench.nx
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
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
structs
| none |
consts
| 35 | const NX_VOB_HEAVY_ID: i64 = 99999 |
functions
| 37 | func main() -> i64 |