Commit Graph
26412 Commits
Author SHA1 Message Date
J. Nick Koston 8d573fd3c9 Merge remote-tracking branch 'upstream/reduce-ble-tracker-log-spam' into integration 2026-04-01 16:17:44 -10:00
J. Nick Koston 195efdc963 [esp32_ble_tracker] Reduce scan cycle log spam by changing to verbose level 2026-04-01 16:16:51 -10:00
J. Nick Koston 5329e449fe Merge branch 'inline-get-component-log-str' into integration 2026-04-01 14:26:43 -10:00
J. Nick Koston 5e7895bf26 [core] Force inline Component::get_component_log_str()
Move get_component_log_str() from component.cpp into the header
as an always_inline method. This is a trivial one-liner that just
calls component_source_lookup(), but the compiler was keeping it
out-of-line across 8 call sites (13 bytes).

Saves 8 bytes on ESP32.
2026-04-01 14:23:47 -10:00
J. Nick Koston e28cbe036b Merge remote-tracking branch 'upstream/reduce-runtime-stats-overhead' into integration 2026-04-01 13:42:20 -10:00
J. Nick Koston 394bce5270 Inline check_blocking_ back into finish() 2026-04-01 13:41:40 -10:00
J. Nick Koston 123dd4f137 [core] Reduce runtime_stats measurement overhead
Inline record_runtime_stats_() to eliminate the non-inlined function
call overhead per component per loop iteration. Extract check_blocking_()
as an inline helper for readability.

The millis() return value stays in the caller's clock domain — only
the micros()-based stats recording is inlined alongside it.
2026-04-01 13:40:03 -10:00
J. Nick Koston 3c890eb994 [core] Reduce runtime_stats measurement overhead
Use a single micros() call in WarnIfComponentBlockingGuard::finish()
for both runtime stats recording and blocking detection. Previously
finish() called millis() for blocking detection and a separate
non-inlined record_runtime_stats_() that called micros() again.

Changes:
- Inline record_runtime_stats_() to avoid function call overhead
- Derive curr_time from micros()/1000 instead of separate millis() call
- Override started_ from micros()/1000 in constructor so both timestamps
  use the same clock source (fixes unsigned underflow on platforms where
  millis() and micros()/1000 can diverge)
