code wiki / (root) / nx_linkqual_cycles.nx

nx_linkqual_cycles.nx

buildroot/runtime/nx_linkqual_cycles.nx

5144 B130 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic linkqual
docsdependenciesstructsconstsfunctions

about

nx_linkqual_cycles.nx -- CYCLE-ACCURATE hot-path measurement of the link-quality substrate using the sovereign __rdtsc() intrinsic. This is the hardware-limit metric: reference-cycles per op straight off the CPU's timestamp counter, with NO per-op syscall in the loop (two reads bracket N calls, amortized). HONEST METHOD: - a warmup pass is discarded (caches/branch-predictors warm). - inputs vary per-iteration so the work can't be constant-folded. - rdtsc measures INVARIANT-TSC reference cycles (the constant base-rate counter), NOT turbo-scaled retired core cycles -- so we ALSO bracket the identical loop with the microsecond clock and derive the effective TSC GHz (cycles/ns). If that GHz matches the CPU's base clock, the two independent clocks agree and the numbers are trustworthy (1:1 cross- validation, [[feedback-1to1-proof-no-proxy-2026-05-28]]). license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_linkqual.nx nx_linkqual_cycles.nx

imports: nx_linkqual.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bdec lq_flow_new sys_mmap lq_on_arrival lq_record_latency lq_buckets lq_bucket_of sys_now_us sys_mmap ↻ sys_clock_gettime_mono report bdec ↻ bcenti bdec ↻ lq_on_rtt lq_on_seq

structs

none

consts

20const K_MAGIC_2000000: i64 = 2000000
21const K_MAGIC_1000000000: i64 = 1000000000
22const K_MAGIC_200000: i64 = 200000
23const K_MAGIC_2654435761: i64 = 2654435761

functions

25func bdec(n: i64) -> i64
called by 3: bcentireportmain
37func bcenti(n: i64) -> i64
called by 1: report calls 1: bdec
44func report(label: *u8, llen: i64, n: i64, cyc: i64, us: i64) -> i64
called by 1: main calls 2: bdecbcenti
57func main() -> i64