std/runtime
Runtime introspection and controls (GC and scheduler).
Lives in std/ rather than a hypothetical internal/ namespace because Vader has no compiler-private visibility tier today and Go-style "runtime" naming already signals the intent. Mostly intended for test harnesses and stress tests ; user programs should rarely need to call these.
Functions
collect :: fn() -> void Force a full collection now: a minor, then a major over the old generation. Returns once it completes.
collections :: fn() -> i32 Total number of GC cycles run since process start. Monotonically
increasing ; useful for asserting in stress tests that a forced
collect() actually ran.
Returns
i32 total cycle count since process start.bytes_used :: fn() -> i32 Old-generation live bytes plus the young generation's allocation. Right
after collect() this is the live-object footprint ; mid-mutation it also
counts uncollected garbage.
Returns
i32 the bytes in use, old and young.bytes_copied :: fn() -> i32 Cumulative bytes copied across all collections. A coarse measure of
total GC work: divide by collections() for the average per-cycle
payload.
Returns
i32 total bytes copied since process start.sched_now :: fn() -> i64 The scheduler clock, in milliseconds from 0. Advanced by sched_park as
timers fire. Backs std/async's sleep.
Returns
i64 the current scheduler time in ms.sched_arm :: fn(deadline: i64) -> void Register a wake at deadline (absolute scheduler ms) on the timer heap: the
scheduler will resume the parked program no earlier than then.
Parameters
| deadline | i64 | absolute scheduler time (ms) at which to wake. |
sched_park :: fn() -> i32 Park until the nearest armed deadline : wait for it (real time, unless
VADER_ASYNC_VIRTUAL_CLOCK is set), advance the clock to it, and drop every
timer then due: the caller re-drives all of its tasks after a park, so one
wake serves them all.
Returns
i32 0 = advanced to the next deadline ; 1 = deadlock: nothing armed, every task suspended with nothing left to wake it.