mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
[core] Raise ESP32 WDT feed interval to 1000ms
Mirrors the bk72xx override: the ESP32 task WDT default timeout is 5s (CONFIG_ESP_TASK_WDT_TIMEOUT_S), so feeding every 1000ms keeps a ~5x safety margin while cutting per-iteration feed overhead substantially. esp_task_wdt_reset() takes a spinlock and walks the WDT task list, so every call costs tens of microseconds. At the normal ~62 Hz main loop the old 300ms cadence produced ~200 hits per 60s period; 1000ms cuts that to ~60 hits per 60s (-70%). Measured on a live ESP32 IDF build (gatetrigger.yaml) via runtime_stats: wdt bucket dropped from 2.24 us/iter to 1.56 us/iter - about 2.5 ms saved per 60s window, or ~0.7us/iter average. Component-level feeds inside component loop() and scheduler items are unaffected; they continue to call arch_feed_wdt after every operation, so any operation that exceeds this rate-limit triggers a real feed naturally. The rate-limit only applies to the outer guard in Application::loop() that fires when nothing else fed recently.
This commit is contained in:
@@ -216,7 +216,7 @@ class Application {
|
||||
/// loops and scheduler items still feed after every op, so any op exceeding
|
||||
/// this threshold triggers a real feed naturally.
|
||||
/// Safety margins vs. platform watchdog timeouts:
|
||||
/// - ESP32 task WDT default (5 s): ~16x
|
||||
/// - ESP32 task WDT default (5 s): ~5x <-- platform override below
|
||||
/// - ESP8266 soft WDT (~1.6 s): ~5x <-- floor case; any future change
|
||||
/// must keep comfortable margin here
|
||||
/// - ESP8266 HW WDT (~6 s): ~20x
|
||||
@@ -226,6 +226,14 @@ class Application {
|
||||
// sets HW WDT to 10s; 2000ms keeps ~5x margin. See wdt_ctrl WCMD_RELOAD_PERIOD:
|
||||
// https://github.com/libretiny-eu/framework-beken-bdk/blob/44800e7451ea30fbcbd3bb6e905315de59349fee/beken378/driver/wdt/wdt.c#L75-L87
|
||||
static constexpr uint32_t WDT_FEED_INTERVAL_MS = 2000;
|
||||
#elif defined(USE_ESP32)
|
||||
// ESP32 task WDT default timeout is 5 s (CONFIG_ESP_TASK_WDT_TIMEOUT_S).
|
||||
// 1000ms keeps a comfortable ~5x margin — matching the bk72xx safety factor —
|
||||
// while cutting the per-hit feed overhead to ~1/3 of the old 300ms cadence.
|
||||
// esp_task_wdt_reset() takes a spinlock and walks the WDT task list, so
|
||||
// each call costs tens of microseconds; feeding less often materially
|
||||
// reduces the main-loop's wdt bucket.
|
||||
static constexpr uint32_t WDT_FEED_INTERVAL_MS = 1000;
|
||||
#else
|
||||
static constexpr uint32_t WDT_FEED_INTERVAL_MS = 300;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user