code wiki / (root) / nx_resource_arbiter.nx

nx_resource_arbiter.nx

buildroot/runtime/nx_resource_arbiter.nx

12342 B337 linesdepth 2pulls 2 transitivereach 75 importersview sourcekind librarytopic resource
docsdependenciesstructsconstsfunctions

about

nx_resource_arbiter.nx -- allocation under contention with priority + treaty. Per CARDINAL [[feedback-conductor-heterogeneous-compute-no-second-class- resources]] + [[feedback-parallel-companion-multimodal-dnd-real-time]]: when multiple cells want the same scarce resource (VRAM bytes, CPU microseconds, NVMe iops), the arbiter decides who gets it based on priority + active treaty + current allocation share. REFUSES the "first-come-first-served leads to starvation of low-rate streams" and "highest-priority-always-wins leads to background-cell death" failure modes. V1 ships sealed resource enum + request enum + grant verdict + per-cell allocation tracking + max-share fairness floor (no cell gets >X% in a single epoch) + per-resource budget pool.

dependencies 2 imports · 15 importers

nx_syscalls.nx nx_tier.nx nx_resource_arbiter.nx nx_bench_companion.nx nx_bench_companion_test.nx nx_companion_compose_test.nx nx_fio_region_gate.nx nx_issue_intake_candidate_t181.nx nx_mgmt_api.nx nx_mgmt_api_search_candidate_t330. nx_mgmt_cap_candidate_t186.nx nx_mgmt_deploy_candidate_t185.nx nx_request_pool.nx

diagram shows first 10 each side; +0 more imports, +5 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_bench_companion.nxnx_bench_companion_test.nxnx_companion_compose_test.nxnx_fio_region_gate.nxnx_issue_intake_candidate_t181.nxnx_mgmt_api.nxnx_mgmt_api_search_candidate_t330.nxnx_mgmt_cap_candidate_t186.nxnx_mgmt_deploy_candidate_t185.nxnx_request_pool.nxnx_request_pool_candidate_t230.nxnx_resource_arbiter_test.nxnx_session.nxnx_session_test.nxnx_swarm_arbitrate.nx

structs

43struct NxAllocation
56struct NxResourceArbiter

consts

21const NX_RA_KIND_VRAM_BYTES: nx_int = 0
22const NX_RA_KIND_RAM_BYTES: nx_int = 1
23const NX_RA_KIND_DISK_BYTES: nx_int = 2
24const NX_RA_KIND_CPU_MICROSECONDS: nx_int = 3
25const NX_RA_KIND_GPU_MICROSECONDS: nx_int = 4
26const NX_RA_KIND_NETWORK_BYTES: nx_int = 5
27const NX_RA_KIND_FILE_HANDLES: nx_int = 6
28const NX_RA_KIND_N: nx_int = 7
32const NX_RA_V_GRANTED_FULL: nx_int = 0
33const NX_RA_V_GRANTED_PARTIAL: nx_int = 1 // less than requested
34const NX_RA_V_DENIED_NO_BUDGET: nx_int = 2
35const NX_RA_V_DENIED_MAX_SHARE: nx_int = 3 // would exceed fairness cap
36const NX_RA_V_DENIED_PREEMPTED: nx_int = 4 // higher-pri cell took it back
37const NX_RA_V_INVALID: nx_int = 5
38const NX_RA_V_NULL: nx_int = 6
39const NX_RA_V_N: nx_int = 7
53const NX_RA_ABI_CELL_BYTES: nx_int = __size_of(nx_int)
54const NX_RA_A_BYTES: nx_int = __size_of(NxAllocation)
70const NX_RA_BYTES: nx_int = __size_of(NxResourceArbiter)
71const NX_RA_Q10_ONE: nx_int = 1024
72const NX_RA_SIZE_MAX: nx_size = 9223372036854775807

functions

76func nx_ra_kind_is_valid(k: nx_int) -> nx_int
82func nx_ra_v_is_valid(v: nx_int) -> nx_int
called by 1: main
90func nx_ra_new(capacity: nx_int) -> *NxResourceArbiter
122func _ra_alloc_at(a: *NxResourceArbiter, idx: nx_int) -> *NxAllocation
131func nx_ra_set_budget(a: *NxResourceArbiter,
142func nx_ra_set_max_share(a: *NxResourceArbiter,
154func nx_ra_get_budget(a: *NxResourceArbiter, resource_kind: nx_int) -> nx_size
163func nx_ra_total_held(a: *NxResourceArbiter, resource_kind: nx_int) -> nx_size
175func nx_ra_held_by_cell(a: *NxResourceArbiter,
196func nx_ra_request(a: *NxResourceArbiter,
269func nx_ra_release(a: *NxResourceArbiter,
291func nx_ra_preempt(a: *NxResourceArbiter,
319func nx_ra_grants_full(a: *NxResourceArbiter) -> nx_int
called by 2: nx_bc_capturemain
324func nx_ra_grants_partial(a: *NxResourceArbiter) -> nx_int
called by 2: nx_bc_capturemain
329func nx_ra_denials(a: *NxResourceArbiter) -> nx_int
called by 2: nx_bc_capturemain
334func nx_ra_preemptions(a: *NxResourceArbiter) -> nx_int
called by 2: nx_bc_capturemain