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 2 imports · 6 importers
imports: nx_resmon_lib.nxnx_ioadmit_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
| 21 | const PC_RATIO_SAT: i64 = 1000000 |
| 22 | const PC_ASCII_0: i64 = 48 |
| 23 | const PC_ASCII_9: i64 = 57 |
| 24 | const PC_ASCII_NL: i64 = 10 |
| 25 | const PC_PERMIL: i64 = 1000 |
| 115 | const PC_NUMSCRATCH: i64 = 32 |
| 116 | const PC_ASCII_MINUS: i64 = 45 |
| 201 | const PC_ACT_PROCEED: i64 = 0 |
| 202 | const PC_ACT_SLOW: i64 = 1 |
| 203 | const PC_ACT_DEFER: i64 = 2 |
| 204 | const PC_ACT_UNOBSERVABLE: i64 = 3 |
| 205 | const PC_SEVKEY_LEN: i64 = 5 |
| 206 | const PC_TSKEY_LEN: i64 = 3 |
| 344 | const PC_PATHBUF: i64 = 64 |
| 345 | const PC_DIRBUF: i64 = 65536 |
| 346 | const PC_DIRENT_NAME_OFF: i64 = 19 |
| 347 | const PC_ST_PPID: i64 = 2 // ioa_stat_parse out layout: 0=comm start, 1=comm length, 2=ppid |
functions
| 33 | func pc_line_ints(buf: *u8, n: i64, key: *u8, out: *i64, maxv: i64) -> i64 |
| 82 | func pc_rate(delta: i64, elapsed_ms: i64) -> i64 |
| 90 | func pc_ratio_permil(sys_j: i64, usr_j: i64) -> i64 |
| 102 | func pc_verdict(forks_ps: i64, ratio_pm: i64, ctxsw_ps: i64, |
| 123 | func pc_cat(d: *u8, o: i64, s: *u8) -> i64 |
| 128 | func pc_catn(d: *u8, o: i64, v: i64) -> i64 |
| 154 | func pc_frame(d: *u8, ts: i64, win_ms: i64, forks_ps: i64, ctxsw_ps: i64, intr_ps: i64, |
| 208 | func pc_isdig(c: i64) -> i64 |
| 217 | func pc_find_in(buf: *u8, s: i64, e: i64, key: *u8) -> i64 called by 1: pc_sev_last |
| 238 | func pc_int_at(buf: *u8, p: i64, e: i64) -> i64 |
| 268 | func pc_sev_last(buf: *u8, n: i64, out: *i64) -> i64 |
| 304 | func pc_sev_consumer(sev: i64, age_s: i64, max_age_s: i64) -> i64 |
| 314 | func pc_act_name(a: i64) -> *u8 called by 1: main |
| 351 | func pc_name_is_pid(s: *u8) -> i64 |
| 362 | func pc_name_to_i64(s: *u8) -> i64 |
| 373 | func pc_pids(out: *i64, cap: i64, out_full: *i64) -> i64 |
| 407 | func pc_pid_seen(pids: *i64, n: i64, pid: i64) -> i64 |
| 416 | func pc_ppid_of(pid: i64, sbuf: *u8, pathb: *u8, out: *i64) -> i64 |
| 426 | func pc_tally_parent(ppids: *i64, counts: *i64, np: i64, maxp: i64, ppid: i64) -> i64 |
| 443 | func pc_fork_by_parent(prev: *i64, prev_n: i64, cur: *i64, cur_n: i64, |
| 470 | func pc_attrib_permil(attributed: i64, kernel_forks: i64) -> i64 |