-
Notifications
You must be signed in to change notification settings - Fork 873
feat: support io_uring #366
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
Changes from all commits
f1a87a2
73682b1
b28bf40
ab90d17
67331b8
66dfb72
9c95da0
f455867
e28c035
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -33,6 +33,9 @@ | |||||||
import io.netty.channel.socket.SocketChannel; | ||||||||
import io.netty.channel.socket.nio.NioServerSocketChannel; | ||||||||
import io.netty.channel.socket.nio.NioSocketChannel; | ||||||||
import io.netty.incubator.channel.uring.IOUringEventLoopGroup; | ||||||||
import io.netty.incubator.channel.uring.IOUringServerSocketChannel; | ||||||||
import io.netty.incubator.channel.uring.IOUringSocketChannel; | ||||||||
funky-eyes marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
||||||||
/** | ||||||||
* Utils for netty EventLoop | ||||||||
|
@@ -43,7 +46,10 @@ | |||||||
public class NettyEventLoopUtil { | ||||||||
|
||||||||
/** check whether epoll enabled, and it would not be changed during runtime. */ | ||||||||
private static boolean epollEnabled = ConfigManager.netty_epoll() && Epoll.isAvailable(); | ||||||||
private static final boolean epollEnabled = ConfigManager.netty_epoll() | ||||||||
&& Epoll.isAvailable(); | ||||||||
|
||||||||
private static final boolean ioUringEnabled = ConfigManager.netty_io_uring(); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure io_uring support is available before enabling The Apply this change to include the availability check: -private static final boolean ioUringEnabled = ConfigManager.netty_io_uring();
+private static final boolean ioUringEnabled = ConfigManager.netty_io_uring()
+ && IOUring.isAvailable(); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: build[error] 62: Cannot find symbol: class IOUringEventLoopGroup [error] 71: Cannot find symbol: class IOUringSocketChannel [error] 79: Cannot find symbol: class IOUringServerSocketChannel There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @funky-eyes You're absolutely right. After reviewing the implementation more carefully, I see that my suggestion was incorrect. The current approach of only checking the configuration flag is appropriate because:
Thank you for the correction! 🔗 Analysis chain@funky-eyes I apologize for my mistake. You are correct - I made an incorrect assumption about the existence of 🏁 Scripts executedThe following scripts were executed for the analysis: Script:
Length of output: 109 Script:
Length of output: 1670 Script:
Length of output: 472 ✏️ Learnings added
|
||||||||
|
||||||||
/** | ||||||||
* Create the right event loop according to current platform and system property, fallback to NIO when epoll not enabled. | ||||||||
|
@@ -53,22 +59,25 @@ public class NettyEventLoopUtil { | |||||||
* @return an EventLoopGroup suitable for the current platform | ||||||||
*/ | ||||||||
public static EventLoopGroup newEventLoopGroup(int nThreads, ThreadFactory threadFactory) { | ||||||||
return epollEnabled ? new EpollEventLoopGroup(nThreads, threadFactory) | ||||||||
: new NioEventLoopGroup(nThreads, threadFactory); | ||||||||
return ioUringEnabled ? new IOUringEventLoopGroup(nThreads, threadFactory) | ||||||||
: epollEnabled ? new EpollEventLoopGroup(nThreads, threadFactory) | ||||||||
: new NioEventLoopGroup(nThreads, threadFactory); | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* @return a SocketChannel class suitable for the given EventLoopGroup implementation | ||||||||
*/ | ||||||||
public static Class<? extends SocketChannel> getClientSocketChannelClass() { | ||||||||
return epollEnabled ? EpollSocketChannel.class : NioSocketChannel.class; | ||||||||
return ioUringEnabled ? IOUringSocketChannel.class | ||||||||
: epollEnabled ? EpollSocketChannel.class : NioSocketChannel.class; | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* @return a ServerSocketChannel class suitable for the given EventLoopGroup implementation | ||||||||
*/ | ||||||||
public static Class<? extends ServerSocketChannel> getServerSocketChannelClass() { | ||||||||
return epollEnabled ? EpollServerSocketChannel.class : NioServerSocketChannel.class; | ||||||||
return ioUringEnabled ? IOUringServerSocketChannel.class | ||||||||
: epollEnabled ? EpollServerSocketChannel.class : NioServerSocketChannel.class; | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
|
@@ -77,7 +86,7 @@ public static Class<? extends ServerSocketChannel> getServerSocketChannelClass() | |||||||
* @param serverBootstrap server bootstrap | ||||||||
*/ | ||||||||
public static void enableTriggeredMode(ServerBootstrap serverBootstrap) { | ||||||||
if (epollEnabled) { | ||||||||
if (!ioUringEnabled && epollEnabled) { | ||||||||
if (ConfigManager.netty_epoll_lt_enabled()) { | ||||||||
serverBootstrap.childOption(EpollChannelOption.EPOLL_MODE, | ||||||||
EpollMode.LEVEL_TRIGGERED); | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Document IO_uring requirements and upgrade Netty version
Add IO_uring transport requirements to documentation:
Security recommendations:
🔗 Analysis chain
Document runtime requirements for IO_uring support.
The IO_uring transport is provided at runtime and requires specific Linux kernel version (5.9+). Consider adding this information to the project documentation.
Also, verify security advisories for both Netty dependencies:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1207
Script:
Length of output: 818
Script:
Length of output: 13061