code wiki / (root) / nx_poolgov.nx

nx_poolgov.nx

buildroot/runtime/nx_poolgov.nx

8531 B185 linesdepth 3pulls 3 transitivereach 7 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_poolgov.nx -- THE POOL-WIDTH GOVERNOR, in the PRIMITIVE layer where production organs can reach it. WHY IT LIVES HERE (seq1450): I first built this in _hdl_build/ and wiring it into nx_torrent_get failed with `nx_compile_x86: expand_imports failed`. The layering edge is DIRECTED and was undocumented: _hdl_build/ organs MAY import runtime/ libs, but a runtime/ organ may NOT import _hdl_build/. runtime/ = PRIMITIVE layer, _hdl_build/ = ORGAN/TOOL layer, and primitives may not depend on tools. LAW: BUILD THE PRIMITIVE IN THE LAYER ITS CONSUMERS CAN REACH -- the import graph, not taste, decides. WHAT IT FIXES (seq1402/seq1410): nx_torrent_get.nx carried `let MAXP: i64 = 32` -- a hardcoded literal (rule-11) that made every machine identical: NAS (4c/8t), west server, laptop, any future box all ran 32 slots, sized for hardware nobody measured. And 32 was PER-INSTANCE: nx_procchurn measured 143 forks/sec = ~9 concurrent instances = ~288 concurrent slots on an 8-thread box. NOBODY CHOSE 143. LAW: A PER-INSTANCE LIMIT IS NOT A LIMIT -- N instances multiply it and nobody ever picks N. WHAT IT DELIBERATELY DOES NOT DO: throttle the connection CYCLING. Constant cycling IS the BitTorrent throughput strategy (continuous optimistic-unchokes vs fast-burst-then-freeze). Slowing it would attack the feature to flatten a graph -- operator rule 25. Only WIDTH is governed; inside the budget the pool stays exactly as aggressive as before. The load parse is duplicated from nx_ctxtop_lib BY LAYER NECESSITY, not by neglect -- the organ-layer copy cannot be imported down here. Correct resolution: the organ layer should import THIS one (the allowed direction) and its copy retire. Tracked, not pretended away. license_tier: ORIGINAL Read-only. No hw writes (Rule 26).

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_hw.nx nx_poolgov.nx nx_poolgov_gate.nx nx_torrent_get.nx

imports: nx_syscalls.nxnx_hw.nx

imported by: nx_poolgov_gate.nxnx_torrent_get.nx

structs

none

consts

33const PG_UNKNOWN_LOAD: i64 = 0 - 1
34const PG_DIRBUF: i64 = 65536
35const PG_PATHBUF: i64 = 256
36const PG_CMDBUF: i64 = 8192
37const PG_LOADBUF: i64 = 128
38const PG_SCALE: i64 = 100
39const PG_DOT: i64 = 46

functions

30func pg_dreclen(rec: *u8) -> i64 { return (rec[16] as i64) | ((rec[17] as i64) << 8) }
called by 2: pg_count_procsmain
31func pg_dname(rec: *u8) -> *u8 { return ((rec as i64) + 19) as *u8 }
called by 2: pg_count_procsmain
44func pg_budget_from_hw(slots_per_cpu: i64, floor: i64) -> i64
called by 1: main calls 1: nx_hw_cpu_count
54func pg_load_centi() -> i64
96func pg_count_procs(needle: *u8) -> i64
164func pg_width(total_budget: i64, n_instances: i64, load_centi: i64,
called by 1: main
180func pg_aggregate(width: i64, n_instances: i64) -> i64
called by 1: main