code wiki / (root) / nx_mesh_autoscale.nx

nx_mesh_autoscale.nx

buildroot/runtime/nx_mesh_autoscale.nx

11895 B220 linesdepth 6pulls 9 transitivereach 0 importersview sourcekind tooltopic mesh
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_connect.nx nx_runtime.nx nx_http_client.nx nx_mesh_autoscale.nx

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

main am_streq am_w sys_write am_atoi am_decide am_p am_w ↻ am_pn am_wn sys_mmap sys_write ↻ am_action_name am_probe_warm sys_mmap ↻ nx_http_client_sockaddr_ip sys_socket nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll am_pollfd sys_poll ↻ sys_close nx_http_client_build_reque hc_put_caps sys_mmap ↻ nx_codec_caps_headers sys_mmap ↻ nx_codec_caps_accept_docum sys_mmap ↻ nx_codec_caps_accept_image nx_cc_put nx_codec_caps_accept_encod cc_encoding_have nx_cc_put ↻ cc_encoding_name nx_cc_put ↻ sys_write ↻

structs

none

consts

22const AM_MAGIC_7861: i64 = 7861
23const AM_MAGIC_2048: i64 = 2048
24const AM_MAGIC_2000: i64 = 2000
25const AM_MAGIC_16384: i64 = 16384
26const AM_MAGIC_16383: i64 = 16383
28const AM_HOLD: i64 = 0
29const AM_SPAWN: i64 = 1
30const AM_SERVE: i64 = 2
31const AM_REAP: i64 = 3

functions

33func 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 }
called by 3: am_pam_gatemain calls 1: sys_write
34func am_wn(fd: i64, v: i64) -> i64
called by 2: am_pnam_gate calls 2: sys_mmapsys_write
47func am_p(s: *u8) -> i64 { return am_w(1, s) }
called by 2: am_gatemain calls 1: am_w
48func am_pn(v: i64) -> i64 { return am_wn(1, v) }
called by 2: am_gatemain calls 1: am_wn
49func 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
50func am_action_name(a: i64) -> *u8
called by 1: main
60func am_decide(warm: i64, demand: i64, idle_sec: i64, ttl_sec: i64) -> i64
called by 2: am_gatemain
74func am_savings_permil(warm_sec: i64, window_sec: i64) -> i64
called by 1: am_gate
84func am_resp_2xx(buf: *u8, n: i64) -> i64
called by 1: am_probe_warm
94func am_pollfd(pfd: *u8, fd: i64, events: i64) -> i64
called by 1: am_probe_warm
100func am_probe_warm(a: i64, b: i64, c: i64, d: i64) -> i64
126func am_gate() -> i64
178func am_streq(a: *u8, b: *u8) -> i64
called by 1: main
185func main(argc: i64, argv: *i64) -> i64