Skip to content

feat: add io_uring transport layer support#3328

Open
yanglimingcn wants to merge 1 commit into
apache:masterfrom
yanglimingcn:feature/io_uring
Open

feat: add io_uring transport layer support#3328
yanglimingcn wants to merge 1 commit into
apache:masterfrom
yanglimingcn:feature/io_uring

Conversation

@yanglimingcn
Copy link
Copy Markdown
Contributor

@yanglimingcn yanglimingcn commented Jun 3, 2026

Add a new io_uring-based transport layer (IouringTransport) as an alternative to the existing TCP and RDMA transports, following the same architectural patterns as the RDMA implementation.

Core implementation:

  • src/brpc/iouring/iouring_endpoint.h/cpp: IouringEndpoint (SocketUser subclass) that submits async read/write SQEs and reaps CQEs, with optional SQPOLL polling mode.
  • src/brpc/iouring/iouring_helper.h/cpp: global io_uring ring lifecycle management, per-bthread-tag poller threads, and availability checks.
  • src/brpc/iouring_transport.h/cpp: IouringTransport (Transport interface) wiring Init/Release/Reset/Connect/CutFromIOBuf(List)/ WaitEpollOut/ProcessEvent/QueueMessage/Debug/ContextInitOrDie.

Build system integration:

  • CMakeLists.txt: BRPC_WITH_IOURING option; find_package(liburing); conditionally compile iouring sources and link -luring.
  • BUILD.bazel / bazel/config/BUILD.bazel: brpc_with_iouring config_setting; conditional srcs/defines/linkopts/deps.
  • WORKSPACE: new_local_repository for @com_github_axboe_liburing.
  • bazel/third_party/liburing/liburing.BUILD: cc_library target for liburing.

Framework hooks:

  • src/brpc/socket_mode.h: add SOCKET_MODE_IOURING enum value.
  • src/brpc/transport_factory.cpp: register IouringTransport in TransportFactory::Create().
  • src/brpc/socket.h: friend declarations for IouringEndpoint / IouringTransport.
  • src/brpc/input_messenger.h: friend declarations for IouringEndpoint / IouringTransport.

Bug fixes:

  • src/butil/single_threaded_pool.h: rename static member BLOCK_SIZE to POOL_BLOCK_SIZE to avoid conflict with the BLOCK_SIZE macro defined by <linux/fs.h> (pulled in via liburing.h).
  • src/brpc/iouring_transport.cpp: move DECLARE_bool(usercode_in_*) inside namespace brpc{} to match the DEFINE_bool site in event_dispatcher.cpp, fixing linker undefined-reference errors.

Example and documentation:

  • example/iouring_performance/: server, client, proto, CMakeLists.txt mirroring the rdma_performance example; supports WITH_IOURING=1 make flag.
  • example/BUILD.bazel: Bazel targets for the new example.
  • docs/cn/iouring.md: Chinese-language guide covering build, flags, architecture and comparison with RDMA.

What problem does this PR solve?

Issue Number:

#1650
#3212

Problem Summary:

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Add a new io_uring-based transport layer (IouringTransport) as an
alternative to the existing TCP and RDMA transports, following the
same architectural patterns as the RDMA implementation.

Core implementation:
- src/brpc/iouring/iouring_endpoint.h/cpp: IouringEndpoint (SocketUser
  subclass) that submits async read/write SQEs and reaps CQEs, with
  optional SQPOLL polling mode.
- src/brpc/iouring/iouring_helper.h/cpp: global io_uring ring lifecycle
  management, per-bthread-tag poller threads, and availability checks.
- src/brpc/iouring_transport.h/cpp: IouringTransport (Transport
  interface) wiring Init/Release/Reset/Connect/CutFromIOBuf(List)/
  WaitEpollOut/ProcessEvent/QueueMessage/Debug/ContextInitOrDie.

Build system integration:
- CMakeLists.txt: BRPC_WITH_IOURING option; find_package(liburing);
  conditionally compile iouring sources and link -luring.
- BUILD.bazel / bazel/config/BUILD.bazel: brpc_with_iouring
  config_setting; conditional srcs/defines/linkopts/deps.
- WORKSPACE: new_local_repository for @com_github_axboe_liburing.
- bazel/third_party/liburing/liburing.BUILD: cc_library target for
  liburing.

Framework hooks:
- src/brpc/socket_mode.h: add SOCKET_MODE_IOURING enum value.
- src/brpc/transport_factory.cpp: register IouringTransport in
  TransportFactory::Create().
- src/brpc/socket.h: friend declarations for IouringEndpoint /
  IouringTransport.
- src/brpc/input_messenger.h: friend declarations for IouringEndpoint /
  IouringTransport.

Bug fixes:
- src/butil/single_threaded_pool.h: rename static member BLOCK_SIZE to
  POOL_BLOCK_SIZE to avoid conflict with the BLOCK_SIZE macro defined
  by <linux/fs.h> (pulled in via liburing.h).
- src/brpc/iouring_transport.cpp: move DECLARE_bool(usercode_in_*)
  inside namespace brpc{} to match the DEFINE_bool site in
  event_dispatcher.cpp, fixing linker undefined-reference errors.

Example and documentation:
- example/iouring_performance/: server, client, proto, CMakeLists.txt
  mirroring the rdma_performance example; supports WITH_IOURING=1 make
  flag.
- example/BUILD.bazel: Bazel targets for the new example.
- docs/cn/iouring.md: Chinese-language guide covering build, flags,
  architecture and comparison with RDMA.
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