Skip to content

Commit a38078d

Browse files
bdracoCopilot
andauthored
[esp32] Document LWIP core locking options for improved socket performance (#5169)
Co-authored-by: Copilot <[email protected]>
1 parent 4a7e3dc commit a38078d

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

components/esp32.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,45 @@ Advanced Configuration
140140

141141
**LWIP Optimization Options (ESP-IDF only):**
142142

143-
The following options are available under the ``advanced`` section when using the ESP-IDF framework to disable unused
144-
LWIP (Lightweight IP) features and save flash memory (approximately 4KB):
143+
The following options are available under the ``advanced`` section when using the ESP-IDF framework to optimize
144+
LWIP (Lightweight IP) behavior. Some options improve performance while others save flash memory:
145145

146146
- **enable_lwip_dhcp_server** (*Optional*, boolean): Enable DHCP server functionality. Only needed if the device will act
147147
as a DHCP server (necessary for WiFi AP mode). When the WiFi component is used, it automatically handles enabling/disabling
148148
the DHCP server based on whether AP mode is configured. When WiFi is not used, defaults to ``false``.
149-
- **enable_lwip_mdns_queries** (*Optional*, boolean): Enable mDNS query support in the DNS resolver. ESPHome uses its own
150-
mDNS implementation, so this is rarely needed. Defaults to ``true``.
149+
- **enable_lwip_mdns_queries** (*Optional*, boolean): Enable mDNS query support in the DNS resolver. This allows resolving
150+
local hostnames (like ``broker.local``) for MQTT brokers and other services. While ESPHome has its own mDNS responder
151+
for advertising, this option is needed for resolving mDNS names. Defaults to ``true``.
151152
- **enable_lwip_bridge_interface** (*Optional*, boolean): Enable bridge interface support for bridging multiple network
152153
interfaces. Defaults to ``false``.
154+
- **enable_lwip_tcpip_core_locking** (*Optional*, boolean): Enable LWIP TCP/IP core locking for better socket performance.
155+
This uses direct function calls with mutex protection instead of mailbox message passing between threads. Enabling this
156+
improves socket operation performance by 20-200% but may reduce multi-threaded scalability. Defaults to ``true``.
157+
- **enable_lwip_check_thread_safety** (*Optional*, boolean): Enable LWIP thread safety checks to detect incorrect usage of
158+
the TCP/IP stack from multiple threads. This helps catch thread safety issues when core locking is enabled. Defaults to ``true``.
153159

154-
These optimizations are applied automatically and save flash memory without affecting typical ESPHome functionality. The
155-
features can be enabled if needed by setting the corresponding option to ``true``.
160+
Some options can be disabled to save flash memory without affecting typical ESPHome functionality. The performance
161+
options (defaulting to ``true``) improve socket operation performance but can be disabled if you need better
162+
multi-threaded scalability (which is uncommon since ESPHome uses an event loop).
163+
164+
**Example configuration with advanced LWIP options:**
165+
166+
.. code-block:: yaml
167+
168+
# Example configuration entry
169+
esp32:
170+
board: esp32dev
171+
framework:
172+
type: esp-idf
173+
advanced:
174+
# Performance options (enabled by default)
175+
enable_lwip_tcpip_core_locking: true # Better socket performance
176+
enable_lwip_check_thread_safety: true # Thread safety validation
177+
178+
# Memory saving options
179+
enable_lwip_dhcp_server: false # Disabled by default, only needed for AP mode
180+
enable_lwip_mdns_queries: false # Enabled by default, can disable if not using .local hostnames
181+
enable_lwip_bridge_interface: false # Disabled by default
156182
157183
.. _esp32-idf_components:
158184

0 commit comments

Comments
 (0)