Add a comment to EventPool documenting that when paired with a
LockFreeQueue<T, N>, the pool should be sized to N-1 (the queue's
actual capacity) to prevent slot leaks and SPSC violations.
LockFreeQueue<T,N> is a ring buffer that holds N-1 elements (one slot
is reserved to distinguish full from empty). With the pool also sized
to N, the Nth allocate() succeeds but push() fails — permanently
leaking one pool slot since the element is never returned.
Size both receive and send pools to N-1 to match queue capacity.
LockFreeQueue<T,N> is a ring buffer that holds N-1 elements (one slot
is reserved to distinguish full from empty). With the pool also sized
to N, the Nth allocate() succeeds but push() fails — permanently
leaking one pool slot since the element is never returned.
Size the pool to N-1 to match queue capacity. This guarantees
allocate() returns nullptr before push() can fail.
The ESP-IDF MQTT client dispatches events from its own task, which
pushed to a std::queue while the main loop popped from it. std::queue
is not thread-safe; concurrent access can corrupt its internal state.
Replace with EventPool + LockFreeQueue (SPSC ring buffer) already
used elsewhere in the codebase. The pool is sized to queue capacity
(SIZE-1) so allocate() fails before push() can, which prevents both
a slot leak and an SPSC violation on the pool's free list.
Also rename the outbound pool from mqtt_event_pool_ to
mqtt_outbound_pool_ to avoid confusion with the new inbound pool.
Replace fnv1_hash(str1 + str2) with fnv1_hash_extend(fnv1_hash(str1), str2)
to avoid constructing temporary std::string objects just to compute a hash.
This eliminates the only callers of operator+(const char*, StringRef),
allowing the linker to drop 197 bytes of string concatenation code.
Move ESP32BLE::is_active() and BLEServer::is_running() to headers
with ESPHOME_ALWAYS_INLINE to eliminate cross-TU call overhead on
every loop iteration. Replace std::remove_if + erase in
BLEServer::loop() with a simple index-based compacting loop,
removing ~250 bytes of unrolled STL template machinery.
Move ESP32BLE::is_active() and BLEServer::is_running() to headers
with ESPHOME_ALWAYS_INLINE to eliminate cross-TU call overhead on
every loop iteration. Replace std::remove_if + erase in
BLEServer::loop() with a simple index-based compacting loop,
removing ~250 bytes of unrolled STL template machinery.
Add a new `sram1_as_iram` option under `esp32 > framework > advanced`
that enables CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM, reclaiming
40KB of SRAM1 memory as additional IRAM on the original ESP32.
This requires a bootloader from ESP-IDF v5.1 or later. USB flashing
updates the bootloader automatically, but OTA does not. At boot,
ESPHome now detects the bootloader version and suggests enabling
this option when the bootloader is compatible.
Add a new `sram1_as_iram` option under `esp32 > framework > advanced`
that enables CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM, reclaiming
40KB of SRAM1 memory as additional IRAM on the original ESP32.
This requires a bootloader from ESP-IDF v5.1 or later. USB flashing
updates the bootloader automatically, but OTA does not. At boot,
ESPHome now detects the bootloader version and suggests enabling
this option when the bootloader is compatible.
Add a new `sram1_as_iram` option under `esp32 > framework > advanced`
that enables CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM, reclaiming
40KB of SRAM1 memory as additional IRAM on the original ESP32.
This requires a bootloader from ESP-IDF v5.1 or later. USB flashing
updates the bootloader automatically, but OTA does not. At boot,
ESPHome now detects the bootloader version and suggests enabling
this option when the bootloader is compatible.
Add a new `sram1_as_iram` option under `esp32 > framework > advanced`
that enables CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM, reclaiming
40KB of SRAM1 memory as additional IRAM on the original ESP32.
This requires a bootloader from ESP-IDF v5.1 or later. USB flashing
updates the bootloader automatically, but OTA does not. At boot,
ESPHome now detects the bootloader version and suggests enabling
this option when the bootloader is compatible.
- Save errno into local before check_socket_write_err_ and HELPER_LOG
to avoid potential clobbering between reads
- Update try_drain() doc: 0 means all-drained or no-progress (callers
only act on -1)
- Include socket/headers.h explicitly for struct iovec
- Move HELPER_LOG after errno check so transient WOULD_BLOCK doesn't
spam very-verbose logs during normal backpressure
- Fix try_drain() docstring: -1 can be EWOULDBLOCK or hard error
(caller distinguishes via errno), 0 means no progress (not would-block)