code wiki / (root) / nx_gpuguard.nx

nx_gpuguard.nx

buildroot/runtime/nx_gpuguard.nx

22844 B470 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_gpuguard.nx -- GPU SERVICE RESIDENCY GUARD: the DECISION, natively. nx_gpuguard decide <held_mb> <util_pct> <listening> <idle_ticks> [conf] nx_gpuguard -- self-gate (teeth incl. the liar-killers) WHY IT EXISTS, MEASURED 2026-08-14: sd-server was running WITHOUT --offload-to-cpu, so its weights were PINNED in VRAM for the process lifetime -- 302 MiB free of 16,303 on the 5080 -- and the gen lane had been dead for writes for hours. The launcher carrying that flag already existed, written to the operator's 2026-08-05 directive. NOTHING CHECKED THAT THE RUNNING PROCESS WAS THE ONE THE LAUNCHER STARTS. That is an adoption gap, and an adoption gap needs a guard, not another launcher. ★IT CHECKS THE CONDITION, NOT THE COMMAND LINE. A cmdline check answers "was it started right?"; this answers "is it behaving right?" -- which catches a bad start however it happened, survives a flag being renamed, and is measurable from outside the process. Behaviour over configuration. ★THE JUDGEMENT IS HERE, IN THE ORGAN. The laptop-side wire may only MEASURE (footprint, utilisation, is-the-port-bound) and ACT on the verdict. It decides nothing. The .ps1 keeper this replaces decided "wedged vs still loading" in shell, and the .ps1 sentinel classified "is a game present" in shell; both are exactly the shape the estate forbids -- shell doing work rather than carrying it. ★held_mb IS THE SERVICE'S OWN FOOTPRINT, NOT THE CARD'S. Judging on card-wide usage would read a game's VRAM as our service being resident and restart an innocent, healthy engine. Every threshold lives in knowledge/gpu_guard.conf. This organ carries NONE. exit/verdict: 0 OK | 1 START | 2 RESTART-RESIDENT | 3 RESTART-WEDGED | 4 BUSY | 5 WAIT | 6 REFUSE license_tier: ORIGINAL. No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_gpuguard.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gg_gate gg_puts sys_write gg_len sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gg_check gg_puts ↻ gg_name gg_decide gg_parse sys_mmap ↻ gg_slot gg_keyis gg_rdint gg_checkn gg_puts ↻ gg_putn sys_write ↻ sys_mmap ↻ gg_fill_sa gg_putn ↻ sys_exit ↻ gg_puts ↻ sys_mmap ↻ gg_load

structs

none

consts

29const GG_OK: i64 = 0
30const GG_START: i64 = 1
31const GG_RESTART_RESIDENT: i64 = 2
32const GG_RESTART_WEDGED: i64 = 3
33const GG_BUSY: i64 = 4
34const GG_WAIT: i64 = 5
35const GG_REFUSE: i64 = 6
37const GG_CFG_N: i64 = 4
38const GG_CFG_HOLD: i64 = 0
39const GG_CFG_BUSY: i64 = 1
40const GG_CFG_IDLE: i64 = 2
41const GG_CFG_WEDGE: i64 = 3
42const GG_CONF_DEFAULT: *u8 = "knowledge/gpu_guard.conf"

functions

44func gg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: gg_puts
45func gg_puts(s: *u8) -> i64 { sys_write(1, s, gg_len(s)); return 0 }
46func gg_putn(v: i64) -> i64
59func gg_atoi(s: *u8) -> i64
called by 1: main
71func gg_keyis(b: *u8, p: i64, len: i64, key: *u8) -> i64
called by 1: gg_slot
80func gg_slot(b: *u8, p: i64, len: i64) -> i64
called by 1: gg_parse calls 1: gg_keyis
89func gg_rdint(b: *u8, pos: *i64, end: i64) -> i64
113func gg_parse(b: *u8, len: i64, cfg: *i64, seen: *i64) -> i64
147func gg_decide(held_mb: i64, util_pct: i64, listening: i64, idle_ticks: i64, cfg: *i64) -> i64
called by 2: gg_gatemain
164func gg_name(v: i64) -> *u8
called by 2: gg_checkmain
173func gg_load(path: *u8, cfg: *i64) -> i64
called by 1: main calls 3: sys_mmapsys_read_filegg_parse
192func gg_fill_sa(sa: *u8, ip: *u8, port: i64) -> i64
called by 2: gg_probegg_gate
226func gg_probe(ip: *u8, port: i64, tmo: i64) -> i64
241func gg_readticks(path: *u8) -> i64
called by 1: main calls 3: sys_mmapsys_read_filegg_rdint
250func gg_writeticks(path: *u8, v: i64) -> i64
272func gg_check(ctr: *i64, name: *u8, got: i64, want: i64) -> i64
called by 1: gg_gate calls 2: gg_putsgg_name
285func gg_checkn(ctr: *i64, name: *u8, got: i64, want: i64) -> i64
called by 1: gg_gate calls 2: gg_putsgg_putn
297func gg_gate() -> i64
388func main(argc: i64, argv: *i64) -> i64