nx_bench_core.nx
buildroot/runtime/nx_bench_core.nx
about
nx_bench_core.nx -- B1 second stone of NISHI_PERFORMANCE_
DOCTRINE_ROADMAP.md.
Shippable bench harness primitive: warmup + N-iteration measurement
+ reference band check + pathology classification + ETG attestation.
Composes nx_etg (E1), nx_perf_pathology (B1 sibling), and
nx_clock (existing monotonic timer).
Why this brick is the SUBSTRATE BENCH PATTERN: every future bench
(CPU matmul, memory copy, NVMe scan, network RTT, GPU kernel) calls
this harness with a "workload runner" + a reference band + signals.
The harness:
1. Runs N_WARMUP iterations to settle caches / JIT / TLB
2. Runs N_MEASURED iterations capturing per-iteration ns
3. Computes median, p50, p99 (sort then index for B1 first stone;
reservoir sampling deferred to B3)
4. Checks if median falls inside the reference (lower, upper) band
5. Calls nx_perf_classify with the signals + in_band flag
6. Emits NxEtgEntry via nx_etg_entry_init with:
probe_kind = caller-supplied (cpu/storage/net/gpu/etc.)
claim_value = upper bound of the reference band
measurement_value = the classified pathology id
outcome = derived from pathology (OPTIMAL -> CONFIRMED,
anything else -> the
ETG outcome that best
matches the pathology)
Composes:
[[NISHI_PERFORMANCE_DOCTRINE_ROADMAP]] B1
nx_etg.nx (E1 attestation)
nx_perf_pathology.nx (B1 sibling classifier)
nx_clock.nx (monotonic timing)
[[feedback-hardware-agnostic-is-robustness]] cardinal: this
harness must produce identical pathology classifications on
identical inputs across ISAs.
[[feedback-no-strawman-perf-comparisons]] (no claim without
paired measurement; the reference band IS the paired claim)
[[feedback-no-false-ok-substrate-honesty-audit]] (INCONCLUSIVE
when N too small; never silent)
dependencies 4 imports · 1 importers
imports: nx_syscalls.nxnx_etg.nxnx_perf_pathology.nxnx_sort.nx
imported by: nx_bench_core_test.nx
structs
| 76 | struct NxBenchResult |
consts
| 63 | const NX_BENCH_DEFAULT_WARMUP: i64 = 5 |
| 64 | const NX_BENCH_DEFAULT_MEASURED: i64 = 17 |
| 65 | const NX_BENCH_MIN_MEASURED: i64 = 3 // below this, INCONCLUSIVE |
| 68 | const NX_BENCH_ERR_TOO_FEW_SAMPLES: i64 = -1 |
| 69 | const NX_BENCH_ERR_BAD_BAND: i64 = -2 |
| 70 | const NX_BENCH_ERR_ALLOC: i64 = -3 |
functions
| 101 | func _bench_p99_index(n: i64) -> i64 called by 1: nx_bench_record_samples |
| 108 | func _bench_median_index(n: i64) -> i64 called by 1: nx_bench_record_samples |
| 134 | func nx_bench_record_samples( |