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.