Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io_uring: update API and docs #38677

Merged
merged 8 commits into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE;

// Configuration for default socket interface that relies on OS dependent syscall to create
// sockets.
// [#next-free-field: 6]
message DefaultSocketInterface {
// io_uring options. io_uring is only valid in Linux with at least kernel version 5.11.
IoUringOptions io_uring = 1;
}

// [#next-free-field: 6]
message IoUringOptions {
// Enable io_uring for socket operations if the kernel supports. io_uring is only valid in
// Linux with at least kernel version 5.6. Otherwise, Envoy will fall back to use the default
// Linux with at least kernel version 5.11. Otherwise, Envoy will fall back to use the default
// socket operations. The default is false.
bool enable_io_uring = 1;
bool enable = 1;

// The size for io_uring submission queues (SQ). io_uring is built with a fixed size in each
// thread during configuration, and each io_uring operation creates a submission queue
Expand All @@ -31,15 +36,15 @@ message DefaultSocketInterface {
// Enable io_uring submission queue polling (SQPOLL). io_uring SQPOLL mode polls all SQEs in the
// SQ in the kernel thread. io_uring SQPOLL mode may reduce latency and increase CPU usage as a
// cost. The default is false.
bool enable_io_uring_submission_queue_polling = 3;
bool enable_submission_queue_polling = 3;

// The size of an io_uring socket's read buffer. Each io_uring read operation will allocate a
// buffer of the given size. If the given buffer is too small, the socket will have read multiple
// times for all the data. The default is 8192.
google.protobuf.UInt32Value io_uring_read_buffer_size = 4;
google.protobuf.UInt32Value read_buffer_size = 4;

// The write timeout of an io_uring socket on closing in ms. io_uring writes and closes
// asynchronously. If the remote stops reading, the io_uring write operation may never complete.
// The operation is canceled and the socket is closed after the timeout. The default is 1000.
google.protobuf.UInt32Value io_uring_write_timeout_ms = 5;
google.protobuf.UInt32Value write_timeout_ms = 5;
}
4 changes: 2 additions & 2 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ new_features:
``envoy.tcp_proxy.receive_before_connect``.
- area: sockets
change: |
Added :ref:`enable_io_uring <envoy_v3_api_field_extensions.network.socket_interface.v3.DefaultSocketInterface.enable_io_uring>` to
support io_uring.
Added an :ref:`io_uring <envoy_v3_api_field_extensions.network.socket_interface.v3.DefaultSocketInterface.io_uring>` option in default
socket interface to support io_uring.

deprecated:
11 changes: 6 additions & 5 deletions source/common/network/socket_interface_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ Server::BootstrapExtensionPtr SocketInterfaceImpl::createBootstrapExtension(
const auto& message = MessageUtil::downcastAndValidate<
const envoy::extensions::network::socket_interface::v3::DefaultSocketInterface&>(
config, context.messageValidationVisitor());
if (message.enable_io_uring() && Io::isIoUringSupported()) {
const auto& io_uring_options = message.io_uring();
if (io_uring_options.enable() && Io::isIoUringSupported()) {
std::shared_ptr<Io::IoUringWorkerFactoryImpl> io_uring_worker_factory =
std::make_shared<Io::IoUringWorkerFactoryImpl>(
PROTOBUF_GET_WRAPPED_OR_DEFAULT(message, io_uring_size, 1000),
message.enable_io_uring_submission_queue_polling(),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(message, io_uring_read_buffer_size, 8192),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(message, io_uring_write_timeout_ms, 1000),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(io_uring_options, io_uring_size, 1000),
io_uring_options.enable_submission_queue_polling(),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(io_uring_options, read_buffer_size, 8192),
PROTOBUF_GET_WRAPPED_OR_DEFAULT(io_uring_options, write_timeout_ms, 1000),
context.threadLocal());
io_uring_worker_factory_ = io_uring_worker_factory;

Expand Down
3 changes: 2 additions & 1 deletion test/integration/socket_interface_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class SocketInterfaceIntegrationTest : public BaseIntegrationTest,
- name: envoy.extensions.network.socket_interface.default_socket_interface
typed_config:
"@type": type.googleapis.com/envoy.extensions.network.socket_interface.v3.DefaultSocketInterface
enable_io_uring: %s
io_uring:
enable: %s
default_socket_interface: "envoy.extensions.network.socket_interface.default_socket_interface"
)EOF",
enable_io_uring ? "true" : "false"));
Expand Down
Loading