code wiki / _hdl_build / nx_resource_governor.nx

nx_resource_governor.nx

buildroot/runtime/_hdl_build/nx_resource_governor.nx

4708 B73 linesdepth 2pulls 2 transitivereach 11 importersview sourcekind librarytopic resource
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_resource_governor.nx nx_crawl_burst.nx nx_genesis_grow.nx nx_governed_autoloop.nx nx_governed_pulse.nx nx_import_probe.nx nx_polite_daemon.nx nx_polite_loop.nx nx_resource_prove.nx nx_selfbuild_governed.nx nx_team_console.nx

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

11const RG_POLITE: i64 = 1
12const RG_CRASH_GATES: i64 = 2

functions

16func rg_worker_budget(mode: i64, ncpu: i64, load_milli: i64, reserve: i64, ceil_factor_milli: i64) -> i64
29func rg_should_backoff(mode: i64, ncpu: i64, load_milli: i64, ceil_factor_milli: i64) -> i64
36func rg_nice(mode: i64) -> i64 { if mode == RG_CRASH_GATES { return 0 } return 10 }
called by 4: mainmainmainmain
39func rg_memory_ok(free_mb: i64, floor_mb: i64) -> i64 { if free_mb >= floor_mb { return 1 } return 0 }
42func rg_backoff_ms(mode: i64, ncpu: i64, load_milli: i64, ceil_factor_milli: i64, base_ms: i64) -> i64
called by 4: mainmainmainmain
50func rg_mode_label(mode: i64) -> *u8 { if mode == RG_CRASH_GATES { return "CRASH-GATES" as *u8 } return "POLITE" as *u8 }
55func rg_serve_first(active_conns: i64) -> i64 { if active_conns > 0 { return 1 } return 0 }
57func rg_hosting_reserve(ncpu: i64) -> i64 { let r: i64 = ncpu / 2; if r < 1 { return 1 } return r }
59func rg_hosting_ceil_milli() -> i64 { return 500 }
65func rg_hw_class_reserve(ncpu: i64) -> i64
71func rg_hw_budget(mode: i64, ncpu: i64, load_milli: i64, ceil_factor_milli: i64) -> i64