Commit Graph
26439 Commits
Author SHA1 Message Date
J. Nick Koston d55f5b9b77 Merge remote-tracking branch 'origin/api/peel-first-write-iteration' into integration 2026-04-01 23:14:29 -10:00
J. Nick Koston adaab73761 [api] Pass payload_size and message_type directly to write_plaintext_header
Avoids constructing a MessageInfo in write_protobuf_packet just to
pass two fields through.
2026-04-01 23:13:33 -10:00
J. Nick Koston a1a1bee060 Merge remote-tracking branch 'origin/api/peel-first-write-iteration' into integration 2026-04-01 22:59:27 -10:00
J. Nick Koston 3f9d8ccf98 [api] Fix clang-tidy: rename varint helpers, remove unused function
Drop trailing underscore from static functions (readability-identifier-naming)
and remove unused plaintext_header_length.
2026-04-01 22:58:08 -10:00
J. Nick Koston 3ca5e9a3f5 [api] Extract inline varint encoders as named ALWAYS_INLINE helpers
Move the inline varint byte writes into encode_varint_16_ and
encode_varint_8_ for readability. Same generated code since both
are ALWAYS_INLINE.
2026-04-01 22:47:13 -10:00
J. Nick Koston a8c6c55de2 [api] Inline varint encoding in write_plaintext_header
Replace two out-of-line encode_varint_to_buffer calls with direct
byte writes using the already-computed varint lengths. Eliminates
function call overhead (register save/restore) from the batch loop
and removes the 34-byte out-of-line encode_varint_to_buffer function
which had no other callers.
2026-04-01 22:43:58 -10:00
J. Nick Koston 1f455e7737 adjust 2026-04-01 22:32:08 -10:00
J. Nick Koston 6576ebc294 [api] Update stale comments in write_protobuf_messages 2026-04-01 22:31:58 -10:00
J. Nick Koston ebefe76362 adjust 2026-04-01 22:30:48 -10:00
J. Nick Koston cdf1adaa39 [api] Eliminate nullptr branch from write_protobuf_messages loop
Pre-compute the first message's header length before the loop to
initialize write_start/write_end. The first loop iteration naturally
skips memmove since src == write_end.

Extract varint_encoded_length_16/8 and plaintext_header_length as
reusable inline helpers from write_plaintext_header.
2026-04-01 22:20:56 -10:00
J. Nick Koston 06bc9462f1 [api] Deduplicate header code in plaintext write_protobuf_messages
Use a single loop for all messages instead of separate first-message
and loop paths. The first iteration skips memmove via the null check.
Eliminates duplicated write_plaintext_header inlining, reducing flash
from 326 to 229 bytes (-30%) while keeping the 64-byte stack frame.
2026-04-01 22:10:17 -10:00
J. Nick Koston f0edf10f95 [api] Pack batch messages contiguously for write() instead of writev()
Replace StaticVector<iovec> + writev() scatter-gather in the batch write
path with contiguous single-buffer write() calls.

Plaintext: compact messages via memmove to close 0-3 byte varint header
gaps, then write_raw_fast_buf_. Noise: messages are already contiguous
(fixed 7-byte header + 16-byte MAC fills all reserved space), switch
directly to write_raw_fast_buf_.

Fix LOG_PACKET_SENDING to log after write/enqueue to prevent re-entrant
log sends from corrupting the shared buffer before data is sent.
Consolidate the macro to api_frame_helper.cpp and expose via out-of-line
log_packet_sending_() helper.

Remove write_raw_fast_iov_ (no remaining callers) and change
encrypt_noise_message_ to return uint16_t length instead of iovec.
2026-04-01 21:45:18 -10:00
J. Nick Koston c84d697319 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-01 17:42:13 -10:00
J. Nick Koston 0a9d36b09d Merge branch 'dev' into api/peel-first-write-iteration 2026-04-01 17:19:11 -10:00
J. Nick Koston 3fbf0f0c01 [api] Simplify encode_to_buffer to single resize call (#15355) 2026-04-02 03:13:09 +00:00
J. Nick Koston 1436d034bf [api] Inline DeferredBatch::add_item to eliminate push_back call barrier (#15353) 2026-04-02 03:11:47 +00:00
J. Nick Koston 08c7b3afbd [esp32_ble_tracker] Reduce scan cycle log spam (#15365) 2026-04-01 16:53:53 -10:00
J. Nick Koston 0df38cc62a Merge branch 'dev' into api/peel-first-write-iteration 2026-04-01 16:34:53 -10:00
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 f36d78e09c [core] Force inline Component::get_component_log_str() (#15363) 2026-04-01 16:15:00 -10:00
J. Nick Koston be56be5201 [core] Reduce runtime_stats measurement overhead (#15359) 2026-04-01 16:14:45 -10:00
J. Nick Koston 7954a770bd Merge branch 'dev' into api/peel-first-write-iteration 2026-04-01 16:12:46 -10:00
J. Nick Koston bcc7b8f490 [api] Add send_sensor_state benchmarks (#15352) 2026-04-01 16:12:02 -10:00
J. Nick Koston 27c662e73f [bluetooth_proxy] Replace loop() with set_interval for advertisement flushing (#15347) 2026-04-01 16:11:50 -10:00
Clyde Stubbs eefbb42be4 [lvgl] Add missing event names (#15362) 2026-04-02 14:16:56 +13: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
dependabot[bot] b5c4449a16 Bump pillow from 12.1.1 to 12.2.0 (#15361)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-01 14:11:44 -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
Boris KrivonogandJ. Nick Koston 5cdbbd4887 [mitsubishi_cn105] Add climate component for Mitsubishi A/C units with CN105 connector (Part 1) (#15315)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
2026-04-01 11:48:47 -10:00
Clyde Stubbs bdce47e764 [lvgl] Fixes #4 (#15334) 2026-04-02 10:39:51 +13: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