code wiki / _hdl_build / nx_polite_loop.nx

nx_polite_loop.nx

buildroot/runtime/_hdl_build/nx_polite_loop.nx

6465 B113 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tooltopic polite
docsdependenciesstructsconstsfunctions

about

nx_polite_loop.nx -- the team's RESOURCE-AWARE autonomous backlog loop (operator: "it needs to be resource aware so when im playing a game or doing other things it should pause or run minimally based on the hardware resources"). Composes the team's OWN governor: nx_sysload reads real /proc (load, ncpu, free mem) and nx_resource_governor (POLITE) decides -> PAUSE when over the load ceiling (you're gaming/busy), run MINIMAL (fewer tasks) under partial load, full when idle; always nice; memory-floor admission; AIMD backoff. A /tmp/nishi_pause flag forces PAUSE (escape hatch + the hook a Windows GPU/foreground sensor can touch, since WSL /proc can't see a Windows game directly). When allowed, it runs a backlog TICK by ITERATIVE reach (no recursion -> dodges the regalloc segfault): the Builder composes each task or RAISES A HAND -> escalation queue. license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_sysload.nx nx_resource_governor.nx nx_syscalls.nx nx_polite_loop.nx

imports: nx_sysload.nxnx_resource_governor.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sl_loadavg_milli sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close sl_ncpu sys_mmap ↻ sys_read_file ↻ sl_count_substr sl_freemem_mb sys_mmap ↻ sys_read_file ↻ pl_puts sys_write pl_putn sys_mmap ↻ sys_write ↻ sys_mmap ↻ sys_read_file ↻ rg_should_backoff rg_memory_ok rg_worker_budget rg_nice sys_exit rg_backoff_ms sys_openat_append pl_reach sys_mmap ↻ sys_write ↻ sys_close ↻

structs

none

consts

18const PL_RESERVE: i64 = 1 // always leave 1 core for the foreground (your game/app)
19const PL_CEIL_MILLI: i64 = 800 // per-core ceiling: load > 0.8*ncpu -> PAUSE (you're busy)
20const PL_MEM_FLOOR_MB: i64 = 1024 // don't start work under 1 GB free
21const PL_BASE_BACKOFF: i64 = 1000 // ms, grows AIMD with overload
23const NTYPE: i64 = 8
24const NP: i64 = 8
25const NTASK: i64 = 6

functions

14func pl_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
15func pl_putn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1}; sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
28func pl_reach(tin: i64, tout: i64, pin: *i64, pout: *i64, pav: *i64) -> i64
called by 1: main calls 1: sys_mmap
44func main() -> i64