nx_bench_receipt_lib.nx
buildroot/runtime/nx_bench_receipt_lib.nx
about
nx_bench_receipt_lib.nx -- THE ONE READER, ONE VERDICT AND ONE SERIALISER for a /compare <dom>.bench receipt
(2026-09-01, lang leg: "meet and exceed gcc and rust, independently verified, reproducible, visible").
WHY A LIB. A benchmark receipt is read by THREE organs -- the writer that measures (nx_lang_h2h), the two
/compare generators that render it (bench_pass in nx_swcompare_lib), and the gate that judges it
(nx_lang_h2h_gate). WHEN THREE ORGANS MUST AGREE ON WHAT "VALID" MEANS, MAKE DISAGREEMENT IMPOSSIBLE BY
CONSTRUCTION: there is exactly one classifier (br_verdict), one row grammar (br_parse / br_write) and one
ratio rule (permil of the reference arm's median). The writer calls br_verdict BEFORE it serialises and the
reader calls it AFTER it parses, so a receipt whose written @verdict disagrees with its rows is detectable.
THE RECEIPT (knowledge/compare/<dom>.bench), a data file the emitter renders for ANY domain:
@title <text> @workload <text: what every arm computes and the checksum it must print>
@host <hostname>|<cpu model>|<kernel>|nproc=<n>
@runs <n> @ref <arm name that is the 1.00x baseline> @asof <epoch>
@repro <the exact command that regenerates this file> @writer <organ>
@verdict VALID|VOID|UNMEASURABLE|EMPTY (written by the writer, RE-DERIVED by every reader)
arm|<name>|<toolchain>|<version>|<source>|<source_sha256>|<bin_bytes>|<bin_sha256>|<runs>|<min_us>|<median_us>|<checksum>|<status>|<note>
STATUS per arm: VALID (measured, checksum equals the reference arm's), VOID (measured, checksum DIFFERS --
the arm did not do the same work, so its time is not comparable and is never ranked), UNMEASURABLE (the
toolchain is not declared on the measuring host -- an absence, never a loss), BUILD-FAIL, RUN-FAIL.
VERDICT for the receipt: EMPTY (no arm rows), UNMEASURABLE (the reference arm is not VALID, so no ratio
exists), VOID (any measured arm disagrees on the checksum), VALID otherwise.
A ratio is permil of the reference median: 1000 = 1.00x, 2020 = 2.02x slower. Only VALID arms carry one.
NOTHING HERE IS A THRESHOLD: the lib says what was measured; the gate says what is acceptable.
license_tier: ORIGINAL No hw writes (Rule 26). LIB (no main).
dependencies 1 imports · 13 importers
diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.
imports: nx_syscalls.nx
imported by: nx_compare_shared_fit_lib_20260910.nxnx_lang_h2h.nxnx_lang_h2h_gate.nxnx_swcompare_evidence_lib_t138.nxnx_swcompare_growth_candidate_20260910.nxnx_swcompare_heading_lib_20260907.nxnx_swcompare_ladder_candidate.nxnx_swcompare_lib.nxnx_swcompare_preview_lib_t56.nxnx_swcompare_production_lib_20260907.nxnx_swcompare_release_candidate.nxnx_video_h2h.nxnx_video_h2h_gate.nx
structs
| none |
consts
| 28 | const BR_MAXARMS: i64 = 32 |
| 29 | const BR_STRIDE: i64 = 16 |
| 30 | const BR_A_NAME: i64 = 0 |
| 31 | const BR_A_TOOL: i64 = 1 |
| 32 | const BR_A_VER: i64 = 2 |
| 33 | const BR_A_SRC: i64 = 3 |
| 34 | const BR_A_SRCSHA: i64 = 4 |
| 35 | const BR_A_BINBYTES: i64 = 5 |
| 36 | const BR_A_BINSHA: i64 = 6 |
| 37 | const BR_A_RUNS: i64 = 7 |
| 38 | const BR_A_MIN: i64 = 8 |
| 39 | const BR_A_MED: i64 = 9 |
| 40 | const BR_A_CHK: i64 = 10 |
| 41 | const BR_A_STATUS: i64 = 11 |
| 42 | const BR_A_NOTE: i64 = 12 |
| 43 | const BR_A_RATIO: i64 = 13 |
| 44 | const BR_H_TITLE: i64 = 0 |
| 45 | const BR_H_WORKLOAD: i64 = 1 |
| 46 | const BR_H_HOST: i64 = 2 |
| 47 | const BR_H_RUNS: i64 = 3 |
| 48 | const BR_H_REF: i64 = 4 |
| 49 | const BR_H_ASOF: i64 = 5 |
| 50 | const BR_H_REPRO: i64 = 6 |
| 51 | const BR_H_WRITER: i64 = 7 |
| 52 | const BR_H_WRITTEN_VERDICT: i64 = 8 |
| 53 | const BR_H_N: i64 = 9 |
| 54 | const BR_ST_UNKNOWN: i64 = 0 |
| 55 | const BR_ST_VALID: i64 = 1 |
| 56 | const BR_ST_VOID: i64 = 2 |
| 57 | const BR_ST_UNMEASURABLE: i64 = 3 |
| 58 | const BR_ST_BUILDFAIL: i64 = 4 |
| 59 | const BR_ST_RUNFAIL: i64 = 5 |
| 60 | const BR_V_EMPTY: i64 = 0 |
| 61 | const BR_V_VALID: i64 = 1 |
| 62 | const BR_V_VOID: i64 = 2 |
| 63 | const BR_V_UNMEASURABLE: i64 = 3 |
| 64 | const BR_V_UNWRITTEN: i64 = 0 - 1 |
| 65 | const BR_ARM_FIELDS: i64 = 14 |
| 66 | const BR_MAXF: i64 = 20 |
| 67 | const BR_PERMIL: i64 = 1000 |
| 68 | const BR_TEN: i64 = 10 |
| 69 | const BR_PIPE: i64 = 124 |
| 70 | const BR_NL: i64 = 10 |
| 71 | const BR_HASH: i64 = 35 |
| 72 | const BR_AT: i64 = 64 |
| 73 | const BR_MINUS: i64 = 45 |
| 74 | const BR_DOT: i64 = 46 |
| 75 | const BR_ZERO: i64 = 48 |
| 76 | const BR_NINE: i64 = 57 |
| 77 | const BR_LOWER_X: i64 = 120 |
| 78 | const BR_WORD: i64 = 8 |
| 79 | const BR_ROW_RESERVE: i64 = 4096 |
| 80 | const BR_NO_RATIO: i64 = 0 - 1 |
functions
| 82 | func br_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 83 | func br_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } |
| 84 | func br_starts(s: *u8, pfx: *u8) -> i64 { var i: i64 = 0; while pfx[i] != (0 as u8) { if s[i] != pfx[i] { return 0 } i = i + 1 } return 1 } called by 1: br_parse |
| 86 | func br_atoi(s: *u8) -> i64 called by 1: br_parse |
| 101 | func br_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 108 | func br_put(dst: *u8, off: i64, c: i64) -> i64 { dst[off] = c as u8; dst[off + 1] = 0 as u8; return off + 1 } |
| 109 | func br_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 122 | func br_status_name(c: i64) -> *u8 |
| 130 | func br_status_code(s: *u8) -> i64 |
| 138 | func br_verdict_name(v: i64) -> *u8 |
| 145 | func br_verdict_code(s: *u8) -> i64 |
| 153 | func br_split(s: *u8, fld: *i64, maxf: i64) -> i64 called by 1: br_parse |
| 163 | func br_init(hdr: *i64, arms: *i64) -> i64 |
| 174 | func br_parse(buf: *u8, n: i64, hdr: *i64, arms: *i64) -> i64 |
| 223 | func br_load(path: *u8, hdr: *i64, arms: *i64) -> i64 |
| 231 | func br_ref_index(hdr: *i64, arms: *i64, n: i64) -> i64 |
| 240 | func br_verdict(hdr: *i64, arms: *i64, n: i64) -> i64 called by 12: bench_pass_headingmainmainbench_pass_headingbench_pass_headingbench_pass_heading+6 calls 1: br_ref_index |
| 264 | func br_ratio_text(permil: i64, dst: *u8, off: i64) -> i64 called by 10: bench_pass_headingmainbench_pass_headingbench_pass_headingbench_pass_headingbench_pass+4 calls 2: br_putbr_catn |
| 277 | func br_write(dst: *u8, cap: i64, dom: *u8, hdr: *i64, arms: *i64, n: i64, verdict: i64) -> i64 |