Skip to main content

Module process_monitor

Module process_monitor 

Source
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:

  1. 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 142s instead of nothing.
  2. 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 as cpu=68.3 cores, where the old active_threads counter only ever saw the handful of threads inside an instrumented track_scope (rayon workers are not) and so reported a misleading 0.
  3. Progress — when a long scope registers a progress counter (via track_scope_with_progress) the heartbeat surfaces progress=a/b (X%).

Structs§

ProcessScopeGuard
ScopeProgress
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 ScopeProgress is cheap to clone into worker closures; bump it as the loop advances and the heartbeat will surface progress=a/b (X%) on the active-scope line. The scope closes when the returned guard is dropped, exactly like track_scope.