Scheduler
Scheduler: runtime observability for the actor/task scheduler.
These counters are the load-shedding substrate: a supervisor or ingress actor polls them to decide when to shed. Interpreted backend reports the subset that is meaningful without the C scheduler (live actor count); unknown/unsupported indices read 0 on both backends.
Every value is an instantaneous reading of the running program, so the examples below compare readings rather than pinning them.
Functions
Messages dropped by bounded-mailbox overflow policies (see Actor.set_queue_limit), summed over every actor for the program lifetime.
let dropped = Scheduler.dropped_messages()
if dropped > last_dropped do alert(dropped - last_dropped) else () endGreen-thread processes currently alive (actors + tasks + main). The interpreter counts live actors only.
let before = Scheduler.live_procs()
let pid = spawn(Worker)
Scheduler.live_procs() - before -- 1 while the worker livesCross-thread global run-queue depth (instantaneous). Compiled backend only; the interpreter reads 0.
if Scheduler.runq_depth() > 1000 do shed(req) else serve(req) endRaw stat by index:
- 0 live procs
- 1 total spawned
- 2 global runq depth
- 3 stack-alloc failures
- 4 messages dropped by mailbox policy
- 5 stacks recycled
- 6 pending timers
- 7 execution contexts released at proc death
- 8 dead proc structs freed
- 9 dead proc structs retired and still waiting for their grace period
- 10 dead actors' metadata freed
- 11 dead actors' metadata retired and still waiting for its grace period
An unknown index (including a negative one) reads 0, as does a counter the interpreter does not track.
Examples
march> Scheduler.stat(99)
0
march> Scheduler.stat(1) >= Scheduler.stat(0)
trueProcesses ever spawned over the program lifetime. Never decreases, and is never below live_procs().
Examples
march> Scheduler.total_spawned() >= Scheduler.live_procs()
true