code wiki / (root) / nx_vsz_watchdog_core.nx

nx_vsz_watchdog_core.nx

buildroot/runtime/nx_vsz_watchdog_core.nx

7776 B158 linesdepth 2pulls 2 transitivereach 25 importersview sourcekind librarytopic vsz
docsdependenciesstructsconstsfunctions

about

nx_vsz_watchdog_core.nx -- importable CORE of the VSZ watchdog (the permanent fix for outage MODE 2: mmap-per-request daemons never munmap -> VSZ balloons (mgmt hit ~160GB) -> fork() fails -> child-exec SILENTLY EMPTY while /api/health stays 200; see reference-mgmt-api-outage-tmp-log-rootcause-2026-07-12). The watchdog DECIDES DEATH ONLY: it kills a conf-listed daemon whose VSZ crossed its threshold; RESPAWN stays 100% the nx_hostctl guard's job (single responsibility, no dueling supervisors). FAIL-SAFE BY CONSTRUCTION: no conf file -> INERT; unreadable /proc -> skip; cooldown suppresses kill-storms; pid<=300 and self are never killed. Pure decision funcs here (gate-locked); the /proc walk + kill live in the CLI. license_tier: ORIGINAL

dependencies 1 imports · 10 importers

nx_syscalls.nx nx_vsz_watchdog_core.nx nx_fsops_lib.nx nx_heal_lib.nx nx_hget_leak_probe.nx nx_leak_check_lib.nx nx_resgov.nx nx_seg_cache_gate.nx nx_sweep_daemon_lib.nx nx_toolreg_reconcile_lib.nx nx_vsz_watchdog.nx nx_vsz_watchdog_gate.nx

imports: nx_syscalls.nx

imported by: nx_fsops_lib.nxnx_heal_lib.nxnx_hget_leak_probe.nxnx_leak_check_lib.nxnx_resgov.nxnx_seg_cache_gate.nxnx_sweep_daemon_lib.nxnx_toolreg_reconcile_lib.nxnx_vsz_watchdog.nxnx_vsz_watchdog_gate.nx

structs

none

consts

11const VW_PROC_PATH_CAP: i64 = 256 // /proc/<pid>/status path buffer
12const VW_STATUS_BUF: i64 = 8192 // /proc status read buffer
13const VW_PTR_CELL: i64 = 16 // 2-i64 scratch cell (vw_num_at end-pointer out-param)

functions

15func vw_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
18func vw_contains(hay: *u8, hn: i64, needle: *u8, nn: i64) -> i64
32func vw_num_at(s: *u8, n: i64, off: i64, endp: *i64) -> i64
48func vw_parse_row(buf: *u8, ls: i64, le: i64, outp: *i64) -> i64
74func vw_status_kb(buf: *u8, n: i64, pat: *u8) -> i64
97func vw_should_kill(vsz_kb: i64, max_gb: i64, last_kill_s: i64, now_s: i64, cooldown_s: i64) -> i64
called by 2: mainmain
106func vw_read(path: *u8, buf: *u8, cap: i64) -> i64
117func vw_now_s() -> i64 { let ts: *i64 = sys_mmap(16) as *i64; sys_clock_gettime_mono(ts); return ts[0] }
called by 1: main calls 2: sys_mmapsys_clock_gettime_mono
120func vw_selfpid() -> i64
131func vw_vmsize_parse(buf: *u8, n: i64) -> i64 { return vw_status_kb(buf, n, "VmSize:" as *u8) }
called by 1: main calls 1: vw_status_kb
135func vw_status_kb_of(dirname: *u8, label: *u8) -> i64
156func vw_vmsize_kb_of(dirname: *u8) -> i64 { return vw_status_kb_of(dirname, "VmSize:" as *u8) }
158func vw_rss_kb_of(dirname: *u8) -> i64 { return vw_status_kb_of(dirname, "VmRSS:" as *u8) }
called by 2: lc_rssmain calls 1: vw_status_kb_of