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

Support netty io_uring #1405

Closed

Conversation

wangchengming666
Copy link
Collaborator

@wangchengming666 wangchengming666 commented Mar 18, 2024

related #1349

Summary by CodeRabbit

  • New Features
    • Introduced an option to utilize io_uring for improved transport performance.
  • Refactor
    • Enhanced transport layer to dynamically select channel implementation for better flexibility and efficiency.
  • Tests
    • Added tests to ensure the reliability of the new dynamic channel selection mechanism.

@sofastack-cla sofastack-cla bot added cla:yes CLA is ok size/L labels Mar 18, 2024
Copy link
Contributor

coderabbitai bot commented Mar 18, 2024

Important

Auto Review Skipped

Review was skipped due to path filters

Files ignored due to path filters (1)
  • bom/pom.xml is excluded by !**/*.xml

Walkthrough

This update introduces the experimental support for io_uring in the transport layer of SOFARPC, enhancing the network communication efficiency by dynamically selecting between io_uring, Epoll, and Nio. It refactors the channel selection process and adds tests to ensure the functionality of the new transport mechanism.

Changes

File Path Change Summary
core/api/.../RpcOptions.java Added TRANSPORT_USE_IO_URING constant
remoting/.../AbstractHttp2ClientTransport.java Use NettyHelper.socketChannel() for channel selection
remoting/.../NettyHelper.java Added IOUring support; dynamic event loop group and socket channel selection
remoting/.../NettyHelperTest.java New tests for NettyHelper functionalities

Related issues

🐰✨
A leap in the dark, a bold new start,
With io_uring, we smartly dart.
Through the net, our packets fly,
Faster than the blinking of an eye.
In the warren, excitement rings,
For the future, what it brings. 🌟
🐰✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ac2a73e and d6b0a91.
Files ignored due to path filters (2)
  • bom/pom.xml is excluded by: !**/*.xml
  • remoting/remoting-http/pom.xml is excluded by: !**/*.xml
Files selected for processing (4)
  • core/api/src/main/java/com/alipay/sofa/rpc/common/RpcOptions.java (1 hunks)
  • remoting/remoting-http/src/main/java/com/alipay/sofa/rpc/transport/http/AbstractHttp2ClientTransport.java (2 hunks)
  • remoting/remoting-http/src/main/java/com/alipay/sofa/rpc/transport/netty/NettyHelper.java (3 hunks)
  • remoting/remoting-http/src/test/java/com/alipay/sofa/rpc/transport/netty/NettyHelperTest.java (1 hunks)
Additional comments: 3
remoting/remoting-http/src/main/java/com/alipay/sofa/rpc/transport/netty/NettyHelper.java (1)
  • 218-227: The socketChannel method dynamically selects the socket channel class based on configuration flags and system capabilities. Adding documentation to clarify the selection process for the socket channel class would enhance code readability and maintainability.
remoting/remoting-http/src/main/java/com/alipay/sofa/rpc/transport/http/AbstractHttp2ClientTransport.java (1)
  • 146-146: The change to dynamically select the channel class using NettyHelper.socketChannel() aligns with the PR's objectives and enhances the flexibility of the transport layer. This is a good practice that allows for better adaptability to different environments and configurations.
core/api/src/main/java/com/alipay/sofa/rpc/common/RpcOptions.java (1)
  • 399-404: The addition of the TRANSPORT_USE_IO_URING constant is well-aligned with the existing codebase conventions and the PR's objectives to introduce io_uring support. The naming, documentation, and placement within the file are appropriate.

Comment on lines +38 to +52
@Test
public void testEventLoopGroup() {
System.setProperty("os.name", "linux111");
System.setProperty(TRANSPORT_USE_IO_URING, "true");

EventLoopGroup eventLoopGroup = NettyHelper.eventLoopGroup(1, new NamedThreadFactory("test", true));
Class<? extends SocketChannel> socketChannel = NettyHelper.socketChannel();
if (IOUring.isAvailable()) {
Assert.assertTrue(eventLoopGroup instanceof IOUringEventLoopGroup);
Assert.assertEquals(IOUringSocketChannel.class, socketChannel);
} else {
Assert.assertTrue(eventLoopGroup instanceof NioEventLoopGroup);
Assert.assertEquals(NioSocketChannel.class, socketChannel);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manipulating system properties directly within a test can lead to unintended side effects, especially when tests are run in parallel. Consider using a setup and teardown approach to ensure system properties are reset after the test. Additionally, it would be beneficial to include test scenarios that cover cases when io_uring is not available or when running on a non-Linux system to ensure comprehensive coverage.

Comment on lines +206 to +215
public synchronized static EventLoopGroup eventLoopGroup(int threads, NamedThreadFactory threadName) {
boolean useEpoll = getBooleanValue(TRANSPORT_USE_EPOLL);
boolean useIoUring = getBooleanValue(TRANSPORT_USE_IO_URING);
if (useEpoll) {
return new EpollEventLoopGroup(threads, threadName);
} else if (useIoUring && SystemInfo.isLinux() && IOUring.isAvailable()) {
return new IOUringEventLoopGroup(threads, threadName);
} else {
return new NioEventLoopGroup(threads, threadName);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The eventLoopGroup method dynamically selects the event loop group based on configuration flags and system capabilities. It would be beneficial to add documentation explaining the precedence of useEpoll over useIoUring and under what conditions each is used. Additionally, consider handling the case where both useEpoll and useIoUring are false more explicitly to improve code clarity.

@Lo1nt
Copy link
Collaborator

Lo1nt commented Mar 25, 2024

看一下dubbo的issue Introduce I/O URing to netty4 remoting
就不引用了

Copy link

stale bot commented May 27, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label May 27, 2024
@stale stale bot closed this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes CLA is ok size/L wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants