Expand description
Run mailboxes — the observability surfaces that stay process-global on purpose, and the one call that keeps them honest across a model swap.
Most model-derived state in Atlas is carried: SchedCtx, ForwardContext,
ModelLevers, OpCache. A handful of counters cannot be, because their
readers cannot be handed a carrier — /metrics answers from an HTTP
handler thread and the dashboard polls from the TUI thread, both while the
scheduler is mid-step and holding its own context. A process-global address
is what an observability surface is for.
That leaves the scoping problem: after a swap the counters would describe
two models at once. reset_for_new_run solves it from the other end —
the values stay reachable at a fixed address, but they start clean when a
run does, so a reader asking “what is the prefix-cache hit rate” gets the
rate for the model now running. Prometheus reads the reset as a counter
restart, which it already handles.
Called from AtlasCudaBackend::new, which is where a model’s GPU state
begins. That is deliberately upstream of the first kernel lookup, so the
kernel audit records only this model’s modules.
Structs§
- RunMetrics
- The process’s single run mailbox.
Functions§
- cache_
counts_ this_ run - Prefix-cache activity since the CURRENT model was loaded.
- metrics
- Read the mailbox.
- reset_
for_ new_ run - Begin a new run’s accounting. Called when a new model’s backend is built.