code wiki / _hdl_build / nx_resource_governor.nx
nx_resource_governor.nx
buildroot/runtime/_hdl_build/nx_resource_governor.nx
about
nx_resource_governor.nx -- the POLITE resource governor: decides how many workers the team may run so it
never overwhelms the host, backing off under load and scaling up as resources free (operator: "an
intelligent begin setup for the team to pick up work without overwhelming this system or any system they
are on but to be polite... till the resources are available... living auto scaling"). Two modes:
POLITE (default) -- leave headroom, run low-priority (nice), back off when load is high.
CRASH_GATES (override) -- full throttle for a user-chosen task, ignore politeness.
Pure policy (host signals passed in by nx_sysload); load is in MILLI cores (load_avg x1000). license_tier: ORIGINAL
dependencies 1 imports · 11 importers
diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.
imports: nx_syscalls.nx
imported by: nx_crawl_burst.nxnx_genesis_grow.nxnx_governed_autoloop.nxnx_governed_pulse.nxnx_import_probe.nxnx_polite_daemon.nxnx_polite_loop.nxnx_resource_prove.nxnx_selfbuild_governed.nxnx_team_console.nxnx_unified_conductor.nx
structs
| none |
consts
| 11 | const RG_POLITE: i64 = 1 |
| 12 | const RG_CRASH_GATES: i64 = 2 |
functions
| 16 | func rg_worker_budget(mode: i64, ncpu: i64, load_milli: i64, reserve: i64, ceil_factor_milli: i64) -> i64 |
| 29 | func rg_should_backoff(mode: i64, ncpu: i64, load_milli: i64, ceil_factor_milli: i64) -> i64 |
| 36 | func rg_nice(mode: i64) -> i64 { if mode == RG_CRASH_GATES { return 0 } return 10 } |
| 39 | func rg_memory_ok(free_mb: i64, floor_mb: i64) -> i64 { if free_mb >= floor_mb { return 1 } return 0 } |
| 42 | func rg_backoff_ms(mode: i64, ncpu: i64, load_milli: i64, ceil_factor_milli: i64, base_ms: i64) -> i64 |
| 50 | func rg_mode_label(mode: i64) -> *u8 { if mode == RG_CRASH_GATES { return "CRASH-GATES" as *u8 } return "POLITE" as *u8 } |
| 55 | func rg_serve_first(active_conns: i64) -> i64 { if active_conns > 0 { return 1 } return 0 } |
| 57 | func rg_hosting_reserve(ncpu: i64) -> i64 { let r: i64 = ncpu / 2; if r < 1 { return 1 } return r } |
| 59 | func rg_hosting_ceil_milli() -> i64 { return 500 } |
| 65 | func rg_hw_class_reserve(ncpu: i64) -> i64 |
| 71 | func rg_hw_budget(mode: i64, ncpu: i64, load_milli: i64, ceil_factor_milli: i64) -> i64 called by 5: crawl_budgethw_budgetrp_decidemainuc_budget calls 2: rg_worker_budgetrg_hw_class_reserve |