- Extract check_blocking_() as inline helper for readability
2026-04-01 13:17:18 -10:00
J. Nick Koston 9b820af99a Merge remote-tracking branch 'origin/libretiny-wifi-queue-abstraction' into integration 2026-04-01 12:34:00 -10:00
J. Nick Koston 7b222f773f Fix: skip update_connected_state_ only when already connected
After wifi_loop_() processes the STA_CONNECTED event, state_ is still
CONNECTING (state machine hasn't run yet). update_connected_state_()
runs but is_connected_() returns false. Then check_connecting_finished()
transitions to STA_CONNECTED. Next iteration: no events, state is
STA_CONNECTED, so we skipped update — connected_ stayed false forever.

Fix: check connected_ instead of state_. Only skip when connected_ is
already true (steady state). When connected_ is false, always re-evaluate
so the flag gets set after the state machine transitions.
2026-04-01 12:32:19 -10:00
J. Nick Koston 244287176a Fix: skip update_connected_state_ only when already connected
After wifi_loop_() processes the STA_CONNECTED event, state_ is still
CONNECTING (state machine hasn't run yet). update_connected_state_()
runs but is_connected_() returns false. Then check_connecting_finished()
transitions to STA_CONNECTED. Next iteration: no events, state is
STA_CONNECTED, so we skipped update — connected_ stayed false forever.

Fix: check connected_ instead of state_. Only skip when connected_ is
already true (steady state). When connected_ is false, always re-evaluate
so the flag gets set after the state machine transitions.
2026-04-01 12:32:11 -10:00
J. Nick Koston 028c6ec1da Merge branch 'libretiny-wifi-queue-abstraction' into integration 2026-04-01 12:28:58 -10:00
J. Nick Koston f7222e39bb Skip update_connected_state_() when no events and already connected
wifi_sta_connect_status_() is a non-inlined function call that reads
3 static globals through literal pool indirections on every loop
iteration. Since those globals are only modified during event
processing, skip the call entirely when wifi_loop_() found no
events and we're already in STA_CONNECTED state.

wifi_loop_() now returns bool (true if events were processed) on
all platforms. ESP8266 and Pico W always return true since they
poll state directly rather than using an event queue.
2026-04-01 12:27:52 -10:00
J. Nick Koston 010e778cd0 Skip update_connected_state_() when no events and already connected
wifi_sta_connect_status_() is a non-inlined function call that reads
3 static globals through literal pool indirections on every loop
iteration. Since those globals are only modified during event
processing, skip the call entirely when wifi_loop_() found no
events and we're already in STA_CONNECTED state.

wifi_loop_() now returns bool (true if events were processed) on
all platforms. ESP8266 and Pico W always return true since they
poll state directly rather than using an event queue.
2026-04-01 12:27:39 -10:00
J. Nick Koston 5917011716 Merge remote-tracking branch 'origin/libretiny-wifi-queue-abstraction' into integration 2026-04-01 12:09:32 -10:00
J. Nick Koston 20884d5844 Use empty() instead of empty_relaxed() for wifi_loop_ fast path
GCC on Xtensa emits memw for relaxed atomic loads too, so the
savings from relaxed vs acquire are only 2 memw (~4 cycles) — not
worth the weaker correctness guarantees. The real optimization is
the early return that skips get_and_reset_dropped_count() and the
pop() loop entirely.
2026-04-01 12:08:39 -10:00
J. Nick Koston 63a0581440 Add empty_relaxed() fast path to wifi_loop_ queue drain
On Xtensa (ESP32), even relaxed atomic loads emit memw instructions,
but they avoid the more expensive acquire fences. The pop() path
required acquire loads + release stores just to discover the queue
was empty. By checking empty_relaxed() first, the steady-state
connected path (queue always empty) returns in ~7 instructions
instead of falling through to get_and_reset_dropped_count() and pop().
2026-04-01 12:06:03 -10:00
J. Nick Koston 0f6d6c989b Merge branch 'encode-to-buffer-combine-resize-v2' into integration 2026-04-01 11:16:33 -10:00
J. Nick Koston d48ec52446 reduce 2026-04-01 11:10:12 -10:00
J. Nick Koston 7afae4ece3 reduce 2026-04-01 11:08:06 -10:00
J. Nick Koston 69a2609d58 [api] Reuse total_calculated_size in encode_to_buffer return and resize 2026-04-01 11:02:15 -10:00
J. Nick Koston f789767614 Merge remote-tracking branch 'upstream/encode-to-buffer-combine-resize-v2' into integration 2026-04-01 10:58:42 -10:00
J. Nick Koston 09648b86f9 [api] Combine reserve_and_resize + resize in encode_to_buffer
For non-first batch messages, fold the payload resize into the
reserve_and_resize call. This eliminates a redundant size() read,
a redundant capacity check, and an extra jump on the hot path.

Saves 17 bytes in encode_to_buffer (130 → 113) and ~5 instructions
on the second-message path.
2026-04-01 10:57:46 -10:00
J. Nick Koston fd4d6beef2 Merge branch 'inline-push-item' into integration 2026-04-01 10:33:49 -10:00
J. Nick Koston 702093fae6 [api] Inline get_batch_delay_ms_ — trivial forwarder 2026-04-01 10:14:08 -10:00
J. Nick Koston e2e2b7d699 [api] Move schedule_message_front_ out-of-line to avoid cold path bloat
schedule_message_front_ is only called from cold paths (on_shutdown,
check_keepalive_). Moving it out-of-line prevents add_item_front and
push_back from being inlined into those callers.
2026-04-01 10:09:20 -10:00
J. Nick Koston 475927e3c4 [api] Revert add_item_front back to inline — single call site 2026-04-01 10:08:24 -10:00
Jesse Hills 813b142b72 Merge branch 'release' into dev 2026-04-02 09:07:41 +13:00
J. Nick Koston 4f385fc2ec [api] Keep add_item_front out-of-line to avoid bloating cold callers
add_item_front is only called from on_shutdown and check_keepalive_
which are cold paths. Keeping it out-of-line prevents inlining
push_back into those callers.
2026-04-01 10:07:09 -10:00
Jesse Hills b7dabe236e Merge pull request #15342 from esphome/bump-2026.3.2
2026.3.2
2026.3.2
2026-04-02 09:06:55 +13:00
J. Nick Koston 6d18422216 [api] Use this-> for member access in inline methods 2026-04-01 09:57:29 -10:00
J. Nick Koston b236d09734 [api] Move add_item/add_item_front inline and remove push_item
Both are only called from one site each. Moving them inline lets the
compiler inline push_back directly into the caller without a function
call barrier. Removes the now-unnecessary push_item wrapper.
2026-04-01 09:56:44 -10:00
J. Nick Koston 83f8a95e28 [api] Flatten add_item and add_item_front to inline push_back
Add __attribute__((flatten)) to add_item and add_item_front so the
compiler inlines push_item → push_back and all their callees directly
into these functions, eliminating the function call barrier.
2026-04-01 09:55:02 -10:00
J. Nick Koston 44be29789a [api] Inline push_item to allow push_back to be inlined into caller
The out-of-line push_item with __attribute__((flatten)) inlined
push_back's callees into push_item, but push_item itself remained
a function call barrier. Moving push_item inline lets the compiler
inline push_back into the actual call sites (add_item, add_item_front).
2026-04-01 09:53:37 -10:00
J. Nick Koston 18b00fb3fc [api] Revert push_item inline — CodSpeed shows 46% regression
Inlining push_item into add_item bloated the dedup loop, causing
the compiler to make worse inlining decisions. Total time went from
44µs to 64.5µs. Restore out-of-line with __attribute__((flatten))
which keeps add_item's dedup loop tight while still inlining
push_back's callees into push_item.
2026-04-01 09:51:55 -10:00
J. Nick Koston 2b8d4af1e7 [api] Inline DeferredBatch::push_item to avoid call overhead
push_item was defined out-of-line in the .cpp to avoid duplicate
_M_realloc_insert instantiation, but the function call overhead
on every add_item was visible in benchmarks. Move it inline since
it's a one-liner wrapper around push_back.
2026-04-01 09:46:04 -10:00
J. Nick Koston d82cc0c08a [api] Guard benchmark friend declarations with USE_BENCHMARK 2026-04-01 09:43:47 -10:00
J. Nick Koston 34cbe0abe1 [api] Fix stale comment: 1MB → 16MB socket buffers 2026-04-01 09:40:25 -10:00
J. Nick Koston 9fb8594a16 [api] Fix lint false positive on 'byte' in comment 2026-04-01 09:06:07 -10:00
J. Nick Koston c09d5d783c [api] Fix immediate benchmark to set batch_delay=0
should_send_immediately_ requires both should_try_send_immediately
flag AND batch_delay==0. Without setting batch_delay to 0, all
sends were falling back to the batch path.
2026-04-01 09:00:59 -10:00
J. Nick Koston d717c7b46c [api] Use large socket buffers and remove mid-loop draining
Increase socket buffer to 16MB so benchmarks never hit WOULD_BLOCK
during an inner loop iteration. Remove per-iteration drain_socket
calls that were adding noise and causing the immediate path to
fall back to batching. Drain only between outer iterations.
2026-04-01 08:54:30 -10:00
J. Nick Koston f469a7ced2 [api] Add process_batch benchmarks for single and multi-sensor
Add ProcessBatch_SingleSensor and ProcessBatch_5Sensors benchmarks
that measure the full batch processing path: queue → process_batch_ →
dispatch → encode → frame → TCP write.
2026-04-01 08:49:33 -10:00
J. Nick Koston 3a4a88df29 [api] Add warm batch benchmark and bench_clear_batch friend
Add SendSensorState_Batch_Warm that pre-warms the deferred batch vector
before benchmarking to isolate steady-state cost from allocation.
2026-04-01 08:43:38 -10:00
J. Nick Koston d3f3f89c59 [api] Extract shared TCP loopback helper for API benchmarks
Deduplicate the TCP loopback socket setup between bench_plaintext_frame
and bench_send_sensor_state into a shared bench_helpers.h header.
2026-04-01 07:48:12 -10:00
J. Nick Koston dcac526a34 [api] Add send_sensor_state benchmarks
Add benchmarks for the full send_sensor_state path covering both
immediate send and batch paths. This measures the end-to-end cost
of sending a sensor state update through an APIConnection including
entity field population, proto encode, framing, and TCP write.
2026-04-01 07:42:58 -10:00
J. Nick Koston 12ab72fb21 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-01 07:13:34 -10:00
Jonathan Swoboda 2e3ea2152d [esp32_camera] Bump esp32-camera to v2.1.6 (#15349) 2026-04-01 07:13:23 -10:00
J. Nick Koston 87a0d0d858 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-01 07:12:13 -10:00
J. Nick Koston ea609d3552 [runtime_stats] Store stats inline on Component to eliminate std::map lookup (#15345) 2026-04-01 07:09:04 -10:00
f33fd047ee [hdc2080] Add support for HDC2080 sensor (#9331)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Big Mike <mikelawrence@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: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
2026-04-01 12:09:22 -04:00