From d2fab8f93bf8a17e13014403a11016681080e79f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 13 Mar 2024 18:29:40 +0100 Subject: [PATCH] IO_Uring support --- patches/server/1010-IO_Uring-support.patch | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 patches/server/1010-IO_Uring-support.patch diff --git a/patches/server/1010-IO_Uring-support.patch b/patches/server/1010-IO_Uring-support.patch new file mode 100644 index 0000000000..d339264a4a --- /dev/null +++ b/patches/server/1010-IO_Uring-support.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Lixfel +Date: Wed, 13 Mar 2024 18:23:22 +0100 +Subject: [PATCH] IO_Uring support + + +diff --git a/build.gradle.kts b/build.gradle.kts +index fb98936bb8a5488db75d676c5bcb4060597fbbf8..2e803f7231b66323373c16e0cbf70e2405b1ed59 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -31,6 +31,7 @@ dependencies { + runtimeOnly(log4jPlugins.output) + alsoShade(log4jPlugins.output) + implementation("io.netty:netty-codec-haproxy:4.1.87.Final") // Paper - Add support for proxy protocol ++ implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.24.Final:linux-x86_64") + // Paper end + implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion + implementation("org.ow2.asm:asm:9.4") +diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java +index 44d99e89226adb6234b9405f25ac9dab9bd84297..6674e461e9668449686369d1e535ed372bd9240b 100644 +--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java ++++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java +@@ -23,6 +23,9 @@ import io.netty.channel.nio.NioEventLoopGroup; + import io.netty.channel.socket.ServerSocketChannel; + import io.netty.channel.socket.nio.NioServerSocketChannel; + import io.netty.handler.timeout.ReadTimeoutHandler; ++import io.netty.incubator.channel.uring.IOUring; ++import io.netty.incubator.channel.uring.IOUringEventLoopGroup; ++import io.netty.incubator.channel.uring.IOUringServerSocketChannel; + import io.netty.util.HashedWheelTimer; + import io.netty.util.Timeout; + import io.netty.util.Timer; +@@ -56,6 +59,9 @@ public class ServerConnectionListener { + public static final LazyLoadedValue SERVER_EPOLL_EVENT_GROUP = new LazyLoadedValue<>(() -> { + return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper + }); ++ public static final LazyLoadedValue SERVER_IOURING_EVENT_GROUP = new LazyLoadedValue<>(() -> { ++ return new IOUringEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(LOGGER)).build()); // Paper ++ }); + final MinecraftServer server; + public volatile boolean running; + private final List channels = Collections.synchronizedList(Lists.newArrayList()); +@@ -89,7 +95,11 @@ public class ServerConnectionListener { + Class oclass; + LazyLoadedValue lazyinitvar; + +- if (Epoll.isAvailable() && this.server.isEpollEnabled()) { ++ if (IOUring.isAvailable() && this.server.isEpollEnabled()) { ++ oclass = IOUringServerSocketChannel.class; ++ lazyinitvar = ServerConnectionListener.SERVER_IOURING_EVENT_GROUP; ++ ServerConnectionListener.LOGGER.info("Using io_uring channel type"); ++ } else if (Epoll.isAvailable() && this.server.isEpollEnabled()) { + if (address instanceof io.netty.channel.unix.DomainSocketAddress) { + oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class; + } else {