Commit Graph
27352 Commits
Author SHA1 Message Date
J. Nick Koston 34c617f046 Merge branch 'proto-speed-log-response' into integration 2026-04-12 22:45:34 -10:00
J. Nick Koston 4bcf3b9661 fix existing bug 2026-04-12 22:44:02 -10:00
J. Nick Koston c5927fff49 Merge branch 'dev' into proto-speed-log-response 2026-04-12 22:14:24 -10:00
dependabot[bot] 6db787d5e4 Bump aioesphomeapi from 44.14.0 to 44.15.0 (#15699)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-13 08:12:57 +00:00
J. Nick Koston 450d753184 Merge branch 'dev' into proto-speed-log-response 2026-04-12 21:52:43 -10:00
J. Nick Koston b4982b9bff Merge remote-tracking branch 'upstream/proto-speed-log-response' into integration 2026-04-12 21:50:41 -10:00
J. Nick Kostonandpre-commit-ci-lite[bot] 5b4385a084 [api] Add speed_optimized proto option for hot encode paths (#15691)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-04-13 07:42:31 +00:00
pre-commit-ci-lite[bot] 2a0e39901e [pre-commit.ci lite] apply automatic fixes 2026-04-13 07:22:54 +00:00
J. Nick Koston 1ccf72dd41 [api] Add speed_optimized to SubscribeLogsResponse
Mark SubscribeLogsResponse with (speed_optimized) = true so its
encode() and calculate_size() are compiled with -O2. Log messages
are among the most frequent messages sent over the API, especially
during debug sessions.
2026-04-12 21:20:59 -10:00
J. Nick Koston 58326bcd56 Merge branch 'dev' into proto-speed-optimized-v2 2026-04-12 21:07:02 -10:00
J. Nick Koston 4f69c3b850 [benchmark] Add SubscribeLogsResponse encode benchmarks (#15696) 2026-04-13 02:03:53 -05:00
J. Nick Koston bccd0375fe Merge branch 'dev' into proto-speed-optimized-v2 2026-04-12 20:42:04 -10:00
J. Nick Koston c62a75ee17 [benchmark] Use -Os to match firmware optimization level (#15688) 2026-04-13 01:40:33 -05:00
J. Nick Koston 5d864c3491 Merge branch 'app-loop-optimize-speed' into integration 2026-04-12 20:31:23 -10:00
J. Nick Koston 1703602c0f Merge branch 'proto-speed-optimized-v2' into integration 2026-04-12 20:30:34 -10:00
J. Nick Koston 6c115e4692 Merge branch 'benchmark-use-os-optimization' into proto-speed-optimized-v2 2026-04-12 20:24:51 -10:00
J. Nick Koston 494f11ce77 Merge branch 'dev' into benchmark-use-os-optimization 2026-04-12 20:24:33 -10:00
dependabot[bot] d4e9c62d92 Bump aioesphomeapi from 44.13.3 to 44.14.0 (#15695)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-13 06:23:49 +00:00
pre-commit-ci-lite[bot] a463e25aa1 [pre-commit.ci lite] apply automatic fixes 2026-04-13 06:23:08 +00:00
J. Nick Koston 603d5a2b54 Fix clang-tidy NOLINT for optimize(O2) in generated protobuf code 2026-04-12 20:21:43 -10:00
J. Nick Koston 3e9f464a2c Fix clang-tidy and test for optimize(O2) attribute 2026-04-12 20:21:11 -10:00
J. Nick Koston 9a022baa06 [core] Optimize main loop with -O2
Add __attribute__((optimize("O2"))) to the main loop functions
(loop_task on ESP32, codegen loop() on other platforms) so GCC
inlines scheduler helpers and loop bookkeeping more aggressively.

Under -Os, GCC outlines small functions (Scheduler::call helpers,
millis conversions, etc.) that are called every loop iteration.
With -O2, these get inlined into the loop body, reducing call
overhead on the hottest code path in the firmware.

ESP32: loop_task grows from 303 to 416 bytes (+113 bytes).
ESP8266: no change (already fully inlined via ESPHOME_ALWAYS_INLINE).
2026-04-12 20:06:34 -10:00
J. Nick Koston 830af94b2c Merge branch 'app-loop-optimize-speed' into integration 2026-04-12 19:57:45 -10:00
J. Nick Koston 0436e5bd86 [core] Optimize main loop with -O2
Add __attribute__((optimize("O2"))) to the main loop functions
(loop_task on ESP32, codegen loop() on other platforms) so GCC
inlines scheduler helpers and loop bookkeeping more aggressively.

Under -Os, GCC outlines small functions (Scheduler::call helpers,
millis conversions, etc.) that are called every loop iteration.
With -O2, these get inlined into the loop body, reducing call
overhead on the hottest code path in the firmware.

ESP32: loop_task grows from 303 to 416 bytes (+113 bytes).
ESP8266: no change (already fully inlined via ESPHOME_ALWAYS_INLINE).
2026-04-12 19:55:30 -10:00
J. Nick Koston d9762759c0 Merge branch 'benchmark-use-os-optimization' into proto-speed-optimized-v2 2026-04-12 19:30:45 -10:00
J. Nick Koston e1ea9cb66b Revert "Merge branch 'benchmark-crypto-o2' into integration"
This reverts commit c58447ad3a, reversing
changes made to 3b02c6d5ef.
2026-04-12 19:26:54 -10:00
J. Nick Koston d217ab3cd4 [api] Add speed_optimized proto option for hot encode paths
Add a new (speed_optimized) message option that emits
__attribute__((optimize("O2"))) on the generated encode() and
calculate_size() methods. Under -Os, GCC does not inline the small
ProtoEncode helpers (write_raw_byte, encode_varint, etc.) into the
generated methods, causing significant overhead on hot paths.

Apply to SensorStateResponse and BluetoothLERawAdvertisementsResponse
which are the highest-frequency encode paths.
2026-04-12 19:23:39 -10:00
J. Nick Koston 70dd732821 [api] Add speed_optimized proto option for hot encode paths
Add a new (speed_optimized) message option that emits
__attribute__((optimize("O2"))) on the generated encode() and
calculate_size() methods. Under -Os, GCC does not inline the small
ProtoEncode helpers (write_raw_byte, encode_varint, etc.) into the
generated methods, causing significant overhead on hot paths.

Apply to SensorStateResponse and BluetoothLERawAdvertisementsResponse
which are the highest-frequency encode paths.
2026-04-12 19:21:47 -10:00
J. Nick Koston c58447ad3a Merge branch 'benchmark-crypto-o2' into integration 2026-04-12 19:17:20 -10:00
J. Nick Koston 63184e95a2 [api] Only apply -O2 to libsodium, not noise-c
CodSpeed results show only Noise benchmarks improved with -O2 —
the speedup comes from libsodium's crypto primitives (Curve25519,
ChaCha20, Poly1305), not noise-c's protocol layer. Narrow the
optimization to libsodium only.
2026-04-12 19:15:06 -10:00
J. Nick Koston 5a250cc74f [api] Compile noise-c and libsodium with -O2 for speed
Crypto libraries are CPU-bound and benefit significantly from speed
optimization over the default -Os. Add a post: extra_script that
appends -O2 to noise-c and libsodium build flags when API noise
encryption is enabled. GCC uses the last -O flag, so this overrides
the global -Os for these libraries only.
2026-04-12 19:03:21 -10:00
J. Nick Koston 9acfeec431 Merge branch 'dev' into benchmark-use-os-optimization 2026-04-12 18:40:32 -10:00
J. Nick Koston 02f828fcbf [benchmark] Use -Os to match firmware optimization level
CodSpeed benchmarks were building with -O2, while all firmware
targets (ESP8266, ESP32, LibreTiny) use -Os. This mismatch means
the benchmarks cannot detect inlining regressions that affect real
devices — GCC under -O2 inlines functions that -Os outlines due to
its size-conscious cost model.

Switch to -Os with -ffunction-sections/-fdata-sections for proper
dead-code stripping (needed because -Os preserves references that
-O2 optimizes away at compile time).
2026-04-12 18:37:50 -10:00
J. Nick Koston ab64916c37 [benchmark] Use -Os to match firmware optimization level
CodSpeed benchmarks were building with -O2, while all firmware
targets (ESP8266, ESP32, LibreTiny) use -Os. This mismatch means
the benchmarks cannot detect inlining regressions that affect real
devices — GCC under -O2 inlines functions that -Os outlines due to
its size-conscious cost model.

Remove the -Os unflag and -O2 override so benchmarks use the
platform default -Os, matching what actually runs on devices.
2026-04-12 18:32:03 -10:00
J. Nick Koston 3b02c6d5ef Merge branch 'scheduler-inline-process-defer-queue' into integration 2026-04-12 17:51:30 -10:00
J. Nick Koston 7000b865ce [scheduler] Force-inline process_defer_queue_() fast path
process_defer_queue_() follows the same fast-path/slow-path pattern
as cleanup_() and process_to_add(): an atomic load + branch that
skips to the slow path only when work is pending. GCC currently
inlines it, but past experience shows the compiler can change its
mind when surrounding code changes. Use ESPHOME_ALWAYS_INLINE to
lock in the intended behavior.
2026-04-12 17:51:01 -10:00
J. Nick Koston 3d5a65cf0e Merge remote-tracking branch 'upstream/scheduler-inline-process-to-add' into integration 2026-04-12 17:48:14 -10:00
J. Nick Koston 939b3d383c [scheduler] Force-inline process_to_add() fast path
process_to_add() has the same pattern as cleanup_(): a one-line
inline fast path (check if to_add_ is empty) with the slow path
already out-of-line in process_to_add_slow_path_(). GCC inlines it
on ESP8266 but not on ESP32, emitting a 20-byte out-of-line body.

Use ESPHOME_ALWAYS_INLINE to guarantee inlining on all platforms.
Verified on ESP32 (xtensa-esp32):
- process_to_add() symbol eliminated from binary
- Scheduler::call() idle path: 1 out-of-line call (millis_64 only)
2026-04-12 17:47:31 -10:00
J. Nick Koston ce397799dd Merge branch 'millis64-inline-single-thread' into integration 2026-04-12 17:36:15 -10:00
J. Nick Koston 7126b01a45 Merge branch 'scheduler-inline-cleanup' into integration 2026-04-12 17:35:36 -10:00
J. Nick Koston 8fbf102ef3 [core] Inline Millis64Impl::compute() on single-threaded platforms
On ESPHOME_THREAD_SINGLE platforms (ESP8266), move the
Millis64Impl::compute() body into the header so it can be inlined at
call sites. The function is trivial: two static loads, a rollover
branch (taken every ~49.7 days), a store, and a shift+add.

The static storage (last_millis_, millis_major_) is declared as class
statics in the header and defined in time_64.cpp so all TUs share one
copy. Multi-threaded paths remain out-of-line in time_64.cpp.

Also force-inline millis_64_from_() which wraps compute() — GCC was
creating an $isra$ clone instead of inlining the wrapper.

Verified on ESP8266 (xtensa-lx106):
- Millis64Impl::compute() and millis_64_from_ symbols eliminated
- Scheduler::call() idle path: zero out-of-line calls (was 1)
- compute body inlined into 3 call sites (Scheduler::call,
  next_schedule_in, loop/millis_64)
2026-04-12 17:34:34 -10:00
J. Nick Koston 942cb0733b [scheduler] Force-inline cleanup_() fast path into Scheduler::call()
cleanup_() has a two-line fast path (check to_remove count, return
!items_.empty()) with the slow path already out-of-line in
cleanup_slow_path_(). Despite `inline` hint, GCC on Xtensa emits it
as a separate function, adding unnecessary call overhead on every
Scheduler::call() invocation even when there is nothing to clean up.

Use ESPHOME_ALWAYS_INLINE to guarantee inlining. Verified on ESP8266:
- cleanup_() symbol eliminated from binary
- Scheduler::call() grows 4 bytes (inlined fast path)
- Net savings: 23 bytes (27-byte out-of-line body removed)
- Idle loop path: 1 out-of-line call instead of 2
2026-04-12 17:26:00 -10:00
Jonathan Swoboda ac8a2467a5 [core] Fix PlatformIO progress bar rendering in subprocess mode (#15681) 2026-04-12 22:51:55 -04:00
J. Nick Koston dde66ff1e1 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-12 16:39:30 -10:00
J. Nick Koston 93a5984a95 Merge branch 'ld24xx-lazy-sensor-dedup' into integration 2026-04-12 15:31:21 -10:00
J. Nick Koston 5d8dc8e62c fix missing semis 2026-04-12 15:30:30 -10:00
J. Nick Koston 099a45cf2e bot comments 2026-04-12 15:19:27 -10:00
Jesse Hills dc1dd9ebb7 Merge branch 'beta' into dev 2026-04-13 12:45:02 +12:00
Jesse Hills 0c06d78a4f Merge pull request #15675 from esphome/bump-2026.4.0b2
2026.4.0b2
2026.4.0b2
2026-04-13 12:44:27 +12:00
schrobandJ. Nick Koston 41c9ed28cd [esp32] Use static stack memory for loop task instead of heap (#15659)
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-04-12 23:23:01 +00:00