Commit Graph

23204 Commits

Author SHA1 Message Date
J. Nick Koston
ec914fcb77 Merge remote-tracking branch 'upstream/scheduler-rvalue-ref-func' into integration 2026-02-24 13:45:32 -06:00
J. Nick Koston
eedb1be19c [core] Pass std::function by rvalue reference in set_timer_common_
Change set_timer_common_ to take std::function<void()>&& instead of
by value. This avoids materializing a std::function copy on the stack
at each call site — the caller just passes a pointer to the rvalue.

On BK7231N (Thumb-1), each forwarder (set_timeout, set_interval) was
118 bytes due to the inlined std::function move constructor + register
spilling. With rvalue reference, they shrink to 32 bytes each.

All 12 callers already pass rvalues (std::move or lambda temporaries),
so this is a purely mechanical change with no semantic difference.

BK7231N: forwarders 118 -> 32 bytes each, ~258 bytes saved total
ESP32: forwarders 46 -> 30 bytes each, ~20 bytes saved total
2026-02-24 13:35:06 -06:00
J. Nick Koston
a53fd4f586 Merge branch 'scheduler-rvalue-ref-func' into integration 2026-02-24 13:25:46 -06:00
J. Nick Koston
b3983bc088 [core] Pass std::function by rvalue reference in set_timer_common_
Change set_timer_common_ to take std::function<void()>&& instead of
by value. This avoids materializing a std::function copy on the stack
at each call site — the caller just passes a pointer to the rvalue.

On BK7231N (Thumb-1), each forwarder (set_timeout, set_interval) was
118 bytes due to the inlined std::function move constructor + register
spilling. With rvalue reference, they shrink to 32 bytes each.

All 12 callers already pass rvalues (std::move or lambda temporaries),
so this is a purely mechanical change with no semantic difference.

