nx_mesh_autoscale.nx
buildroot/runtime/nx_mesh_autoscale.nx
about
nx_mesh_autoscale.nx -- WORKER MESH F3: sovereign AUTOSCALE-TO-ZERO controller (the Modal/KServe analog).
A GPU worker should hold VRAM only while there is work. This is the LIFECYCLE POLICY: given whether the worker is
warm (model in VRAM), whether there is demand (a pending/recent job), and how long it has been idle vs a TTL, it
decides one action -- SPAWN (warm it), SERVE (dispatch now), HOLD (do nothing), or REAP (free VRAM). The policy is
identical whether it runs natively on a NishiOS+VRAM host or drives a worker-host agent; the actuation (start/stop
the worker process) lives at the host boundary (CreateProcessW on Windows today, native on NishiOS).
Nishi is STRUCTURALLY ahead on scale-to-zero: idle = 0 MB / 0 procs (measured) and cold start ~1s, so demand-spawn +
idle-reap costs almost nothing -- exactly where the serving frameworks are "Best".
CLI: (no args) -> self-test GATE (decision table + savings + neg-controls)
tick <demand> <idle_sec> <ttl_sec> -> live: probe the worker for warmth, then print the DECISION (a host
agent calls this each cycle and actuates SPAWN/REAP)
tick <demand> <idle> <ttl> <a> <b> <c> <d> -> probe an explicit worker ipv4
Actions: 0 HOLD 1 SPAWN 2 SERVE 3 REAP. NO fake greens: the gate proves every transition + that REAP never fires
while warm-and-busy and SPAWN never fires while already warm. license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_connect.nxnx_runtime.nxnx_http_client.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 22 | const AM_MAGIC_7861: i64 = 7861 |
| 23 | const AM_MAGIC_2048: i64 = 2048 |
| 24 | const AM_MAGIC_2000: i64 = 2000 |
| 25 | const AM_MAGIC_16384: i64 = 16384 |
| 26 | const AM_MAGIC_16383: i64 = 16383 |
| 28 | const AM_HOLD: i64 = 0 |
| 29 | const AM_SPAWN: i64 = 1 |
| 30 | const AM_SERVE: i64 = 2 |
| 31 | const AM_REAP: i64 = 3 |
functions
| 33 | func am_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } |
| 34 | func am_wn(fd: i64, v: i64) -> i64 |
| 47 | func am_p(s: *u8) -> i64 { return am_w(1, s) } |
| 48 | func am_pn(v: i64) -> i64 { return am_wn(1, v) } |
| 49 | func am_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } called by 1: main |
| 50 | func am_action_name(a: i64) -> *u8 called by 1: main |
| 60 | func am_decide(warm: i64, demand: i64, idle_sec: i64, ttl_sec: i64) -> i64 |
| 74 | func am_savings_permil(warm_sec: i64, window_sec: i64) -> i64 called by 1: am_gate |
| 84 | func am_resp_2xx(buf: *u8, n: i64) -> i64 called by 1: am_probe_warm |
| 94 | func am_pollfd(pfd: *u8, fd: i64, events: i64) -> i64 called by 1: am_probe_warm |
| 100 | func am_probe_warm(a: i64, b: i64, c: i64, d: i64) -> i64 called by 1: main calls 11: sys_mmapnx_http_client_sockaddr_ipv4sys_socketnx_connect_boundedam_pollfdsys_poll+5 |
| 126 | func am_gate() -> i64 |
| 178 | func am_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 185 | func main(argc: i64, argv: *i64) -> i64 |