Commit Graph
24677 Commits
Author SHA1 Message Date
J. Nick Koston 2f57f0c90f Merge branch 'fix-lwiplock-inline-noop' into integration 2026-03-13 13:07:54 -10:00
J. Nick Koston 303c6513ee [core] Inline LwIPLock as no-op on platforms without lwIP core locking
LwIPLock was introduced for RP2040 WiFi in #14679 to prevent race
conditions between lwip callbacks and the main loop. However, on
platforms without lwIP core locking (ESP8266, LibreTiny, Zephyr,
RP2040 without WiFi), the constructor/destructor were empty stubs
in .cpp files that the compiler could not see through, generating
unnecessary function calls at every call site.

Move the no-op implementation inline into helpers.h so the compiler
can eliminate all LwIPLock overhead on these platforms. ESP32 and
RP2040+WiFi retain their out-of-line implementations with real
locking.
2026-03-13 13:07:27 -10:00
J. Nick Koston ebc4c556e3 Merge remote-tracking branch 'upstream/fix-lwiplock-inline-noop' into integration 2026-03-13 13:06:42 -10:00
J. Nick Koston e918814530 [core] Inline LwIPLock as no-op on platforms without lwIP core locking
LwIPLock was introduced for RP2040 WiFi in #14679 to prevent race
conditions between lwip callbacks and the main loop. However, on
platforms without lwIP core locking (ESP8266, LibreTiny, Zephyr,
RP2040 without WiFi), the constructor/destructor were empty stubs
in .cpp files that the compiler could not see through, generating
unnecessary function calls at every call site.

Move the no-op implementation inline into helpers.h so the compiler
can eliminate all LwIPLock overhead on these platforms. ESP32 and
RP2040+WiFi retain their out-of-line implementations with real
locking.
2026-03-13 13:02:05 -10:00
J. Nick Koston 7bb88267fe Merge branch 'entity-base-inline-accessors' into integration 2026-03-13 12:43:56 -10:00
J. Nick Koston 7709713fad Merge branch 'dev' into entity-base-inline-accessors 2026-03-13 12:39:52 -10:00
J. Nick Koston 742230e9ab [core] Inline trivial EntityBase accessors
Move get_name() and get_object_id_hash() definitions from
entity_base.cpp to entity_base.h so the compiler can inline
these trivial member accessors, eliminating call overhead at
every call site.
2026-03-13 12:38:49 -10:00
J. Nick Koston 71c94d2a6c Merge branch 'analyze-memory-call-frequency' into integration 2026-03-13 12:35:02 -10:00
J. Nick Koston 434bbde5b3 tweak 2026-03-13 12:34:31 -10:00
J. Nick Koston 95ff7fc883 Merge remote-tracking branch 'upstream/inline-calc-force-proto' into integration 2026-03-13 12:29:26 -10:00
J. Nick Koston 05990474b0 [api] Inline force-variant ProtoSize calc methods for BLE proxy hot path
Force-inline calc_uint64_force, calc_sint32_force, calc_length_force,
and calc_message_force so the varint fast path (value < 128) is
expanded at each call site instead of going through a function call.

These are the size-calculation methods used by BLE proxy messages
(BluetoothLERawAdvertisement, BluetoothGATTService/Characteristic/
Descriptor) which are called 12x per advertisement batch in the
hot path.

Benchmarked on ESP32 with 12-advertisement batches (10k iterations):
- calculate_size: 10381 -> 9718 ns/op (6.4% faster)
- Full calc+encode: 49886 -> 47599 ns/op (4.6% faster)

Flash cost: +40 bytes (ESP32 IDF), +64 bytes (ESP8266).
2026-03-13 12:18:03 -10:00
J. Nick Koston 2aeb5314c9 Merge remote-tracking branch 'upstream/analyze-memory-call-frequency' into integration 2026-03-13 11:47:24 -10:00
J. Nick Koston d54f31e9c2 [analyze-memory] Add function call frequency analysis
Add a "Top Called Functions" section to the analyze-memory report
that shows the most frequently called functions by call site count.
This helps identify inlining candidates by showing which functions
are called most often alongside their code size.

The analysis parses objdump disassembly output to count direct and
indirect call instructions across architectures (Xtensa call0/callx0,
ARM bl/blx).

Also fixes _batch_demangle_symbols to merge into the existing cache
instead of replacing it.
2026-03-13 11:43:14 -10:00
Thomas SAMTERandJ. Nick Koston 1eed1adfa0 [pid] Replace std::deque with FixedRingBuffer (#14733)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-13 11:38:45 -10:00
J. Nick Koston 516a705df0 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-13 10:38:11 -10:00
J. Nick Koston a6c08576be [sensor] Use FixedRingBuffer in SlidingWindowFilter, add window_size limit (#14736) 2026-03-13 10:17:40 -10:00
dependabot[bot]andJ. Nick Koston f41aa8b18c Bump ruff from 0.15.5 to 0.15.6 (#14774)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-13 19:35:10 +00:00
J. Nick Koston 6bdaa4c972 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-13 09:07:55 -10:00
Jonathan SwobodaandClaude Opus 4.6 6700347a48 [wifi] Fix ESP-IDF 6.0 compatibility (#14766)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 14:47:12 -04:00
Jonathan SwobodaandClaude Opus 4.6 b147830ef9 [core] Fix std::isnan conflict with picolibc on ESP-IDF 6.0 (#14768)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 14:24:39 -04:00
J. Nick Koston bd844fcd0a [template] Fix misleading 'Text value too long to save' warning (#14753) 2026-03-13 07:37:44 -10:00
J. Nick Koston 8936be628f [api] Increase log Nagle coalescing on all platforms except ESP8266 (#14752) 2026-03-13 07:37:30 -10:00
J. Nick Koston 5920fa97e4 [select] Fix -Wmaybe-uninitialized warnings on ESP8266 (#14759) 2026-03-13 09:20:50 -04:00
Kjell Braden 326769e43c [runtime_image] fix BMP parsing (#14762) 2026-03-13 09:18:42 -04:00
Thomas SAMTER 7524590bcf [const] Add CONF_CLIMATE_ID for climate component sub-entities (#14764) 2026-03-13 09:17:11 -04:00
J. Nick Koston c8dc00e76b Merge branch 'api-plaintext-varint-devirtualize' into integration 2026-03-12 22:45:41 -10:00
J. Nick Koston a29206f838 [api] Rename VARINT_MAX_ to VARINT_THRESHOLD_ for clarity
These are exclusive upper bounds (value < threshold), not inclusive
maximums. The new name avoids off-by-one confusion if reused.
2026-03-12 22:45:26 -10:00
J. Nick Koston e00f1bfd3a Merge remote-tracking branch 'upstream/select-fix-maybe-uninitialized-warning' into integration 2026-03-12 22:37:33 -10:00
J. Nick Koston a19b36e4be [select] Fix -Wmaybe-uninitialized warnings on ESP8266
Replace brace-initialization `{}` with explicit `nullopt` for
optional<size_t> returns and assignments. Older GCC on ESP8266
falsely warns about uninitialized values with `return {}`.
2026-03-12 22:26:46 -10:00
J. Nick Koston b8d47e8280 Merge branch 'api-plaintext-varint-devirtualize' into integration 2026-03-12 22:23:19 -10:00
J. Nick Koston c7af451a56 [api] Fix type_varint_len ternary for uint8_t message_type
message_type is uint8_t (max 255), which fits in at most 2 varint
bytes. Simplify the ternary to reflect this constraint. Also revert
unnecessary comment split.
2026-03-12 22:21:26 -10:00
J. Nick Koston 5c4527905c [api] Optimize plaintext varint encoding and devirtualize write_protobuf_packet
- Replace ProtoSize::varint() call for message_type with inline
  ternary using named constants, avoiding the noinline varint_slow
  call overhead in the write_protobuf_messages loop (-32 bytes on
  ESP8266 Xtensa).

- Add named varint threshold constants (VARINT_MAX_1_BYTE, etc.)
  to ProtoSize class, used by both varint() and varint_wide().

- Devirtualize write_protobuf_packet by moving it to the base class
  as a non-virtual inline method. The plaintext and noise
  implementations only differed in footer handling, which is now
  unified via a conditional resize based on frame_footer_size_.
  This eliminates one vtable slot and allows the compiler to fully
  inline the thin wrapper into callers (-192 bytes total flash on
  ESP8266).

- Include proto.h from api_frame_helper.h (no circular dependency)
  to support the inline definition, replacing the forward declaration
  of ProtoWriteBuffer.
2026-03-12 22:15:36 -10:00
J. Nick Koston 120ddded18 Merge branch 'scheduler-placement-new-move' into integration 2026-03-12 21:19:07 -10:00
J. Nick Koston 8010386614 [scheduler] Use placement-new for std::function move in set_timer_common_
GCC's std::function::operator=(function&&) implements move-assignment as
a swap dance: construct temporary, swap with *this, destroy temporary.
This generates two std::swap<_Any_data> calls plus a destructor even
when the target is known to be empty.

Since scheduler items returned from the pool or freshly allocated always
have an empty callback, we can use explicit destroy + placement
move-construct to bypass the swap overhead.

Measured savings in set_timer_common_:
- ESP8266 (Xtensa LX106): 473 → 421 bytes (-52 B, -11%)
- ESP32-S3 (Xtensa LX7): 412 → 376 bytes (-36 B, -9%)
2026-03-12 21:17:22 -10:00
J. Nick Koston 1337d852da Merge remote-tracking branch 'origin/inline-mutex-single-threaded' into integration 2026-03-12 21:01:52 -10:00
J. Nick Koston 0d503db403 [core] Inline Mutex/LockGuard on single-threaded platforms
When USE_ESP8266 or USE_RP2040 is defined, provide a fully inline
no-op Mutex class in the header. This allows the compiler to
eliminate all lock/unlock call overhead instead of generating
calls to empty function stubs.
2026-03-12 20:56:59 -10:00
Michael Kerscher 15ec46abfe [vbus] add DeltaSol CS4 (Citrin Solar 1.3) (#12477) 2026-03-12 22:31:16 -07:00
J. Nick Koston 4f76473f2a Merge branch 'scheduler-interval-offset-integer-math' into integration 2026-03-12 19:30:51 -10:00
J. Nick Koston 74e9bd8d7c [scheduler] Use integer math for interval offset calculation
Replace floating-point random offset calculation with integer
multiply-and-shift, eliminating soft-float calls on ESP8266 and
FPU instructions on ESP32/RP2040.
2026-03-12 19:29:11 -10:00
J. Nick Koston b074aebd6d Merge branch 'fix-template-text-save-warning' into integration 2026-03-12 19:21:04 -10:00
J. Nick Koston 30c010a47d Merge branch 'rp2040-boards-ci-check' into integration 2026-03-12 19:20:59 -10:00
J. Nick Koston a4d3a908e5 [rp2040] Add CI check for boards.py freshness
Add generate-rp2040-boards.py script that clones the arduino-pico
repository at the recommended framework version and regenerates
boards.py, matching the existing ESP32 board generation CI check
pattern.

This ensures boards.py stays in sync when the arduino-pico
framework version is updated.

Follow-up to #14528.
2026-03-12 19:19:43 -10:00
J. Nick Koston b81ef4697f [template] Fix misleading 'Text value too long to save' warning
TextSaver::save() returned false for both unchanged values and
values that are too long, causing a misleading warning on every
duplicate save. Return true early when the value hasn't changed.

Add integration test for template text save/restore persistence.
2026-03-12 18:05:44 -10:00
J. Nick Koston 8c0ef135aa Merge branch 'increase-log-nagle-count' into integration 2026-03-12 17:05:41 -10:00
J. Nick Koston 17c833f891 Fix stale comment referencing hardcoded log count 2026-03-12 16:58:53 -10:00
J. Nick Koston ccb9b66dd3 Merge branch 'increase-log-nagle-count' into integration 2026-03-12 16:55:36 -10:00
J. Nick Koston c3fee4a211 Include LibreTiny in LOG_NAGLE_COUNT=3
LibreTiny's TCP_SND_BUF is 4×MSS (5840 bytes), matching ESP32's
default. Only ESP8266 at 2×MSS needs the conservative count=2.
2026-03-12 16:54:03 -10:00
J. Nick Koston c04335d21d [api] Increase log Nagle coalescing on ESP32 and RP2040
Increase LOG_NAGLE_COUNT from 2 to 3 on ESP32 and RP2040, which have
larger TCP send buffers (64KB and 11.7KB respectively). This coalesces
4 log messages per Nagle cycle instead of 3, reducing the number of
individual write() calls and significantly reducing EWOULDBLOCK hits
on the log subscriber connection.

Tested on ESP32 and RP2040: buffered writes dropped from ~15% to near
zero with this change. ESP8266 and LibreTiny remain at LOG_NAGLE_COUNT=2
due to tighter buffer constraints.
2026-03-12 16:48:07 -10:00
J. Nick Koston 98379b70e9 Merge branch 'cache-errno-local' into integration 2026-03-12 15:58:32 -10:00
J. Nick KostonandClaude Opus 4.6 4e5d1cae8d Cache errno into local variable to eliminate duplicate __errno() calls
On embedded targets (ESP32, RP2040, ESP8266), errno expands to
(*__errno()) - a function call returning a pointer to thread-local
storage. The compiler cannot optimize away repeated accesses since
errno is treated as volatile. Cache it once into a const int local
to avoid redundant calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 15:57:16 -10:00