mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 12:35:25 +00:00
scheduler-memw-outlined
Fold the to_remove_empty check, cleanup_slow_path_ call, and MAX_LOGICALLY_DELETED_ITEMS threshold check into a single hot-path branch + cold outlined helper. Before this change, the cleanup block in Scheduler::call compiled to two independent memw + l32i sequences (one for to_remove_empty_() inside cleanup_(), one for the separate to_remove_count_() check) because GCC cannot CSE across the memw barriers that std::atomic<uint32_t>::load emits on Xtensa. A previous attempt at collapsing these into a single inline branch (#15985) had the right assembly for the memw count but grew Scheduler::call by a handful of bytes and rearranged the control flow enough to nudge sched up ~0.5 us/iter on gatetrigger in practice. This version goes further: cleanup_slow_combined_ is annotated noinline + cold so the entire slow path (both reads, both calls) is pulled out of Scheduler::call entirely. The hot path becomes: memw; l32i a8, [to_remove_]; beqz skip call8 cleanup_slow_combined_ ; unlikely, cold and Scheduler::call's body shrinks 344 B -> 332 B (-12 B, below the dev baseline). Adjacent code (feed_wdt_slow_, etc.) stays in the same flash region, avoiding the cache-layout side-effects that made earlier attempts a net loss on busier configs. The [[unlikely]] attribute on the branch plus the cold attribute on the helper give the compiler permission to keep the skip path straight and push the call out-of-line.
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
393 MiB
Languages
C++
60.7%
Python
38.9%
C
0.3%
