Skip to main content

Module drive_loop_profile

Module drive_loop_profile 

Source
Expand description

Fixed-window latency/rate profiling for drive_runtime_until_shutdown’s own per-iteration phases – the top half of the answer to “the node burns CPU with zero live PTY sessions and there is no number for where.”

gate4agent_runtime_native::tick_profile already owns the six phases inside NativeRuntime::tick; this module covers the three things that surround that call in the drive loop itself (draining control events, publishing terminal frames, and whatever is left of the iteration before the trailing sleep), plus the loop’s own actual iteration rate. It reuses that other module’s RingStats/Distribution/ duration_micros rather than redefining them: both profilers need the identical “last 256 samples, p50/p95/max, no allocation after construction” contract, and gate4agent-node already depends on gate4agent-runtime-native for gate4agent_runtime_native::NativeRuntime itself.

Structs§

DriveLoopProfileSnapshot
One snapshot of the drive loop’s own phase/rate readings – what GET /metrics reports alongside NativeRuntime’s own gate4agent_runtime_native::tick_profile::TickProfileSnapshot.
DriveLoopProfiler
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.