AsyncEventSource queue management - #480
Open
willmmiles wants to merge 3 commits into
Open
willmmiles wants to merge 3 commits into
willmmiles wants to merge 3 commits into
Conversation
Track when we've filled the underlying socket and stop until we receive an ack. Reduces CPU usage blindly retrying when the buffer is full. Also fixes a correctness issue where a _runQueue which partially sends a message will still attempt to send the next message, which will tear if an ack arrives in between writes.
Drop redundant space check prior to attempting data send. add() has to check for available space internally, interlocked with the TCP layer; the additional check just wastes time.
As we are committed to ASYNC_WRITE_FLAG_COPY, we can release written event messages as soon as they are accepted by the TCP socket. Originally implemented in: - esphome#41 - mathieucarbou/ESPAsyncWebServer#92 Reverted by 43e0b5c in the hopes of supporting zero-copy TCP writes, but (as noted in that commit!) they are not supported on any Espressif platform, so the additional complexity buys no benefit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some fixes and performance improvements to
AsyncEventSourcethat fell out duringAsyncTCPregression testing._runQueuein this sequence:_runQueuefills the output buffer with a partial frameasyncthread - the space is made available as soon as it touches LwIP`_runQueuestill considers the next message, sending a part of the next messagewrite()reduces round trips with the LwIP core.