nx_poolgov.nx
buildroot/runtime/nx_poolgov.nx
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
imports: nx_syscalls.nxnx_hw.nx
imported by: nx_poolgov_gate.nxnx_torrent_get.nx
structs
| none |
consts
| 33 | const PG_UNKNOWN_LOAD: i64 = 0 - 1 |
| 34 | const PG_DIRBUF: i64 = 65536 |
| 35 | const PG_PATHBUF: i64 = 256 |
| 36 | const PG_CMDBUF: i64 = 8192 |
| 37 | const PG_LOADBUF: i64 = 128 |
| 38 | const PG_SCALE: i64 = 100 |
| 39 | const PG_DOT: i64 = 46 |
functions
| 30 | func pg_dreclen(rec: *u8) -> i64 { return (rec[16] as i64) | ((rec[17] as i64) << 8) } |
| 31 | func pg_dname(rec: *u8) -> *u8 { return ((rec as i64) + 19) as *u8 } |
| 44 | func pg_budget_from_hw(slots_per_cpu: i64, floor: i64) -> i64 |
| 54 | func pg_load_centi() -> i64 |
| 96 | func pg_count_procs(needle: *u8) -> i64 |
| 164 | func pg_width(total_budget: i64, n_instances: i64, load_centi: i64, called by 1: main |
| 180 | func pg_aggregate(width: i64, n_instances: i64) -> i64 called by 1: main |