Skip to content

io_uring: add write_buffer_high_watermark for io_uring sockets#44666

Open
aburan28 wants to merge 1 commit intoenvoyproxy:mainfrom
aburan28:aburan28/io-uring-write-watermark
Open

io_uring: add write_buffer_high_watermark for io_uring sockets#44666
aburan28 wants to merge 1 commit intoenvoyproxy:mainfrom
aburan28:aburan28/io-uring-write-watermark

Conversation

@aburan28
Copy link
Copy Markdown

Commit Message

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.

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

  • Added unit tests (IoUringWorkerImplTest.WriteBufferHighWatermark and WriteSliceBufferHighWatermark) for both write overloads, exercising the cap, the short-write reporting via the socket handle, and the back-pressure release (injected Write completion) 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_features entry in changelogs/current.yaml under io_uring.

Platform Specific Features

io_uring (Linux >= 5.11).

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>
@aburan28 aburan28 requested a deployment to external-contributors April 27, 2026 00:31 — with GitHub Actions Waiting
@repokitteh-read-only
Copy link
Copy Markdown

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.

🐱

Caused by: #44666 was opened by aburan28.

see: more, trace.

@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #44666 was opened by aburan28.

see: more, trace.

@aburan28 aburan28 marked this pull request as ready for review April 27, 2026 01:29
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #44666 was ready_for_review by aburan28.

see: more, trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants