Skip to content

Commit a429bb5

Browse files
committed
Merge remote-tracking branch 'origin/dev/3.0.0' into cleanup/plugin-message-channel-handling
2 parents 9c1be72 + a549880 commit a429bb5

File tree

3 files changed

+38
-12
lines changed

3 files changed

+38
-12
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ configurate3 = "3.7.3"
33
configurate4 = "4.1.2"
44
flare = "2.0.1"
55
log4j = "2.24.1"
6-
netty = "4.1.119.Final"
6+
netty = "4.2.0.Final"
77

88
[plugins]
99
indra-publishing = "net.kyori.indra.publishing:2.0.6"
@@ -54,6 +54,7 @@ netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty"
5454
netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" }
5555
netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" }
5656
netty-transport-native-kqueue = { module = "io.netty:netty-transport-native-kqueue", version.ref = "netty" }
57+
netty-transport-native-iouring = { module = "io.netty:netty-transport-native-io_uring", version.ref = "netty" }
5758
nightconfig = "com.electronwill.night-config:toml:3.6.7"
5859
slf4j = "org.slf4j:slf4j-api:2.0.12"
5960
snakeyaml = "org.yaml:snakeyaml:1.33"

proxy/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ dependencies {
121121
implementation(libs.netty.transport.native.epoll)
122122
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-x86_64") })
123123
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-aarch_64") })
124+
implementation(libs.netty.transport.native.iouring)
125+
implementation(variantOf(libs.netty.transport.native.iouring) { classifier("linux-x86_64") })
126+
implementation(variantOf(libs.netty.transport.native.iouring) { classifier("linux-aarch_64") })
124127
implementation(libs.netty.transport.native.kqueue)
125128
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-x86_64") })
126129
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier("osx-aarch_64") })

proxy/src/main/java/com/velocitypowered/proxy/network/TransportType.java

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,32 @@
2020
import com.velocitypowered.proxy.util.concurrent.VelocityNettyThreadFactory;
2121
import io.netty.channel.ChannelFactory;
2222
import io.netty.channel.EventLoopGroup;
23+
import io.netty.channel.IoHandlerFactory;
24+
import io.netty.channel.MultiThreadIoEventLoopGroup;
2325
import io.netty.channel.epoll.Epoll;
2426
import io.netty.channel.epoll.EpollDatagramChannel;
25-
import io.netty.channel.epoll.EpollEventLoopGroup;
27+
import io.netty.channel.epoll.EpollIoHandler;
2628
import io.netty.channel.epoll.EpollServerSocketChannel;
2729
import io.netty.channel.epoll.EpollSocketChannel;
2830
import io.netty.channel.kqueue.KQueue;
2931
import io.netty.channel.kqueue.KQueueDatagramChannel;
30-
import io.netty.channel.kqueue.KQueueEventLoopGroup;
32+
import io.netty.channel.kqueue.KQueueIoHandler;
3133
import io.netty.channel.kqueue.KQueueServerSocketChannel;
3234
import io.netty.channel.kqueue.KQueueSocketChannel;
33-
import io.netty.channel.nio.NioEventLoopGroup;
35+
import io.netty.channel.nio.NioIoHandler;
3436
import io.netty.channel.socket.DatagramChannel;
3537
import io.netty.channel.socket.ServerSocketChannel;
3638
import io.netty.channel.socket.SocketChannel;
3739
import io.netty.channel.socket.nio.NioDatagramChannel;
3840
import io.netty.channel.socket.nio.NioServerSocketChannel;
3941
import io.netty.channel.socket.nio.NioSocketChannel;
42+
import io.netty.channel.uring.IoUring;
43+
import io.netty.channel.uring.IoUringDatagramChannel;
44+
import io.netty.channel.uring.IoUringIoHandler;
45+
import io.netty.channel.uring.IoUringServerSocketChannel;
46+
import io.netty.channel.uring.IoUringSocketChannel;
4047
import java.util.concurrent.ThreadFactory;
41-
import java.util.function.BiFunction;
48+
import java.util.function.Supplier;
4249

4350
/**
4451
* Enumerates the supported transports for Velocity.
@@ -47,41 +54,52 @@ public enum TransportType {
4754
NIO("NIO", NioServerSocketChannel::new,
4855
NioSocketChannel::new,
4956
NioDatagramChannel::new,
50-
(name, type) -> new NioEventLoopGroup(0, createThreadFactory(name, type))),
57+
NioIoHandler::newFactory),
5158
EPOLL("epoll", EpollServerSocketChannel::new,
5259
EpollSocketChannel::new,
5360
EpollDatagramChannel::new,
54-
(name, type) -> new EpollEventLoopGroup(0, createThreadFactory(name, type))),
61+
EpollIoHandler::newFactory),
5562
KQUEUE("kqueue", KQueueServerSocketChannel::new,
5663
KQueueSocketChannel::new,
5764
KQueueDatagramChannel::new,
58-
(name, type) -> new KQueueEventLoopGroup(0, createThreadFactory(name, type)));
65+
KQueueIoHandler::newFactory),
66+
IO_URING("io_uring", IoUringServerSocketChannel::new,
67+
IoUringSocketChannel::new,
68+
IoUringDatagramChannel::new,
69+
IoUringIoHandler::newFactory);
5970

6071
final String name;
6172
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory;
6273
final ChannelFactory<? extends SocketChannel> socketChannelFactory;
6374
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory;
64-
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory;
75+
final Supplier<IoHandlerFactory> ioHandlerFactorySupplier;
6576

6677
TransportType(final String name,
6778
final ChannelFactory<? extends ServerSocketChannel> serverSocketChannelFactory,
6879
final ChannelFactory<? extends SocketChannel> socketChannelFactory,
6980
final ChannelFactory<? extends DatagramChannel> datagramChannelFactory,
70-
final BiFunction<String, Type, EventLoopGroup> eventLoopGroupFactory) {
81+
final Supplier<IoHandlerFactory> ioHandlerFactorySupplier) {
7182
this.name = name;
7283
this.serverSocketChannelFactory = serverSocketChannelFactory;
7384
this.socketChannelFactory = socketChannelFactory;
7485
this.datagramChannelFactory = datagramChannelFactory;
75-
this.eventLoopGroupFactory = eventLoopGroupFactory;
86+
this.ioHandlerFactorySupplier = ioHandlerFactorySupplier;
7687
}
7788

7889
@Override
7990
public String toString() {
8091
return this.name;
8192
}
8293

94+
/**
95+
* Creates a new event loop group for the given type.
96+
*
97+
* @param type the type of event loop group to create
98+
* @return the event loop group
99+
*/
83100
public EventLoopGroup createEventLoopGroup(final Type type) {
84-
return this.eventLoopGroupFactory.apply(this.name, type);
101+
return new MultiThreadIoEventLoopGroup(
102+
0, createThreadFactory(this.name, type), this.ioHandlerFactorySupplier.get());
85103
}
86104

87105
private static ThreadFactory createThreadFactory(final String name, final Type type) {
@@ -98,6 +116,10 @@ public static TransportType bestType() {
98116
return NIO;
99117
}
100118

119+
if (IoUring.isAvailable() && !Boolean.getBoolean("velocity.disable-iouring-transport")) {
120+
return IO_URING;
121+
}
122+
101123
if (Epoll.isAvailable()) {
102124
return EPOLL;
103125
}

0 commit comments

Comments
 (0)