Skip to content

Increase event queue size#5

Closed
willmmiles wants to merge 2 commits intopbolduc:masterfrom
willmmiles:fix-event-queue-size
Closed

Increase event queue size#5
willmmiles wants to merge 2 commits intopbolduc:masterfrom
willmmiles:fix-event-queue-size

Conversation

@willmmiles
Copy link
Copy Markdown

I'm working on stabilizing ESPAsyncWebServer for WLED, and I ran in to a problem with AsyncTCP deadlocking under load (>5 inbound connections). The issue turned out to be that the event queue overflowed, resulting in the lwip task blocking to put something in the queue, while the async service task was in turn blocked waiting for lwip to service a synchronous tcpip_api_call().

Since there doesn't seem to be a reasonable way to handle a queue overflow in this architecture -- discarding the overflowing event could confuse the state machine, resulting in leaked objects and connections -- I've oped to increase the queue size until it's big enough that I can fill service CONFIG_LWIP_MAX_ACTIVE_TCP connections without locking up. Empirical testing suggested this seemed to work well at 4 events per connection.

This patch set restores the existing CONFIG_ASYNC_TCP_EVENT_QUEUE_SIZE to operation, and then increases the default size.

If the queue size is too small, the tasks can deadlock when the IP task
needs to queue an event, but the service task is trying to execute an IP
stack call.  Raise the queue size to avoid this case; 4 events per
connection seems to be enough.
willmmiles referenced this pull request in willmmiles/AsyncTCP Jan 25, 2025
Co-authored-by: Paweł pidpawel Kozubal <pawel.kozubal@husarnet.com>
willmmiles referenced this pull request in willmmiles/AsyncTCP Feb 5, 2025
Fix compilation warnings when using LTO
@willmmiles willmmiles closed this Jul 26, 2025
@willmmiles willmmiles deleted the fix-event-queue-size branch July 26, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant