Commit Graph

444 Commits

Author SHA1 Message Date
J. Nick Koston 2a379490e8 Merge remote-tracking branch 'upstream/remove-noinline-encode-fixed32' into integration 2026-03-20 23:57:37 -10:00
J. Nick Koston 225c770b1b [api] Use write_tag_and_fixed32 and extract calculate_tag helper
- Combine tag byte + fixed32 value into single write_tag_and_fixed32()
  method: pos[0] = tag, memcpy(pos+1, &value, 4), pos += 5
- Extract calculate_tag() from duplicated computation in
  calculate_field_id_size() and encode_content
2026-03-20 23:45:23 -10:00
J. Nick Koston 21725983fd [api] Emit raw tag+value writes for force=true fixed32 fields
Instead of ALWAYS_INLINE on encode_field_raw (which bloated all
callers), have the code generator precompute the tag byte and emit
write_raw_byte(tag) + write_fixed32_raw(value) directly.

This gives the same tight codegen (single byte store + memcpy) for
key fields without inflating encode_bool/encode_uint32/etc.

+108 bytes flash vs baseline, -48 bytes vs the ALWAYS_INLINE approach.
2026-03-20 23:28:19 -10:00
J. Nick Koston 7c1b30f37f Merge remote-tracking branch 'upstream/devirtualize-api-dispatch' into integration 2026-03-20 21:31:54 -10:00
J. Nick Koston 1d191d2461 [api] Fix review comments and add USE_API guards
- Update comments to reflect that ProtoService methods moved to
  APIConnection, not APIServerConnectionBase
- Fix comment referring to read_message as "override"
- Wrap #include "api_connection.h" and read_message_ implementation
  in #ifdef USE_API guards
2026-03-20 21:29:42 -10:00
J. Nick Koston 7d8eba85c6 Merge remote-tracking branch 'upstream/devirtualize-api-dispatch' into integration 2026-03-20 21:21:56 -10:00
J. Nick Koston 20d3e7c13a [api] Remove virtual destructor and rename read_message to read_message_
The virtual destructor was unnecessary since APIConnection is only
stored as unique_ptr<APIConnection>, never via a base class pointer.
Removing it eliminates the vtable entirely.

Rename read_message to read_message_ per clang-tidy naming convention
for protected methods.
2026-03-20 21:21:09 -10:00
J. Nick Koston e1f37675da Merge remote-tracking branch 'upstream/devirtualize-api-dispatch' into integration 2026-03-20 21:15:06 -10:00
J. Nick Koston 2067053adb [api] Remove ProtoService base class
ProtoService was an abstract interface with 6 pure virtual methods,
but APIConnection was the only concrete implementation. Move all
functionality directly into APIConnection and remove the unnecessary
virtual dispatch and vtable overhead.
2026-03-20 21:14:45 -10:00
J. Nick Koston 77d2e378e2 Merge remote-tracking branch 'upstream/devirtualize-api-dispatch' into integration 2026-03-20 21:06:22 -10:00
J. Nick Koston 391ad05d45 [api] Devirtualize API command dispatch
Move read_message() from APIServerConnectionBase into APIConnection
and drop the virtual keyword from all 64 on_* handler declarations.

