pub struct DriveLoopProfiler { /* private fields */ }Expand description
Owns every drive-loop phase/rate ring drive_runtime_until_shutdown
writes into once per iteration. Lives on NodeShared behind a
std::sync::Mutex that is only ever locked for a push and dropped
before the next .await – never held across one, so it does not need
tokio::sync::Mutex.
Implementations§
Source§impl DriveLoopProfiler
impl DriveLoopProfiler
Sourcepub fn record_runtime_tick(&mut self, elapsed: Duration)
pub fn record_runtime_tick(&mut self, elapsed: Duration)
runtime.tick().await – the whole native-runtime tick, whose own
six internal phases are separately timed by
gate4agent_runtime_native::tick_profile.
Sourcepub fn record_event_drain(&mut self, elapsed: Duration)
pub fn record_event_drain(&mut self, elapsed: Duration)
Draining events.try_recv() in a loop and republishing each control
event – includes the per-event managed-record export lookup, but
not the detached tokio::spawn’d export task itself.
Sourcepub fn record_publish_terminal_frames(&mut self, elapsed: Duration)
pub fn record_publish_terminal_frames(&mut self, elapsed: Duration)
shared.publish_terminal_frames() – snapshotting sessions, then
diffing and broadcasting any advanced terminal frame.
Sourcepub fn record_remainder(&mut self, elapsed: Duration)
pub fn record_remainder(&mut self, elapsed: Duration)
Whatever is left of the iteration after the three phases above and
before the trailing sleep – today that is the shutdown-progress
check (a no-op outside shutdown) plus this profiler’s own
bookkeeping.
Sourcepub fn note_iteration(&mut self, now: Instant)
pub fn note_iteration(&mut self, now: Instant)
Call exactly once per drive-loop iteration, regardless of what that
iteration did – rolls the current one-second bucket into
iterations_per_sec the moment a full second has elapsed, then
counts this iteration toward the (possibly just-rolled) bucket.
Rolling before counting means an iteration observed after a second
boundary is credited to the new second, not folded into the one
being flushed.
Bounded to SAMPLE_WINDOW catch-up rolls for the same reason as
hatchery-tui’s tick_second: a long idle gap (e.g. the process
paused under a debugger) must resync rather than spin backfilling a
zero-sample per elapsed second.