sketch_count_sketch_negative_bench.nx
buildroot/runtime/sketch_count_sketch_negative_bench.nx
about
sketch_count_sketch_negative_bench.nx -- negative-insert capability bench.
CLAIM TO VALIDATE:
CountSketch (Charikar et al. 2002) natively supports NEGATIVE
inserts -- it tracks the SIGNED sum of inserts per key (a TURNSTILE
stream). Apache DataSketches queues but does NOT ship CountSketch;
their only frequency primitive (CMS) handles INSERT-ONLY streams
(cash-register). Every other in-tree frequency primitive
(SpaceSaving, MisraGries, LossyCounting) is also INSERT-ONLY.
This bench demonstrates: CountSketch correctly tracks net counts
under mixed +/- inserts; CMS (forced to accept negative inserts)
silently corrupts. CAPABILITY EXCEED across the entire freq family.
WORKLOAD:
Per-key insert pattern (item 1): +1000, +500, -200, -100, +50, -50
Net per item 1: 1200
Item 2: +800, -100, +200 -> net 900
Item 3: +300, -50 -> net 250
Plus 200 singleton-positive noise items.
MEASUREMENT:
- CountSketch must return est within reasonable noise band of NET count
- CMS estimate is UNRELIABLE under negative inserts (rows can go
negative; the min-over-rows guarantee breaks). We document this
by asserting CountSketch is materially closer to truth.
dependencies 5 imports · 0 importers
imports: syscalls.nxsketch_count_sketch.nxsketch_cms.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
| none |
functions
| 34 | func iabs_n(x: i64) -> i64 called by 1: main |
| 39 | func write_bn(buf: *u8, value: i64) -> i64 called by 1: main |
| 50 | func main() -> i64 |