code wiki / (root) / nx_ship_fleet.nx

nx_ship_fleet.nx

buildroot/runtime/nx_ship_fleet.nx

12244 B234 linesdepth 3pulls 5 transitivereach 0 importersview sourcekind tooltopic ship
docsdependenciesstructsconstsfunctions

about

nx_ship_fleet.nx -- INTELLIGENT (adaptive-concurrency) FLEET SHIPPER. Drains a list of targets by running as many concurrent ships as the box can take RIGHT NOW -- never serially (too slow to drain a backlog), never blindly (3 blind concurrent ships stormed the box on 2026-09-02). It composes the estate's existing pieces into the DRIVER that was missing: SENSE nx_sysload (sl_ncpu / sl_loadavg_milli / sl_freemem_mb / sl_active_conns_8443) GOVERN nx_resource_governor rg_worker_budget -> the polite headroom budget, used here as a concurrency WIDTH (the governed drivers computed this budget and then fired ONE task per beat -- the budget was never used as a width, which is exactly why concurrent shipping was ungoverned) ADMIT fork _offc/nx_build_admit.elf -> its exit code is the DIRECT I/O-storm signal (D-state witness), which the CPU-load budget alone cannot see (our storms are I/O on a degraded RAID, not CPU) AIMD nx_shipfleet_lib -- +1 on progress, halve on a storm refusal, ceilinged by the polite budget POOL fork _offc/nx_organ_ship.elf per target; reap with wait4(WNOHANG); requeue nothing blindly Research (Sept 2026): AIMD adaptive concurrency limits (Netflix concurrency-limits, Envoy adaptive_concurrency filter, ThomWright/congestion-limiter) + HPA-style headroom budgeting. The field infers congestion from latency; our exceed is a measured congestion signal (build_admit reads /proc). usage: nx_ship_fleet <targets-file> [plan] <targets-file> one target name per line; '#' and blank lines skipped plan SENSE + print the width the controller WOULD use, fork NOTHING (safe live demo) license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_sysload.nx nx_resource_governor.nx nx_shipfleet_lib.nx nx_ship_fleet.nx

imports: nx_syscalls.nxnx_sysload.nxnx_resource_governor.nxnx_shipfleet_lib.nx

imported by: nobody (leaf or entry point)

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

main sf_w sys_write sf_slen 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 ↻ sf_read sys_openat_rd sys_read sys_close sf_n sys_write ↻ sys_mmap ↻ sl_ncpu sys_mmap ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read ↻ sys_munmap sys_close ↻ sl_count_substr sl_loadavg_milli sys_mmap ↻ sys_read_file ↻ sl_freemem_mb

structs

none

consts

28const SF_MEM_FLOOR_MB: i64 = 256
29const SF_CEIL_MILLI: i64 = 800 // back off at 0.8 core/cpu (rg default; shipping is background, not latency-sacred)
30const SF_BASE_BACKOFF_MS:i64 = 2000 // AIMD storm back-off base (rg_backoff_ms scales it up with overload)
31const SF_TICK_MS: i64 = 250 // settle time between launch ticks (avoid busy-spin on /proc)
32const SF_MAX_STORM_TICKS:i64 = 120 // ~ bounded: consecutive storm/busy ticks before giving up (killable, deferred reported)
33const SF_MAXTARGETS: i64 = 4096
34const SF_NAMECAP: i64 = 128
35const SF_INFLIGHT_CAP: i64 = 256
36const SF_READCAP: i64 = 1048576
37const SF_SHIP_ELF: *u8 = "_offc/nx_organ_ship.elf" as *u8
38const SF_ADMIT_ELF: *u8 = "_offc/nx_build_admit.elf" as *u8
39const SF_DEVNULL: *u8 = "/dev/null\x00" as *u8

functions

41func sf_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: sf_w
42func sf_w(s: *u8) -> i64 { sys_write(1, s, sf_slen(s)); return 0 }
called by 1: main calls 2: sys_writesf_slen
43func sf_n(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
54func sf_read(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
63func sf_admit_grant() -> i64
81func sf_launch(target: *u8) -> i64
96func sf_rg_budget(ncpu: i64, load: i64, freemb: i64) -> i64
102func main(argc: i64, argv: *i64) -> i64