io_uring: add write_buffer_high_watermark for io_uring sockets#44666
Open
aburan28 wants to merge 1 commit intoenvoyproxy:mainfrom
Open
io_uring: add write_buffer_high_watermark for io_uring sockets#44666aburan28 wants to merge 1 commit intoenvoyproxy:mainfrom
aburan28 wants to merge 1 commit intoenvoyproxy:mainfrom
Conversation
Expose ``IoUringOptions.write_buffer_high_watermark`` to bound the size of ``IoUringServerSocket::write_buf_``. Without a cap, the upper layer always sees writes as fully accepted (because the io_uring socket is async and stages bytes internally), so connection-level back-pressure -- and overload protections that depend on it, e.g. HTTP flood protection -- never engages. When the new field is set to a non-zero value, ``IoUringServerSocket::write`` returns a short write once ``write_buf_`` reaches the configured size, and ``IoUringSocketHandleImpl::write`` reports the actual bytes moved (rather than the original buffer length). The upper layer's connection-level write buffer holds the remainder, where the existing watermark mechanism applies. After the in-flight write completes and the buffer drops below the threshold, an injected Write completion is delivered so the upper layer retries. The default of 0 disables the cap and preserves the previous (uncapped) behavior. Resolves the existing TODO in ``IoUringServerSocket`` referencing the ``IntegrationTest.TestFloodUpstreamErrors`` timeout. Risk Level: Low Testing: Added unit tests for the buffer- and slice-based ``write`` overloads, including the back-pressure release on completion. Docs Changes: New field documented inline in the proto. Release Notes: Added. Platform Specific Features: io_uring (Linux >=5.11) Signed-off-by: Adam Buran <aburan28@gmail.com>
|
Hi @aburan28, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
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.
Commit Message
Expose
IoUringOptions.write_buffer_high_watermarkto bound the size ofIoUringServerSocket::write_buf_.Without a cap, the upper layer always sees writes as fully accepted (because the io_uring socket is async and stages bytes internally), so connection-level back-pressure — and overload protections that depend on it, e.g. HTTP flood protection — never engages.
When the new field is set to a non-zero value,
IoUringServerSocket::writereturns a short write oncewrite_buf_reaches the configured size, andIoUringSocketHandleImpl::writereports the actual bytes moved (rather than the original buffer length). The upper layer's connection-level write buffer holds the remainder, where the existing watermark mechanism applies. After the in-flight write completes and the buffer drops below the threshold, an injected Write completion is delivered so the upper layer retries.The default of 0 disables the cap and preserves the previous (uncapped) behavior. Resolves the existing TODO in
IoUringServerSocketreferencing theIntegrationTest.TestFloodUpstreamErrorstimeout.Additional Description
This is a draft PR opened for review and discussion. The new field is opt-in (default 0) so existing deployments are unaffected.
Risk Level
Low — opt-in via a new config field; default-0 path preserves the previous (uncapped) behavior. Behavior change only kicks in when the field is set to a non-zero value.
Testing
IoUringWorkerImplTest.WriteBufferHighWatermarkandWriteSliceBufferHighWatermark) for bothwriteoverloads, exercising the cap, the short-write reporting via the socket handle, and the back-pressure release (injectedWritecompletion) when the in-flight write completes.Docs Changes
New field is documented inline in
api/envoy/extensions/network/socket_interface/v3/default_socket_interface.proto.Release Notes
Added a
new_featuresentry inchangelogs/current.yamlunderio_uring.Platform Specific Features
io_uring (Linux >= 5.11).