|
73 | 73 | import io.netty.channel.kqueue.KQueueSocketChannel; |
74 | 74 | import io.netty.channel.nio.NioIoHandler; |
75 | 75 | import io.netty.channel.socket.nio.NioSocketChannel; |
| 76 | +import io.netty.channel.uring.IoUringIoHandler; |
| 77 | +import io.netty.channel.uring.IoUringSocketChannel; |
76 | 78 | import io.netty.handler.codec.base64.Base64; |
77 | 79 | import io.netty.handler.codec.http.DefaultFullHttpRequest; |
78 | 80 | import io.netty.handler.codec.http.DefaultHttpRequest; |
@@ -137,6 +139,7 @@ public class NettyConnector extends AbstractConnector { |
137 | 139 | public static String NIO_CONNECTOR_TYPE = "NIO"; |
138 | 140 | public static String EPOLL_CONNECTOR_TYPE = "EPOLL"; |
139 | 141 | public static String KQUEUE_CONNECTOR_TYPE = "KQUEUE"; |
| 142 | + public static String IOURING_CONNECTOR_TYPE = "IO_URING"; |
140 | 143 |
|
141 | 144 | private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); |
142 | 145 |
|
@@ -295,6 +298,8 @@ public class NettyConnector extends AbstractConnector { |
295 | 298 |
|
296 | 299 | private boolean useKQueue; |
297 | 300 |
|
| 301 | + private boolean useIoUring; |
| 302 | + |
298 | 303 | private int remotingThreads; |
299 | 304 |
|
300 | 305 | private boolean useGlobalWorkerPool; |
@@ -404,6 +409,7 @@ public NettyConnector(final Map<String, Object> configuration, |
404 | 409 |
|
405 | 410 | useEpoll = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_EPOLL_PROP_NAME, TransportConstants.DEFAULT_USE_EPOLL, configuration); |
406 | 411 | useKQueue = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_KQUEUE_PROP_NAME, TransportConstants.DEFAULT_USE_KQUEUE, configuration); |
| 412 | + useIoUring = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_IOURING_PROP_NAME, TransportConstants.DEFAULT_USE_IOURING, configuration); |
407 | 413 |
|
408 | 414 | useServlet = ConfigurationHelper.getBooleanProperty(TransportConstants.USE_SERVLET_PROP_NAME, TransportConstants.DEFAULT_USE_SERVLET, configuration); |
409 | 415 | host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME, TransportConstants.DEFAULT_HOST, configuration); |
@@ -528,14 +534,30 @@ public synchronized void start() { |
528 | 534 | return; |
529 | 535 | } |
530 | 536 |
|
531 | | - if (remotingThreads == -1) { |
| 537 | + boolean defaultRemotingThreads = remotingThreads == -1; |
| 538 | + |
| 539 | + if (defaultRemotingThreads) { |
532 | 540 | // Default to number of cores * 3 |
533 | 541 | remotingThreads = Runtime.getRuntime().availableProcessors() * 3; |
534 | 542 | } |
535 | 543 |
|
536 | 544 | String connectorType; |
537 | 545 |
|
538 | | - if (useEpoll && CheckDependencies.isEpollAvailable()) { |
| 546 | + if (useIoUring && CheckDependencies.isIoUringAvailable()) { |
| 547 | + //IO_URING should default to 1 remotingThread unless specified in config |
| 548 | + remotingThreads = defaultRemotingThreads ? 1 : remotingThreads; |
| 549 | + |
| 550 | + if (useGlobalWorkerPool) { |
| 551 | + group = SharedEventLoopGroup.getInstance((threadFactory -> new MultiThreadIoEventLoopGroup(remotingThreads, threadFactory, IoUringIoHandler.newFactory()))); |
| 552 | + } else { |
| 553 | + group = new MultiThreadIoEventLoopGroup(remotingThreads, IoUringIoHandler.newFactory()); |
| 554 | + } |
| 555 | + |
| 556 | + connectorType = IOURING_CONNECTOR_TYPE; |
| 557 | + channelClazz = IoUringSocketChannel.class; |
| 558 | + |
| 559 | + logger.debug("Connector {} using native io_uring", this); |
| 560 | + } else if (useEpoll && CheckDependencies.isEpollAvailable()) { |
539 | 561 | if (useGlobalWorkerPool) { |
540 | 562 | group = SharedEventLoopGroup.getInstance((threadFactory -> new MultiThreadIoEventLoopGroup(remotingThreads, threadFactory, EpollIoHandler.newFactory()))); |
541 | 563 | } else { |
|
0 commit comments