Replace the shared noinline notify() dispatch loop with direct
virtual calls in each notify method. This eliminates two levels
of indirection (noinline function call + function pointer) from
every entity state publish while adding only ~20 bytes of flash
per entity type for the duplicated loop.
IDF 6 uses picolibc instead of newlib. In newlib, vfprintf was a thin
36-byte trampoline to _vfprintf_r, so wrapping printf/vprintf/fprintf
was sufficient to dead-code eliminate _vfprintf_r. In picolibc, vfprintf
IS the heavy implementation (~2.8 KB) and is referenced directly by SDK
components. Add vfprintf to the wrap list to intercept those references.
Benchmarking in #15034 showed that esp_log_printf and vsnprintf_chk
dominate sensor publish time (95%+ of internal_send_state_to_frontend).
At the default DEBUG log level, every state change generates log output
that overwhelms the log output making it hard to actually debug and
wastes significant CPU time on string formatting.
Move all entity state publish (>>) and setting logs from ESP_LOGD to
ESP_LOGV across all base entity types: sensor, binary_sensor, switch,
number, text_sensor, select, text, event, lock, cover, valve, climate,
fan, light, media_player, alarm_control_panel, datetime, update, and
water_heater.
- Remove dead DEFAULT_SLOT_COUNT constant from host header
- Fix misleading BSS comments (Logger is heap-allocated via new_Pvariable)
- Add comment explaining Zephyr BUF_WORD_COUNT formula
Follow-up to #15071 which moved the TaskLogBuffer allocation into the
Logger constructor to fix a race condition where another task could log
before the buffer was initialized.
This takes that fix further by eliminating the heap allocation entirely.
The buffer size is a codegen constant, so we emit it as a define
(ESPHOME_TASK_LOG_BUFFER_SIZE) and use it to size member arrays directly.
The TaskLogBuffer becomes a direct member of Logger rather than a
heap-allocated pointer, placing the entire buffer in BSS.
Changes per platform:
- ESP32: storage_ from RAMAllocator heap to member array
- Host: slots_ from unique_ptr<LogMessage[]> to member array
- LibreTiny: storage_ from RAMAllocator heap to member array
- Zephyr: mpsc buf from new uint32_t[] to member array
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
The API component calls status_set_warning() without a message when no
client is connected and reboot timeout is enabled. This results in a
confusing log line: "api set Warning flag: unspecified"
Replace with a descriptive message so users see:
"api set Warning flag: waiting for client connection"
Closes https://github.com/esphome/esphome/issues/15140