Skip to content

Commit 3bca510

Browse files
lnevesLuis Neves
andauthored
update netty and add io_uring support (#6164)
* use heap buffers for the plaintext response * remove unnecessary call to fireChannelRead() * update netty and add io_uring support * pick netty deps Co-authored-by: Luis Neves <[email protected]>
1 parent 80ef9f4 commit 3bca510

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

frameworks/Java/netty/pom.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24

35
<modelVersion>4.0.0</modelVersion>
46

@@ -9,7 +11,7 @@
911
<properties>
1012
<maven.compiler.source>11</maven.compiler.source>
1113
<maven.compiler.target>11</maven.compiler.target>
12-
<netty.version>4.1.36.Final</netty.version>
14+
<netty.version>4.1.54.Final</netty.version>
1315
</properties>
1416

1517
<packaging>jar</packaging>
@@ -36,6 +38,13 @@
3638
<classifier>osx-x86_64</classifier>
3739
</dependency>
3840

41+
<dependency>
42+
<groupId>io.netty.incubator</groupId>
43+
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
44+
<version>0.0.1.Final</version>
45+
<classifier>linux-x86_64</classifier>
46+
</dependency>
47+
3948
<dependency>
4049
<groupId>com.jsoniter</groupId>
4150
<artifactId>jsoniter</artifactId>
@@ -45,7 +54,7 @@
4554
<dependency>
4655
<groupId>org.javassist</groupId>
4756
<artifactId>javassist</artifactId>
48-
<version>3.25.0-GA</version>
57+
<version>3.27.0-GA</version>
4958
</dependency>
5059

5160
</dependencies>

frameworks/Java/netty/src/main/java/hello/HelloWebServer.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
import io.netty.channel.kqueue.KQueueServerSocketChannel;
1616
import io.netty.channel.nio.NioEventLoopGroup;
1717
import io.netty.channel.socket.nio.NioServerSocketChannel;
18+
import io.netty.incubator.channel.uring.IOUring;
19+
import io.netty.incubator.channel.uring.IOUringChannelOption;
20+
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
21+
import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
1822
import io.netty.util.ResourceLeakDetector;
1923
import io.netty.util.ResourceLeakDetector.Level;
2024

@@ -32,8 +36,10 @@ public HelloWebServer(int port) {
3236

3337
public void run() throws Exception {
3438
// Configure the server.
35-
36-
if (Epoll.isAvailable()) {
39+
if (IOUring.isAvailable()) {
40+
doRun(new IOUringEventLoopGroup(), IOUringServerSocketChannel.class, IoMultiplexer.IO_URING);
41+
} else
42+
if (Epoll.isAvailable()) {
3743
doRun(new EpollEventLoopGroup(), EpollServerSocketChannel.class, IoMultiplexer.EPOLL);
3844
} else if (KQueue.isAvailable()) {
3945
doRun(new EpollEventLoopGroup(), KQueueServerSocketChannel.class, IoMultiplexer.KQUEUE);
@@ -45,13 +51,19 @@ public void run() throws Exception {
4551
private void doRun(EventLoopGroup loupGroup, Class<? extends ServerChannel> serverChannelClass, IoMultiplexer multiplexer) throws InterruptedException {
4652
try {
4753
InetSocketAddress inet = new InetSocketAddress(port);
54+
55+
System.out.printf("Using %s IoMultiplexer%n", multiplexer);
4856

4957
ServerBootstrap b = new ServerBootstrap();
5058

5159
if (multiplexer == IoMultiplexer.EPOLL) {
5260
b.option(EpollChannelOption.SO_REUSEPORT, true);
5361
}
5462

63+
if (multiplexer == IoMultiplexer.IO_URING) {
64+
b.option(IOUringChannelOption.SO_REUSEPORT, true);
65+
}
66+
5567
b.option(ChannelOption.SO_BACKLOG, 8192);
5668
b.option(ChannelOption.SO_REUSEADDR, true);
5769
b.group(loupGroup).channel(serverChannelClass).childHandler(new HelloServerInitializer(loupGroup.next()));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package hello;
22

33
public enum IoMultiplexer {
4-
EPOLL, KQUEUE, JDK
4+
EPOLL, KQUEUE, JDK, IO_URING
55
}

0 commit comments

Comments
 (0)