code wiki / _hdl_build / nx_procchurn_lib.nx
nx_procchurn_lib.nx
buildroot/runtime/_hdl_build/nx_procchurn_lib.nx
about
nx_procchurn_lib.nx -- the PURE, GATEABLE core of nx_procchurn (perf lane, debt seq1317/seq1318).
WHY THIS EXISTS: on 2026-07-30 the NAS measured 78.3 forks/sec SUSTAINED with kernel time at 231 permil
of an 8-core host against 98 permil userspace -- the kernel doing 2.36x the work of the application --
while nx_health reported {overall:OK, degraded:0, down:0} and all 14 services read UP. nx_resmon owns the
MEMORY axis and nx_netobs owns the NETWORK axis; NOTHING owned the PROCESS-CHURN axis, so the single
largest CPU consumer on the platform had no instrument at all and had to be found by hand from /proc.
LAW: liveness is not performance -- a board that only asks \"is it up\" cannot see the machine burning.
Split per rule 9 (single responsibility) + rule 15 (DRY): the organ owns the sampling and the printing,
this lib owns the four pure functions that encode the policy, so the gate exercises the SAME code the
organ runs rather than a reimplementation. Rule 15 again: the generic helpers (puts/num/read/conf) are
IMPORTED from nx_resmon_lib.nx, NOT copied -- D001/seq389 counts 9495 duplicate function bodies and the
emit family (gw x427, g_puts x325) is the worst group; a new organ must not add to it.
license_tier: ORIGINAL Read-only. No hw writes (Rule 26).
dependencies 1 imports · 6 importers
imports: nx_resmon_lib.nx
imported by: nx_ctrl_fn.nxnx_ctrl_same.nxnx_ctxtop_lib.nxnx_fnclosure_probe.nxnx_procchurn.nxnx_procchurn_gate.nx
structs
| none |
consts
| 20 | const PC_RATIO_SAT: i64 = 1000000 |
| 21 | const PC_ASCII_0: i64 = 48 |
| 22 | const PC_ASCII_9: i64 = 57 |
| 23 | const PC_ASCII_NL: i64 = 10 |
| 24 | const PC_PERMIL: i64 = 1000 |
| 114 | const PC_NUMSCRATCH: i64 = 32 |
| 115 | const PC_ASCII_MINUS: i64 = 45 |
functions
| 32 | func pc_line_ints(buf: *u8, n: i64, key: *u8, out: *i64, maxv: i64) -> i64 |
| 81 | func pc_rate(delta: i64, elapsed_ms: i64) -> i64 |
| 89 | func pc_ratio_permil(sys_j: i64, usr_j: i64) -> i64 |
| 101 | func pc_verdict(forks_ps: i64, ratio_pm: i64, ctxsw_ps: i64, |
| 122 | func pc_cat(d: *u8, o: i64, s: *u8) -> i64 called by 1: pc_frame |
| 127 | func pc_catn(d: *u8, o: i64, v: i64) -> i64 |
| 153 | func pc_frame(d: *u8, ts: i64, win_ms: i64, forks_ps: i64, ctxsw_ps: i64, intr_ps: i64, |