6
6
import io .netty .channel .ChannelException ;
7
7
import io .netty .channel .ChannelOption ;
8
8
import io .netty .channel .EventLoopGroup ;
9
+ import io .netty .channel .MultiThreadIoEventLoopGroup ;
9
10
import io .netty .channel .ServerChannel ;
10
11
import io .netty .channel .WriteBufferWaterMark ;
11
12
import io .netty .channel .epoll .Epoll ;
12
13
import io .netty .channel .epoll .EpollDatagramChannel ;
13
14
import io .netty .channel .epoll .EpollDomainSocketChannel ;
14
- import io .netty .channel .epoll .EpollEventLoopGroup ;
15
+ import io .netty .channel .epoll .EpollIoHandler ;
15
16
import io .netty .channel .epoll .EpollServerDomainSocketChannel ;
16
17
import io .netty .channel .epoll .EpollServerSocketChannel ;
17
18
import io .netty .channel .epoll .EpollSocketChannel ;
18
- import io .netty .channel .nio .NioEventLoopGroup ;
19
+ import io .netty .channel .nio .NioIoHandler ;
19
20
import io .netty .channel .socket .DatagramChannel ;
20
21
import io .netty .channel .socket .nio .NioDatagramChannel ;
21
22
import io .netty .channel .socket .nio .NioServerSocketChannel ;
22
23
import io .netty .channel .socket .nio .NioSocketChannel ;
23
24
import io .netty .channel .unix .DomainSocketAddress ;
25
+ import io .netty .channel .uring .IoUring ;
26
+ import io .netty .channel .uring .IoUringDatagramChannel ;
27
+ import io .netty .channel .uring .IoUringIoHandler ;
28
+ import io .netty .channel .uring .IoUringServerSocketChannel ;
29
+ import io .netty .channel .uring .IoUringSocketChannel ;
24
30
import io .netty .handler .codec .haproxy .HAProxyMessageDecoder ;
25
31
import io .netty .handler .timeout .ReadTimeoutHandler ;
26
32
import io .netty .handler .timeout .WriteTimeoutHandler ;
27
- import io .netty .incubator .channel .uring .IOUring ;
28
- import io .netty .incubator .channel .uring .IOUringDatagramChannel ;
29
- import io .netty .incubator .channel .uring .IOUringEventLoopGroup ;
30
- import io .netty .incubator .channel .uring .IOUringServerSocketChannel ;
31
- import io .netty .incubator .channel .uring .IOUringSocketChannel ;
32
33
import io .netty .util .AttributeKey ;
33
34
import io .netty .util .internal .PlatformDependent ;
34
35
import java .net .SocketAddress ;
@@ -133,16 +134,17 @@ private static void setChannelInitializerHolders()
133
134
{
134
135
if ( !PlatformDependent .isWindows () )
135
136
{
136
- // disable by default (experimental)
137
+ // disable by default
138
+ // TODO: maybe make it the new default?
137
139
if ( Boolean .parseBoolean ( System .getProperty ( "bungee.io_uring" , "false" ) ) )
138
140
{
139
141
ProxyServer .getInstance ().getLogger ().info ( "Not on Windows, attempting to use enhanced IOUringEventLoopGroup" );
140
- if ( io_uring = IOUring .isAvailable () )
142
+ if ( io_uring = IoUring .isAvailable () )
141
143
{
142
144
ProxyServer .getInstance ().getLogger ().log ( Level .WARNING , "io_uring is enabled and working, utilising it! (experimental feature)" );
143
145
} else
144
146
{
145
- ProxyServer .getInstance ().getLogger ().log ( Level .WARNING , "io_uring is not working: {0}" , Util .exception ( IOUring .unavailabilityCause () ) );
147
+ ProxyServer .getInstance ().getLogger ().log ( Level .WARNING , "io_uring is not working: {0}" , Util .exception ( IoUring .unavailabilityCause () ) );
146
148
}
147
149
}
148
150
@@ -164,7 +166,7 @@ private static void setChannelInitializerHolders()
164
166
165
167
public static EventLoopGroup newEventLoopGroup (int threads , ThreadFactory factory )
166
168
{
167
- return io_uring ? new IOUringEventLoopGroup ( threads , factory ) : epoll ? new EpollEventLoopGroup ( threads , factory ) : new NioEventLoopGroup ( threads , factory );
169
+ return new MultiThreadIoEventLoopGroup ( threads , factory , io_uring ? IoUringIoHandler . newFactory ( ) : epoll ? EpollIoHandler . newFactory ( ) : NioIoHandler . newFactory () );
168
170
}
169
171
170
172
public static Class <? extends ServerChannel > getServerChannel (SocketAddress address )
@@ -176,7 +178,7 @@ public static Class<? extends ServerChannel> getServerChannel(SocketAddress addr
176
178
return EpollServerDomainSocketChannel .class ;
177
179
}
178
180
179
- return io_uring ? IOUringServerSocketChannel .class : epoll ? EpollServerSocketChannel .class : NioServerSocketChannel .class ;
181
+ return io_uring ? IoUringServerSocketChannel .class : epoll ? EpollServerSocketChannel .class : NioServerSocketChannel .class ;
180
182
}
181
183
182
184
public static Class <? extends Channel > getChannel (SocketAddress address )
@@ -188,12 +190,12 @@ public static Class<? extends Channel> getChannel(SocketAddress address)
188
190
return EpollDomainSocketChannel .class ;
189
191
}
190
192
191
- return io_uring ? IOUringSocketChannel .class : epoll ? EpollSocketChannel .class : NioSocketChannel .class ;
193
+ return io_uring ? IoUringSocketChannel .class : epoll ? EpollSocketChannel .class : NioSocketChannel .class ;
192
194
}
193
195
194
196
public static Class <? extends DatagramChannel > getDatagramChannel ()
195
197
{
196
- return io_uring ? IOUringDatagramChannel .class : epoll ? EpollDatagramChannel .class : NioDatagramChannel .class ;
198
+ return io_uring ? IoUringDatagramChannel .class : epoll ? EpollDatagramChannel .class : NioDatagramChannel .class ;
197
199
}
198
200
199
201
private static final int LOW_MARK = Integer .getInteger ( "net.md_5.bungee.low_mark" , 2 << 18 ); // 0.5 mb
@@ -217,6 +219,8 @@ public boolean accept(Channel ch)
217
219
{
218
220
// IP_TOS is not supported (Windows XP / Windows Server 2003)
219
221
}
222
+ // https://github.com/netty/netty/wiki/Netty-4.2-Migration-Guide
223
+ // TODO: check for AdaptiveByteBufAllocator
220
224
ch .config ().setAllocator ( PooledByteBufAllocator .DEFAULT );
221
225
ch .config ().setWriteBufferWaterMark ( MARK );
222
226
0 commit comments