nx_pool_ring_gate.nx
buildroot/runtime/nx_pool_ring_gate.nx
about
nx_pool_ring_gate.nx -- regression witness for the RING ARENA fix
in nx_thread_pool (2026-07-08).
The task arena was a bump allocator (16384 slots); past that,
nx_pool_submit returned -1 without queuing, and a caller that then
delta-waited spun to the 2-billion timeout. A long-lived shared
pool (the LLM forward submits thousands of tasks per token) hit
this and wedged 428s/token. Fix: slot index wraps modulo
arena_cap; SAFE because channel depth << arena_cap so a slot is
consumed long before the ring wraps back to it.
This gate submits N >> arena_cap tasks to ONE pool (forcing several
full ring wraps), each atomically incrementing a shared counter,
and verifies EVERY task ran exactly once -- the exact scenario that
silently dropped tasks before.
Checks:
1 shared counter == N (no task lost to a dropped submit)
2 pool completed-counter == N (delta-wait saw them all)
3 a SECOND batch on the same pool also completes (reuse across
the wrap boundary)
lineage_id: pool_ring_gate_v1
dependencies 3 imports · 0 importers
imports: nx_thread_pool.nxnx_atom.nxnx_fmt.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 30 | const RG_N: i64 = 50000 |
| 31 | const RG_N2: i64 = 20000 |
functions
| 33 | func rg_task(ctx: i64) -> i64 calls 1: nx_atom_faa_i64 |
| 39 | func rg_nl() -> i64 { fmt_puts("\n" as *u8); return 0 } |
| 41 | func main() -> i64 |