code wiki / _hdl_build / nx_procchurn_lib.nx

nx_procchurn_lib.nx

buildroot/runtime/_hdl_build/nx_procchurn_lib.nx

22888 B474 linesdepth 5pulls 6 transitivereach 16 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 2 imports · 6 importers

nx_resmon_lib.nx nx_ioadmit_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.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

21const PC_RATIO_SAT: i64 = 1000000
22const PC_ASCII_0: i64 = 48
23const PC_ASCII_9: i64 = 57
24const PC_ASCII_NL: i64 = 10
25const PC_PERMIL: i64 = 1000
115const PC_NUMSCRATCH: i64 = 32
116const PC_ASCII_MINUS: i64 = 45
201const PC_ACT_PROCEED: i64 = 0
202const PC_ACT_SLOW: i64 = 1
203const PC_ACT_DEFER: i64 = 2
204const PC_ACT_UNOBSERVABLE: i64 = 3
205const PC_SEVKEY_LEN: i64 = 5
206const PC_TSKEY_LEN: i64 = 3
344const PC_PATHBUF: i64 = 64
345const PC_DIRBUF: i64 = 65536
346const PC_DIRENT_NAME_OFF: i64 = 19
347const PC_ST_PPID: i64 = 2 // ioa_stat_parse out layout: 0=comm start, 1=comm length, 2=ppid

functions

33func pc_line_ints(buf: *u8, n: i64, key: *u8, out: *i64, maxv: i64) -> i64
called by 5: mainmainpc_scalarmainmain calls 1: rm_slen
82func pc_rate(delta: i64, elapsed_ms: i64) -> i64
90func pc_ratio_permil(sys_j: i64, usr_j: i64) -> i64
called by 4: mainmainmainmain
102func pc_verdict(forks_ps: i64, ratio_pm: i64, ctxsw_ps: i64,
called by 4: mainmainmainmain
123func pc_cat(d: *u8, o: i64, s: *u8) -> i64
called by 2: mainpc_frame
128func pc_catn(d: *u8, o: i64, v: i64) -> i64
154func 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
208func pc_isdig(c: i64) -> i64
217func pc_find_in(buf: *u8, s: i64, e: i64, key: *u8) -> i64
called by 1: pc_sev_last
238func pc_int_at(buf: *u8, p: i64, e: i64) -> i64
called by 1: pc_sev_last calls 1: pc_isdig
268func pc_sev_last(buf: *u8, n: i64, out: *i64) -> i64
called by 2: mainmain calls 2: pc_find_inpc_int_at
304func pc_sev_consumer(sev: i64, age_s: i64, max_age_s: i64) -> i64
called by 2: mainmain
314func pc_act_name(a: i64) -> *u8
called by 1: main
351func pc_name_is_pid(s: *u8) -> i64
called by 2: mainpc_pids calls 1: pc_isdig
362func pc_name_to_i64(s: *u8) -> i64
called by 2: mainpc_pids
373func pc_pids(out: *i64, cap: i64, out_full: *i64) -> i64
407func pc_pid_seen(pids: *i64, n: i64, pid: i64) -> i64
416func pc_ppid_of(pid: i64, sbuf: *u8, pathb: *u8, out: *i64) -> i64
426func pc_tally_parent(ppids: *i64, counts: *i64, np: i64, maxp: i64, ppid: i64) -> i64
443func pc_fork_by_parent(prev: *i64, prev_n: i64, cur: *i64, cur_n: i64,
470func pc_attrib_permil(attributed: i64, kernel_forks: i64) -> i64
called by 2: mainmain