mirror of
https://github.com/esphome/esphome.git
synced 2026-09-02 02:56:01 +00:00
Merge remote-tracking branch 'upstream/decouple_scheduler_loop_cadence' into integration
This commit is contained in:
@@ -42,9 +42,9 @@ class RuntimeStatsCollector {
|
||||
// before_us = time spent in Phase A (scheduler tick) excluding time
|
||||
// already attributed to per-component stats.
|
||||
// tail_us = time spent in after_component_phase_ + the trailing record/stats
|
||||
// prefix. On Phase A-only ticks (component phase gated) this
|
||||
// is just the small trailing prefix between loop_before_end_us
|
||||
// and loop_now_us — non-zero but typically a few µs.
|
||||
// prefix. Only meaningful on component-phase ticks; reported
|
||||
// as 0 on Phase A-only ticks (no component phase ran, so any
|
||||
// overhead between Phase A and stats belongs to "residual").
|
||||
// Residual overhead at log time = active − Σ(component) − before − tail,
|
||||
// which captures per-iteration inter-component bookkeeping (set_current_component,
|
||||
// WarnIfComponentBlockingGuard construction/destruction, feed_wdt_with_time calls,
|
||||
|
||||
@@ -650,10 +650,10 @@ inline void ESPHOME_ALWAYS_INLINE __attribute__((optimize("O2"))) Application::l
|
||||
#ifdef USE_RUNTIME_STATS
|
||||
uint32_t loop_before_end_us = micros();
|
||||
uint64_t loop_before_scheduled_us = ComponentRuntimeStats::global_recorded_us - loop_recorded_snap;
|
||||
// Default tail_start to end-of-before so tail_us on Phase A-only ticks
|
||||
// captures only the small gate-check + record_loop_active prefix between
|
||||
// here and the loop_now_us sample below (not strictly zero, but tiny).
|
||||
uint32_t loop_tail_start_us = loop_before_end_us;
|
||||
// Only meaningful when do_component_phase is true; initialized to 0 so the
|
||||
// tail bucket receives 0 on Phase A-only ticks (no component tail happened,
|
||||
// the gate-check / stats-prefix overhead belongs to "residual", not "tail").
|
||||
uint32_t loop_tail_start_us = 0;
|
||||
#endif
|
||||
|
||||
// Gate the component phase on loop_interval_, an active high-frequency
|
||||
@@ -712,8 +712,10 @@ inline void ESPHOME_ALWAYS_INLINE __attribute__((optimize("O2"))) Application::l
|
||||
uint32_t loop_before_overhead_us = loop_before_wall_us > loop_before_scheduled_us
|
||||
? loop_before_wall_us - static_cast<uint32_t>(loop_before_scheduled_us)
|
||||
: 0;
|
||||
global_runtime_stats->record_loop_active(loop_now_us - loop_active_start_us, loop_before_overhead_us,
|
||||
loop_now_us - loop_tail_start_us);
|
||||
// tail_us is only defined when Phase B ran; 0 on Phase A-only ticks so the
|
||||
// stats bucket keeps its "component-phase trailing overhead" meaning.
|
||||
uint32_t loop_tail_us = do_component_phase ? (loop_now_us - loop_tail_start_us) : 0;
|
||||
global_runtime_stats->record_loop_active(loop_now_us - loop_active_start_us, loop_before_overhead_us, loop_tail_us);
|
||||
global_runtime_stats->process_pending_stats(now);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user