code wiki / (root) / nx_bench_receipt_lib.nx

nx_bench_receipt_lib.nx

buildroot/runtime/nx_bench_receipt_lib.nx

16082 B318 linesdepth 2pulls 2 transitivereach 61 importersview sourcekind benchtopic bench
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_bench_receipt_lib.nx nx_compare_shared_fit_lib_20260910 nx_lang_h2h.nx nx_lang_h2h_gate.nx nx_swcompare_evidence_lib_t138.nx nx_swcompare_growth_candidate_2026 nx_swcompare_heading_lib_20260907. nx_swcompare_ladder_candidate.nx nx_swcompare_lib.nx nx_swcompare_preview_lib_t56.nx nx_swcompare_production_lib_202609

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

28const BR_MAXARMS: i64 = 32
29const BR_STRIDE: i64 = 16
30const BR_A_NAME: i64 = 0
31const BR_A_TOOL: i64 = 1
32const BR_A_VER: i64 = 2
33const BR_A_SRC: i64 = 3
34const BR_A_SRCSHA: i64 = 4
35const BR_A_BINBYTES: i64 = 5
36const BR_A_BINSHA: i64 = 6
37const BR_A_RUNS: i64 = 7
38const BR_A_MIN: i64 = 8
39const BR_A_MED: i64 = 9
40const BR_A_CHK: i64 = 10
41const BR_A_STATUS: i64 = 11
42const BR_A_NOTE: i64 = 12
43const BR_A_RATIO: i64 = 13
44const BR_H_TITLE: i64 = 0
45const BR_H_WORKLOAD: i64 = 1
46const BR_H_HOST: i64 = 2
47const BR_H_RUNS: i64 = 3
48const BR_H_REF: i64 = 4
49const BR_H_ASOF: i64 = 5
50const BR_H_REPRO: i64 = 6
51const BR_H_WRITER: i64 = 7
52const BR_H_WRITTEN_VERDICT: i64 = 8
53const BR_H_N: i64 = 9
54const BR_ST_UNKNOWN: i64 = 0
55const BR_ST_VALID: i64 = 1
56const BR_ST_VOID: i64 = 2
57const BR_ST_UNMEASURABLE: i64 = 3
58const BR_ST_BUILDFAIL: i64 = 4
59const BR_ST_RUNFAIL: i64 = 5
60const BR_V_EMPTY: i64 = 0
61const BR_V_VALID: i64 = 1
62const BR_V_VOID: i64 = 2
63const BR_V_UNMEASURABLE: i64 = 3
64const BR_V_UNWRITTEN: i64 = 0 - 1
65const BR_ARM_FIELDS: i64 = 14
66const BR_MAXF: i64 = 20
67const BR_PERMIL: i64 = 1000
68const BR_TEN: i64 = 10
69const BR_PIPE: i64 = 124
70const BR_NL: i64 = 10
71const BR_HASH: i64 = 35
72const BR_AT: i64 = 64
73const BR_MINUS: i64 = 45
74const BR_DOT: i64 = 46
75const BR_ZERO: i64 = 48
76const BR_NINE: i64 = 57
77const BR_LOWER_X: i64 = 120
78const BR_WORD: i64 = 8
79const BR_ROW_RESERVE: i64 = 4096
80const BR_NO_RATIO: i64 = 0 - 1

functions

82func br_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
83func 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 }
84func 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
86func br_atoi(s: *u8) -> i64
called by 1: br_parse
101func br_cat(dst: *u8, off: i64, s: *u8) -> i64
108func br_put(dst: *u8, off: i64, c: i64) -> i64 { dst[off] = c as u8; dst[off + 1] = 0 as u8; return off + 1 }
109func br_catn(dst: *u8, off: i64, v: i64) -> i64
122func br_status_name(c: i64) -> *u8
130func br_status_code(s: *u8) -> i64
called by 1: br_parse calls 1: br_streq
138func br_verdict_name(v: i64) -> *u8
145func br_verdict_code(s: *u8) -> i64
called by 1: br_parse calls 1: br_streq
153func br_split(s: *u8, fld: *i64, maxf: i64) -> i64
called by 1: br_parse
163func br_init(hdr: *i64, arms: *i64) -> i64
174func br_parse(buf: *u8, n: i64, hdr: *i64, arms: *i64) -> i64
223func br_load(path: *u8, hdr: *i64, arms: *i64) -> i64
231func br_ref_index(hdr: *i64, arms: *i64, n: i64) -> i64
called by 1: br_verdict calls 1: br_streq
240func br_verdict(hdr: *i64, arms: *i64, n: i64) -> i64
264func br_ratio_text(permil: i64, dst: *u8, off: i64) -> i64
277func br_write(dst: *u8, cap: i64, dom: *u8, hdr: *i64, arms: *i64, n: i64, verdict: i64) -> i64