From 7000b865ce92e780005cfd9d0660bbb836bee927 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Apr 2026 17:51:01 -1000 Subject: [PATCH] [scheduler] Force-inline process_defer_queue_() fast path process_defer_queue_() follows the same fast-path/slow-path pattern as cleanup_() and process_to_add(): an atomic load + branch that skips to the slow path only when work is pending. GCC currently inlines it, but past experience shows the compiler can change its mind when surrounding code changes. Use ESPHOME_ALWAYS_INLINE to lock in the intended behavior. --- esphome/core/scheduler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index 43a3ec7049..ea6c2a675e 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -407,7 +407,7 @@ class Scheduler { // Process defer queue for FIFO execution of deferred items. // IMPORTANT: This method should only be called from the main thread (loop task). // Inlined: the fast path (nothing deferred) is just an atomic load check. - inline void HOT process_defer_queue_(uint32_t &now) { + inline void ESPHOME_ALWAYS_INLINE HOT process_defer_queue_(uint32_t &now) { // Fast path: nothing to process, avoid lock entirely. // Worst case is a one-loop-iteration delay before newly deferred items are processed. if (this->defer_empty_())