Skip to main content

Module census

Module census 

Source
Expand description

Env-gated LIVE-OBJECT CENSUS.

A permanent, zero-cost-when-off diagnostic answering the question: when sui’s eval peak is ~2× nix’s, is the overhead (a) cyclic/lingering producer garbage sui retains, or (b) a uniform per-object representation overhead? These need different fixes, so we MEASURE.

Gated behind SUI_LIVE_CENSUS=1. The atomics are always compiled but the _MADE/_LIVE bookkeeping and the RSS/dump thread only run when enabled. All counters use Relaxed — we want a cheap high-water snapshot, not a linearizable total.

_MADE + _LIVE are incremented in the INNER heap type’s constructor; _LIVE is decremented in the inner type’s Drop so it fires exactly once when the last Rc drops. Counters live on the inner heap types (NixAttrs, ThunkInner, EnvInner, NixString, the list Vec) so we count distinct heap allocations, not Rc clones.

Statics§

ATTRS_LIVE
ATTRS_MADE
ENV_LIVE
ENV_MADE
LIST_LIVE
LIST_MADE
NIXSTR_LIVE
NIXSTR_MADE
SCOPE_THUNKS_NARROWED
Scope-narrowing verdict counters (SUI_SCOPE_NARROW, eval.rs).
SCOPE_THUNKS_PINNED
THUNK_EVALUATED
THUNK_LIVE
THUNK_MADE

Functions§

dropped
dump
Print all live/made counts + RSS to stderr, tagged.
enabled
True iff SUI_LIVE_CENSUS=1. Cached — read once.
evaluated
made
rss_bytes
Resident set size of this process, in bytes (macOS + Linux).
scope_narrowed
Record a binding that kept its outer-env capture.
scope_pinned
Record a binding that still needs the scope env.
spawn_poller
Spawn the periodic-dump thread (only when enabled). Dumps every 2s so a 30s+ eval captures the high-water region. Also usable as an at-exit hook via the returned guard.