Commit Graph

23650 Commits

Author SHA1 Message Date
J. Nick Koston fd78e19bc2 Merge remote-tracking branch 'origin/web_server' into integration 2026-03-01 17:04:50 -10:00
J. Nick Koston 3601aff8e0 Merge remote-tracking branch 'origin/api-flash-string-progmem' into integration 2026-03-01 17:04:44 -10:00
J. Nick Koston e93df630fa Merge remote-tracking branch 'origin/remove_posix_tz_parser' into integration 2026-03-01 17:04:42 -10:00
J. Nick Koston 33b4fc516b Merge branch 'dev' into web_server 2026-03-01 17:04:01 -10:00
J. Nick Koston 367de9b737 Merge branch 'dev' into api-flash-string-progmem 2026-03-01 17:03:18 -10:00
J. Nick Koston 251e0129a2 Merge remote-tracking branch 'upstream/dev' into remove_posix_tz_parser 2026-03-01 17:02:06 -10:00
J. Nick Koston 0e18e4461e [time,api] Send pre-parsed timezone struct over protobuf (#14233)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 15:52:53 +13:00
J. Nick Koston 338a1ce244 Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 16:47:08 -10:00
J. Nick Koston 5bd7f0ea96 [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 16:46:58 -10:00
J. Nick Koston bad8525235 eliminate duplicate socket_listen* symbols on BSD/LWIP_SOCKETS 2026-03-01 16:44:53 -10:00
J. Nick Koston affad9439d Merge remote-tracking branch 'upstream/dev' into integration 2026-03-01 16:37:09 -10:00
J. Nick Koston 023faab206 Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 15:38:10 -10:00
J. Nick Koston 680417941e [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 15:38:01 -10:00
J. Nick Koston d8fa5ace1b document stale read tolerance in hint read comment 2026-03-01 15:37:42 -10:00
J. Nick Koston 1a8b7bd38e Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 15:36:20 -10:00
J. Nick Koston 0a45c5a351 [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 15:36:09 -10:00
J. Nick Koston 52f76a4f43 restore SYS_ARCH_UNPROTECT visibility comment 2026-03-01 15:35:52 -10:00
J. Nick Koston 1b5df15aaf Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 15:35:32 -10:00
J. Nick Koston 2f43416005 [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 15:35:20 -10:00
J. Nick Koston 50fb013fc5 document unlocked hint read rationale 2026-03-01 15:34:55 -10:00
J. Nick Koston 3e7424b307 [preferences] Reduce heap churn with small inline buffer optimization (#13259) 2026-03-02 14:22:55 +13:00
J. Nick Koston b86807a8ea Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 15:19:59 -10:00
J. Nick Koston 1d438be580 [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 15:19:35 -10:00
J. Nick Koston 74ca9e9f91 assert rcvevent is exactly 2 bytes to match inline int16_t read 2026-03-01 15:19:16 -10:00
J. Nick Koston 9ba087cf97 Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 14:38:27 -10:00
J. Nick Koston f46a1deeda [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 14:38:02 -10:00
J. Nick Koston 48622dadbc inline ready() for full inlining chain 2026-03-01 14:37:35 -10:00
J. Nick Koston 85bd364093 Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 14:33:55 -10:00
J. Nick Koston a4dc546f58 [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 14:33:33 -10:00
J. Nick Koston 76073798a4 fix missing endif and clang-tidy enum ambiguity 2026-03-01 14:33:11 -10:00
J. Nick Koston 28cec19380 Merge branch 'cache-lwip-sock-pointers' into integration 2026-03-01 14:32:36 -10:00
J. Nick Koston 710458161a [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 14:32:28 -10:00
J. Nick Koston 9abb52f485 move socket_ready to header for inlining 2026-03-01 14:31:44 -10:00
J. Nick Koston 10ec8afbb2 Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/lwip_fast_select.h
2026-03-01 14:25:00 -10:00
J. Nick Koston 055ed0e751 [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 14:24:30 -10:00
J. Nick Koston 760f6bc37d Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/lwip_fast_select.c
#	esphome/core/lwip_fast_select.h
2026-03-01 14:23:26 -10:00
J. Nick Koston b3b3f18b3b [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- esphome_lwip_socket_has_data() moved to header as static inline
  for inlining — uses offset-based access verified by _Static_assert
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 14:21:40 -10:00
J. Nick Koston 248061ab1f fix unterminated #ifdef USE_LWIP_FAST_SELECT in merge 2026-03-01 14:15:12 -10:00
J. Nick Koston fac328f2e0 Merge remote-tracking branch 'upstream/cache-lwip-sock-pointers' into integration 2026-03-01 14:13:21 -10:00
J. Nick Koston 9da23db21c [core] Cache lwip_sock pointers to simplify fast select hot path
Cache struct lwip_sock* pointers at socket registration time instead of
looking them up by fd on every iteration. The previous code stored file
descriptors and called lwip_socket_dbg_get_socket(fd) on every loop
iteration to convert each fd back to a pointer — only to read a single
field from it.

- register_socket(lwip_sock*) returns bool and hooks the callback
  internally — replaces the separate register_socket_fd + hook dance
- Hot loop iterates struct lwip_sock* directly instead of converting
  fds each iteration
- Socket::ready() uses the cached pointer instead of fd lookup
- esphome_lwip_hook_socket() takes struct lwip_sock* directly
- Null cached_sock_ on close to prevent post-close dereference
- socket_ready() tolerant of null pointer for safety
2026-03-01 14:12:41 -10:00
J. Nick Koston b987bcbec8 Merge branch 'cache-lwip-sock-pointers' into integration 2026-03-01 14:11:00 -10:00
J. Nick Koston f160a17617 restore removed comments in register/unregister_socket_fd
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 14:10:52 -10:00
J. Nick Koston 2aa750b5fc Merge branch 'cache-lwip-sock-pointers' into integration 2026-03-01 14:06:50 -10:00
J. Nick Koston 52cc24880c guards 2026-03-01 14:06:39 -10:00
J. Nick Koston bca53e35e1 fix merge conflict: remove stray #endif
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 14:04:08 -10:00
J. Nick Koston 0d54dc94ba Merge branch 'cache-lwip-sock-pointers' into integration
# Conflicts:
#	esphome/core/application.h
2026-03-01 13:59:55 -10:00
J. Nick Koston 9733c28c40 [core] Cache lwip_sock pointers to eliminate per-socket fd lookup in fast select hot path
In yield_with_select_(), the fast select path iterated all monitored
sockets and called esphome_lwip_socket_has_data(fd) for each one.
That C function called lwip_socket_dbg_get_socket(fd) — a cross-
compilation-unit call that can't be inlined because sockets[] is
static in lwip's sockets.c. The actual rcvevent check is ~4
instructions, but the lookup adds entry/retw window overhead on
Xtensa (~8-12 cycles per socket per loop iteration).

Now lwip_sock* pointers are cached at socket registration time and
stored directly in monitored_sockets_. The hot path iterates pointers
and reads rcvevent with no fd lookup. esphome_lwip_hook_socket() also
takes lwip_sock* directly, avoiding a redundant get_sock() call.

API split for fast select vs fallback select:
- register_socket(lwip_sock*) / unregister_socket(lwip_sock*)
- register_socket_fd(int fd) / unregister_socket_fd(int fd)

Chained on top of socket-devirtualize (#14398).
2026-03-01 13:38:25 -10:00
J. Nick Koston bb7d811865 Merge branch 'compile-time-has-overridden-loop' into integration 2026-03-01 12:12:07 -10:00
J. Nick Koston 836f403d53 reduce generated code 2026-03-01 12:11:44 -10:00
J. Nick Koston c876b95af5 Merge branch 'compile-time-has-overridden-loop' into integration
# Conflicts:
#	esphome/core/application.cpp
2026-03-01 12:08:14 -10:00