nx_sketch_comparator.nx
buildroot/runtime/nx_sketch_comparator.nx
about
sketch_comparator.nx -- sealed-verdict comparator for head-to-head stomp claims.
THE VALIDATION PRIMITIVE. Every claim of the form "our primitive
beats incumbent X on axis Y" must pass through this. Sealed verdicts:
NX_CMP_VERDICT_BEATS our primitive measurably better
NX_CMP_VERDICT_EQUIVALENT within tolerance band; can't distinguish
NX_CMP_VERDICT_LOSES incumbent measurably better
NX_CMP_VERDICT_INCONCLUSIVE missing data or degenerate inputs
THREE INDEPENDENT AXES:
ACCURACY -- whoever's closer to ground truth wins
MEMORY -- smaller bytes wins
TIME -- faster wall-time wins
COMPOSITE verdict aggregates 3 axis verdicts via majority vote with
inconclusive-axis discounting. A 2/3 majority with one INCONCLUSIVE
is enough to call. A 1/1/1 tie returns EQUIVALENT.
All inputs are i64; caller supplies measurements from external runs.
This primitive does NOT itself run benchmarks -- it normalizes the
VERDICT against typed tolerance, so claims become falsifiable.
LOSSLESS-LANGUAGE DISCIPLINE: result struct carries verdict + signed
delta in PPM (positive = our wins) + ppb confidence.
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_sketch_types.nx
imported by: nx_bench_hll_vs_cpc.nxnx_bench_hll_vs_cpcd.nx
structs
| 48 | struct ComparisonResult |
consts
| 35 | const NX_MAGIC_1000000000: i64 = 1000000000 |
| 36 | const NX_MAGIC_500000000: i64 = 500000000 |
| 37 | const NX_MAGIC_1000000: i64 = 1000000 |
| 39 | const NX_CMP_VERDICT_BEATS: i64 = 0 |
| 40 | const NX_CMP_VERDICT_EQUIVALENT: i64 = 1 |
| 41 | const NX_CMP_VERDICT_LOSES: i64 = 2 |
| 42 | const NX_CMP_VERDICT_INCONCLUSIVE: i64 = 3 |
| 44 | const NX_CMP_AXIS_ACCURACY: i64 = 0 |
| 45 | const NX_CMP_AXIS_MEMORY: i64 = 1 |
| 46 | const NX_CMP_AXIS_TIME: i64 = 2 |
functions
| 57 | func nx_cmp_iabs(x: i64) -> i64 called by 1: nx_cmp_accuracy |
| 71 | func nx_cmp_accuracy(our: i64, theirs: i64, truth: i64, tolerance_ppm: i64) -> *ComparisonResult |
| 108 | func nx_cmp_memory(our_bytes: i64, their_bytes: i64, tolerance_ppm: i64) -> *ComparisonResult |
| 140 | func nx_cmp_time(our_us: i64, their_us: i64, tolerance_ppm: i64) -> *ComparisonResult |
| 181 | func nx_cmp_composite(acc: *ComparisonResult, mem: *ComparisonResult, |
| 211 | func nx_cmp_query(r: *ComparisonResult) -> *ApproxI64 calls 1: nx_approx_new |
| 218 | func nx_cmp_memory_bytes(r: *ComparisonResult) -> i64 |