BK7231N: forwarders 118 -> 32 bytes each, ~258 bytes saved total
ESP32: forwarders 46 -> 30 bytes each, ~20 bytes saved total
2026-02-24 13:19:53 -06:00
Jonathan Swoboda
fe3c2ba555 [http_request.ota] Percent-encode credentials in URL (#14257)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-24 14:15:22 -05:00
J. Nick Koston
95623476c5 Merge remote-tracking branch 'upstream/scheduler-custom-deleter-bk7231n' into integration
# Conflicts:
#	esphome/core/scheduler.h
2026-02-24 12:23:35 -06:00
J. Nick Koston
e3bf2d78d1 [core] Use custom deleter for SchedulerItem unique_ptr to prevent destructor inlining
On BK7231N (Thumb-1/Cortex-M0), GCC inlines ~unique_ptr<SchedulerItem>
(~30 bytes: null check + ~std::function + operator delete) at every
destruction site, while ESP32/ESP8266/RTL8720CF outline it into a single
shared helper. This causes significant flash bloat in scheduler functions.

Use a custom deleter (SchedulerItemDeleter) with its operator() defined
in the .cpp file, ensuring the compiler emits exactly one copy of the
destruction code. All destruction sites now generate a simple function
call instead of inlining the full body.

BK7231N savings (bytes):
- call():           816 -> 670  (-146)
- process_to_add(): 390 -> 308  (-82)
- __adjust_heap:    430 -> 312  (-118)
- pop_raw_locked_(): 192 -> 140  (-52)
- cleanup_():       130 -> 112  (-18)
- SchedulerItemDeleter: +32 (new, single copy)
- Net: ~384 bytes saved

ESP32/ESP8266/RTL8720CF are unaffected (already outline the destructor).
2026-02-24 12:10:21 -06:00
J. Nick Koston
535fb86c9c Merge remote-tracking branch 'upstream/dev' into integration
# Conflicts:
#	esphome/core/scheduler.h
2026-02-24 12:09:20 -06:00
J. Nick Koston
6554ad7c7e [core] Prevent inlining of mark_matching_items_removed_locked_ on Thumb-1 (#14256) 2026-02-24 12:08:51 -06:00
J. Nick Koston
6dac62d0df Merge branch 'scheduler-custom-deleter-bk7231n' into integration
# Conflicts:
#	esphome/core/scheduler.h
2026-02-24 11:54:20 -06:00
J. Nick Koston
60dc18b80c [core] Use custom deleter for SchedulerItem unique_ptr to prevent destructor inlining
On BK7231N (Thumb-1/Cortex-M0), GCC inlines ~unique_ptr<SchedulerItem>
(~30 bytes: null check + ~std::function + operator delete) at every
destruction site, while ESP32/ESP8266/RTL8720CF outline it into a single
shared helper. This causes significant flash bloat in scheduler functions.

Use a custom deleter (SchedulerItemDeleter) with its operator() defined
in the .cpp file, ensuring the compiler emits exactly one copy of the
destruction code. All destruction sites now generate a simple function
call instead of inlining the full body.

BK7231N savings (bytes):
- call():           816 -> 670  (-146)
- process_to_add(): 390 -> 308  (-82)
- __adjust_heap:    430 -> 312  (-118)
- pop_raw_locked_(): 192 -> 140  (-52)
- cleanup_():       130 -> 112  (-18)
- SchedulerItemDeleter: +32 (new, single copy)
- Net: ~384 bytes saved

ESP32/ESP8266/RTL8720CF are unaffected (already outline the destructor).
2026-02-24 11:48:48 -06:00
J. Nick Koston
3660363eaf Merge remote-tracking branch 'upstream/noinline-mark-matching-items-removed' into integration 2026-02-24 11:18:10 -06:00
J. Nick Koston
7ec61ae265 [core] Prevent inlining of mark_matching_items_removed_locked_
The BK7231N Thumb-1 compiler inlines this function 3 times into
cancel_item_locked_, bloating it from ~140 B to 666 B. ESP32 and
RTL8720CF compilers already outline it, so this attribute only
affects BK7231N. Saves ~486 B of flash.
2026-02-24 11:15:52 -06:00
J. Nick Koston
f1810550f3 Merge branch 'extend_ultra_low_latency_select_libretiny' into integration 2026-02-24 10:47:58 -06:00
J. Nick Koston
2e6d10474e Add socket build tests for LibreTiny platforms
Add bk72xx-ard, rtl87xx-ard, and ln882x-ard YAML build tests to
verify the fast select code path compiles on all LibreTiny platforms.
2026-02-24 10:29:49 -06:00
J. Nick Koston
d812683df1 Use platform build flags in lwip_fast_select.c guard
USE_ESP32 and USE_LIBRETINY are compiler flags (-D) always available
to .c files. USE_LWIP_FAST_SELECT is in the generated defines.h which
may not be force-included for .c files on all build systems. Use
platform flags directly in the .c file; .cpp/.h files continue using
USE_LWIP_FAST_SELECT from the generated defines.
2026-02-24 09:49:07 -06:00
J. Nick Koston
3f74726f00 [core] Extend fast select optimization to LibreTiny platforms
Extend the ESP32 lwip_select() replacement (direct rcvevent reads +
FreeRTOS task notifications) to all LibreTiny platforms (bk72xx,
rtl87xx, ln882h).

All LibreTiny platforms have LwIP >= 2.1.3 with
lwip_socket_dbg_get_socket() and FreeRTOS task notifications. The
thread safety argument is actually stronger on LibreTiny since all
platforms are single-core ARM Cortex-M, eliminating cross-core
memory ordering concerns entirely.

Introduces USE_LWIP_FAST_SELECT feature define (set from Python
codegen for ESP32 and LibreTiny) replacing per-platform USE_ESP32
guards. The only platform-specific difference is FreeRTOS header
paths (freertos/FreeRTOS.h on ESP-IDF vs FreeRTOS.h on LibreTiny).

Expected impact on LibreTiny (same as ESP32):
- ~17x faster socket polling (direct rcvevent vs lwip_select)
- ~3.5 KB flash savings (dead code elimination of lwip_select)
- ~56 bytes static RAM savings (fd_set members excluded)
- ~200-300 bytes heap savings (UDP wake socket eliminated)
2026-02-24 09:39:38 -06:00
J. Nick Koston
fc5b94df6c pressure test 2026-02-24 08:48:50 -06:00
J. Nick Koston
40da111322 Merge branch 'ultra_low_latancy_select_esp32' into integration 2026-02-24 08:44:43 -06:00
J. Nick Koston
73092d14a5 tweak comments 2026-02-24 08:44:31 -06:00
J. Nick Koston
bd906a0fbd Merge branch 'ultra_low_latancy_select_esp32' into integration 2026-02-24 08:42:32 -06:00
J. Nick Koston
36eb31e8ee tweak comments 2026-02-24 08:42:23 -06:00
J. Nick Koston
96cbea96a1 Merge branch 'ultra_low_latancy_select_esp32' into integration 2026-02-24 08:40:35 -06:00
J. Nick Koston
8d997c247e improve comments about safety 2026-02-24 08:40:02 -06:00
Clyde Stubbs
4abbed0cd4 [mipi_dsi] Allow transform disable; fix warnings (#14216) 2026-02-24 08:33:33 -05:00
H. Árkosi Róbert
72263eda85 [version] text sensor add option hide_hash to restore the pre-2026.1 behavior (#14251)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-02-24 07:31:58 -06:00
Jonathan Swoboda
abf7074518 [esp32] Improve ESP32-P4 engineering sample warning message (#14252)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-24 08:27:48 -05:00
J. Nick Koston
3edf5f97db Merge remote-tracking branch 'origin/light-gamma-lut' into integration 2026-02-23 23:17:11 -06:00
J. Nick Koston
5e713a84a0 [light] Remove unused color_interlock parameter from current_values_as_rgb/rgbw
The color_interlock parameter was accepted but never read in
current_values_as_rgb and current_values_as_rgbw — a leftover
from when it was forwarded to LightColorValues::as_rgb().
2026-02-23 23:15:23 -06:00
J. Nick Koston
ccd9936080 Merge branch 'ultra_low_latancy_select_esp32' into integration 2026-02-23 22:24:55 -06:00
J. Nick Koston
07014b09ae Revert "Add fast_select diagnostic counters logged every 10000 loops"
This reverts commit 29ffeeeb19.
2026-02-23 22:22:26 -06:00
J. Nick Koston
29ffeeeb19 Add fast_select diagnostic counters logged every 10000 loops 2026-02-23 22:21:07 -06:00
J. Nick Koston
ccdaf9b940 Merge branch 'ultra_low_latancy_select_esp32' into integration 2026-02-23 22:16:37 -06:00
J. Nick Koston
d1dffafc86 Clarify rcvevent reads are main-loop-only due to socket ownership 2026-02-23 22:14:15 -06:00
J. Nick Koston
44462d8453 Document Socket::ready() as main-loop-only 2026-02-23 22:10:29 -06:00
J. Nick Koston
341395a1cd Remove unused public is_socket_ready() 2026-02-23 22:09:46 -06:00
J. Nick Koston
63a144fb43 Fix is_socket_ready comment: main loop only, not thread-safe 2026-02-23 22:07:58 -06:00
J. Nick Koston
5a378143e2 Fix LwIP source references and thread safety comments 2026-02-23 22:06:17 -06:00
J. Nick Koston
04af37e514 Note lwip_socket_dbg_get_socket wraps tryget_socket_unconn_nouse 2026-02-23 22:01:36 -06:00
J. Nick Koston
cba004e2d1 Check for pending socket data before sleeping 2026-02-23 21:49:26 -06:00
J. Nick Koston
8d1cf9fd7d Add clarifying comments for review feedback 2026-02-23 21:37:19 -06:00
J. Nick Koston
1c886d43e7 Extract get_sock() helper to deduplicate lookup pattern 2026-02-23 21:33:05 -06:00
J. Nick Koston
746e760697 Remove dead NULL check on s_original_callback 2026-02-23 21:32:18 -06:00
J. Nick Koston
661f826bf1 comments 2026-02-23 21:27:03 -06:00
J. Nick Koston
6734aa1544 comments 2026-02-23 21:24:29 -06:00
J. Nick Koston
c3dee3d307 comments 2026-02-23 21:21:43 -06:00
J. Nick Koston
29416061ea comments 2026-02-23 21:20:38 -06:00
J. Nick Koston
3fd24b779c comments 2026-02-23 21:17:50 -06:00
J. Nick Koston
c9c73ec6e9 cleanup 2026-02-23 21:13:16 -06:00
J. Nick Koston
a696ed4920 cleanup 2026-02-23 21:10:59 -06:00