From 3087b120f93dca5cbd79d59068b7f8f3b16d2591 Mon Sep 17 00:00:00 2001 From: themode Date: Sat, 21 Nov 2020 10:42:07 +0100 Subject: [PATCH] Basic support for linux io_uring --- build.gradle | 1 + .../net/minestom/server/network/netty/NettyServer.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f01a523cc..5ea60abf9 100644 --- a/build.gradle +++ b/build.gradle @@ -110,6 +110,7 @@ dependencies { api 'io.netty:netty-codec:4.1.54.Final' api 'io.netty:netty-transport-native-epoll:4.1.54.Final:linux-x86_64' api 'io.netty:netty-transport-native-kqueue:4.1.54.Final:osx-x86_64' + api 'io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.1.Final:linux-x86_64' // https://mvnrepository.com/artifact/it.unimi.dsi/fastutil api 'it.unimi.dsi:fastutil:8.4.3' diff --git a/src/main/java/net/minestom/server/network/netty/NettyServer.java b/src/main/java/net/minestom/server/network/netty/NettyServer.java index c3b94b75f..f6f42a5fd 100644 --- a/src/main/java/net/minestom/server/network/netty/NettyServer.java +++ b/src/main/java/net/minestom/server/network/netty/NettyServer.java @@ -14,6 +14,9 @@ import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.traffic.GlobalChannelTrafficShapingHandler; import io.netty.handler.traffic.TrafficCounter; +import io.netty.incubator.channel.uring.IOUring; +import io.netty.incubator.channel.uring.IOUringEventLoopGroup; +import io.netty.incubator.channel.uring.IOUringServerSocketChannel; import net.minestom.server.MinecraftServer; import net.minestom.server.network.PacketProcessor; import net.minestom.server.network.netty.channel.ClientChannel; @@ -65,7 +68,12 @@ public final class NettyServer { public NettyServer(@NotNull PacketProcessor packetProcessor) { Class channel; - if (Epoll.isAvailable()) { + if (IOUring.isAvailable()) { + boss = new IOUringEventLoopGroup(2); + worker = new IOUringEventLoopGroup(); // thread count = core * 2 + + channel = IOUringServerSocketChannel.class; + } else if (Epoll.isAvailable()) { boss = new EpollEventLoopGroup(2); worker = new EpollEventLoopGroup(); // thread count = core * 2