Expand description
Process-wide liveness monitor with per-thread scope stacks.
Each heartbeat (≈once/minute) reports three things a user watching a long compute log actually needs:
- The currently-active operation — the label of the longest-running
instrumented scope on any thread and how long it has been running, so a
multi-minute silent window shows
active="BMS coord_corrections …" for 142sinstead of nothing. - A TRUE busy signal — process-wide CPU utilization in cores-busy,
computed from
/proc/self/stat(utime+stime) deltas between heartbeats. A rayon fan-out saturating ~70 cores reads ascpu=68.3 cores, where the oldactive_threadscounter only ever saw the handful of threads inside an instrumentedtrack_scope(rayon workers are not) and so reported a misleading0. - Progress — when a long scope registers a progress counter (via
track_scope_with_progress) the heartbeat surfacesprogress=a/b (X%).
Structs§
- Process
Scope Guard - Scope
Progress - A shared progress counter a long-running scope can expose to the heartbeat.
Functions§
- start
- Start the background process monitor thread if it is not already running.
- track_
scope - track_
scope_ with_ progress - Open a tracked scope that also exposes a live progress counter to the
heartbeat. The returned
ScopeProgressis cheap to clone into worker closures; bump it as the loop advances and the heartbeat will surfaceprogress=a/b (X%)on the active-scope line. The scope closes when the returned guard is dropped, exactly liketrack_scope.