Basic support for linux io_uring

This commit is contained in:
themode 2020-11-21 10:42:07 +01:00
parent 3193c0894e
commit 3087b120f9
2 changed files with 10 additions and 1 deletions

View File

@ -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'

View File

@ -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<? extends ServerChannel> 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