mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 16:38:43 +00:00
d15a9597d720f5bdffaccc9ff33dbb00007b2781
Adds three debug atomic counters around the pre-sleep socket scan in
yield_with_select_():
- fast_select_scan_total_ every scan
- fast_select_scan_found_data_ scan saw a socket with pending data
- fast_select_scan_load_bearing_ scan saw pending data AND the task
notification counter was 0 at scan start
Only the third counter represents a case the scan actually rescues: had
the scan not been present, ulTaskNotifyTake would have stalled up to
loop_interval ms. The other two cases are harmless (Take would have
returned immediately).
The notification value is peeked with ulTaskNotifyValueClear(nullptr, 0)
(a pure read — zero bits cleared, state untouched) BEFORE the scan loop.
Peeking before the scan makes the measurement TOCTOU-free: the value we
compare against is the value at the moment Take would have been called,
exactly the counterfactual we want to measure. Peeking after has_data
would race with the lwip callback firing during the scan.
Stats are logged via ESP_LOGD every 30s from Application::loop().
Background: PR #14475 removed the scan and was reverted because the API
connection's MAX_MESSAGES_PER_LOOP=5 throttle violated the ready()
contract (see #15589, #15590). With #15590 the contract is now
documented and honored, so the scan may now be removable. This PR
gathers evidence; if load_bearing stays 0 across ESP32/LibreTiny under
real workloads, the scan and these counters will be removed in a
follow-up.
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%