Since APIConnection is final and the only subclass, the virtual
dispatch was unnecessary. With read_message and the on_* handlers
in the same class, the compiler can devirtualize the calls and
inline small handlers directly into the switch cases.
2026-03-20 20:58:54 -10:00
J. Nick Koston 7b6312a819 Merge remote-tracking branch 'upstream/libsodium-enable-weak-symbols' into integration 2026-03-20 18:02:29 -10:00
J. Nick Koston 1920d8a887 [benchmark] Add noise encryption benchmarks (#15037) 2026-03-20 17:35:17 -10:00
J. Nick Koston 533301c909 Merge remote-tracking branch 'upstream/rp2040-lwip-tune' into integration 2026-03-19 19:57:09 -10:00
J. Nick Koston 5da2073d45 Merge branch 'dev' into rp2040-lwip-tune 2026-03-19 16:22:33 -10:00
J. Nick Koston 151f71e033 [ci] Add libretiny and zephyr to memory impact platform filter (#14985) 2026-03-19 14:12:15 -10:00
J. Nick Koston e91e1edbe8 Merge remote-tracking branch 'origin/fix-memory-impact-platform-filter' into integration 2026-03-19 13:38:59 -10:00
J. Nick Koston b5a1faac68 [ci] Add libretiny and zephyr to memory impact platform filter
Add libretiny and zephyr to PLATFORM_SPECIFIC_COMPONENTS so they
are correctly filtered out when an incompatible platform is selected
for memory impact analysis. Previously, libretiny was missing from
the set, causing it to be included in esp32-idf builds and producing
a misleading comment showing both platforms.
2026-03-19 13:32:40 -10:00
J. Nick Koston 8a28e40a9e Merge remote-tracking branch 'upstream/api-dump-progmem' into integration 2026-03-19 12:41:04 -10:00
J. Nick Koston 78b10a24b0 Move message_name() strings to flash via LOG_STR
message_name() returned bare string literals that stayed in RAM on
ESP8266. Change return type to const LogString * and wrap with LOG_STR()
so they are stored in flash. Update log_send_message_ to use
LOG_STR_ARG() accordingly.

Also fix clang-tidy: rename append_p_esp8266_ to append_p_esp8266,
add NOLINTNEXTLINE for conditionally-unused dump_field overloads.
2026-03-19 12:40:38 -10:00
J. Nick Koston 68340875dd Merge remote-tracking branch 'origin/api-dump-progmem' into integration 2026-03-19 12:38:52 -10:00
J. Nick Koston fb07c708b5 Move message_name() strings to flash via LOG_STR
message_name() returned bare string literals that stayed in RAM on
ESP8266. Change return type to const LogString * and wrap with LOG_STR()
so they are stored in flash. Update log_send_message_ to use
LOG_STR_ARG() accordingly.

Also fix clang-tidy: rename append_p_esp8266_ to append_p_esp8266,
add NOLINTNEXTLINE for conditionally-unused dump_field overloads.
2026-03-19 12:35:29 -10:00
J. Nick Koston 96616e3ccb Merge remote-tracking branch 'upstream/ci-ban-std-bind' into integration 2026-03-19 12:30:24 -10:00
J. Nick Koston 5e64e3a3d4 [api] Store dump strings in PROGMEM to save RAM on ESP8266
All string literals in api_pb2_dump.cpp (field names, message names,
enum value names) were stored in rodata which occupies RAM on ESP8266.
This meant every API protobuf change appeared as a RAM increase in CI
when using very_verbose logging.

Add append_p() to DumpBuffer for PROGMEM-safe string reading and update
the code generator to wrap all dump string literals with ESPHOME_PSTR().
On non-ESP8266 platforms, these are no-ops with zero overhead.
2026-03-19 12:24:10 -10:00
J. Nick Koston b3281e0c2e Address review: add word boundary and soften SBO wording 2026-03-19 01:32:51 -10:00
J. Nick Koston df71e4db17 [ci] Ban std::bind in new C++ code
Lambdas are clearer, produce smaller binaries, and fit within the
std::function small-buffer optimization (avoiding heap allocation).
2026-03-19 01:22:36 -10:00
Javier Peletier 0a3393bed3 [core] Disable LeakSanitizer in C++ unit tests (#14712) 2026-03-18 23:13:36 -10:00
Javier Peletier 0c5f055d45 [core] cpp tests: Allow customizing code generation during tests (#14681)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-18 00:16:01 +00:00
J. Nick Koston 1670f04a87 [core] Add CodSpeed C++ benchmarks for protobuf, main loop, and helpers (#14878) 2026-03-17 12:29:38 -10:00
J. Nick Koston b3210de374 [core] Extract shared C++ build helpers from cpp_unit_test.py (#14883) 2026-03-17 08:53:36 -10:00
Diorcet Yann 73ca0ff106 [core] Small improvements (#14884) 2026-03-17 09:22:31 -04:00
J. Nick Koston ecfb302c72 [rp2040] Tune oversized lwIP defaults for ESPHome
Arduino-pico's lwIP defaults are tuned for general-purpose networking,
not IoT devices. This generates a custom lwipopts.h overlay using
#include_next to chain to the framework's original, then override
specific settings to match ESP32's lwIP tuning.

Saves ~12KB static RAM by reducing oversized buffer and pool defaults.

Tested on Pico W (CYW43 WiFi) and Wiznet W5500 (Ethernet) with
500-iteration concurrent connect/disconnect stress tests.
2026-03-15 15:47:19 -10:00
Jonathan Swoboda 18a082de30 [ci] Support URL and version extras in generate-esp32-boards.py (#14828)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-15 14:58:01 -04:00
J. Nick Koston 5e3c44d48f [rp2040] Add CI check for boards.py freshness (#14754)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-13 13:28:55 -10:00
J. Nick Koston 56f7b3e61b [ci] Only run integration tests for changed components (#14776) 2026-03-13 13:20:35 -10:00
J. Nick Koston 05d285ba86 [api] Fix heap-buffer-overflow in protobuf message dump for StringRef (#14721) 2026-03-12 07:16:53 -10:00
Adam DeMuri 4df3d3554e Enable the address and behavior sanitizers for C++ component unit tests (#13490) 2026-03-10 19:44:05 -10:00
J. Nick Koston 4d2ef09a29 [log] Detect early log calls before logger init and optimize hot path (#14538) 2026-03-10 09:12:10 -10:00
J. Nick Koston 6e468936ec [api] Inline ProtoVarInt::parse fast path and return consumed in struct (#14638)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 09:10:55 -10:00
Javier Peletier e82f0f4432 [cpptests] support testing platform components (#13075)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-10 02:41:02 +00:00
J. Nick Koston d6ce5dda81 [ci] Skip YAML anchor keys in integration fixture component extraction (#14670) 2026-03-09 22:54:56 +00:00
Clyde Stubbs f3ca86b670 [ci-custom] Directions on constant hoisting (#14637) 2026-03-08 23:48:03 -04:00
J. Nick Koston 088a8a4338 [ci] Match symbols with changed signatures in memory impact analysis (#14600)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 17:23:58 -10:00
tomaszduda23 e4b89a69d4 [nrf52, ota] ble and serial OTA based on mcumgr (#11932)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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>
2026-03-07 20:32:20 -10:00
J. Nick Koston be6c3c52ac [api] Add force proto field option to skip zero checks on hot path (#14610)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 18:59:13 -10:00
J. Nick Koston 77f2c371b2 [api] Single-pass protobuf encode for BLE proxy advertisements (#14575) 2026-03-07 07:26:34 -10:00
J. Nick Koston 42dbb51022 [api] Devirtualize protobuf encode/calculate_size (#14449)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-06 19:03:54 +00:00
Kevin Ahrendt 5c5ea8824e [audio_file] New component for embedding files into firmware (#14434)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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@koston.org>
2026-03-05 09:51:08 -10:00
Clyde Stubbs f5c37bf486 [packet_transport] Minimise heap allocations (#14482) 2026-03-05 14:24:01 +11:00
J. Nick Koston 78602ccacb [ci] Add lint check to prevent powf in core and base entity platforms (#14126) 2026-03-03 07:03:50 -10:00