code wiki / _hdl_build / nx_procchurn_lib.nx

nx_procchurn_lib.nx

buildroot/runtime/_hdl_build/nx_procchurn_lib.nx

8958 B183 linesdepth 3pulls 3 transitivereach 11 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_resmon_lib.nx nx_procchurn_lib.nx nx_ctrl_fn.nx nx_ctrl_same.nx nx_ctxtop_lib.nx nx_fnclosure_probe.nx nx_procchurn.nx nx_procchurn_gate.nx

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

20const PC_RATIO_SAT: i64 = 1000000
21const PC_ASCII_0: i64 = 48
22const PC_ASCII_9: i64 = 57
23const PC_ASCII_NL: i64 = 10
24const PC_PERMIL: i64 = 1000
114const PC_NUMSCRATCH: i64 = 32
115const PC_ASCII_MINUS: i64 = 45

functions

32func pc_line_ints(buf: *u8, n: i64, key: *u8, out: *i64, maxv: i64) -> i64
called by 5: mainmainpc_scalarmainmain calls 1: rm_slen
81func pc_rate(delta: i64, elapsed_ms: i64) -> i64
89func pc_ratio_permil(sys_j: i64, usr_j: i64) -> i64
called by 4: mainmainmainmain
101func pc_verdict(forks_ps: i64, ratio_pm: i64, ctxsw_ps: i64,
called by 4: mainmainmainmain
122func pc_cat(d: *u8, o: i64, s: *u8) -> i64
called by 1: pc_frame
127func pc_catn(d: *u8, o: i64, v: i64) -> i64
153func pc_frame(d: *u8, ts: i64, win_ms: i64, forks_ps: i64, ctxsw_ps: i64, intr_ps: i64,
called by 5: mainmainmainmainmain calls 2: pc_catpc_catn