Skip to content

Commit ff58be3

Browse files
committed
Support Unix Domain Sockets with io_uring transport
In Netty 4.2, Unix Domain Sockets with io_uring are supported. But they were not integrated by Vert.x yet. Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
1 parent 3924e93 commit ff58be3

4 files changed

Lines changed: 49 additions & 22 deletions

File tree

.github/workflows/ci-matrix-5.x.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
- os: ubuntu-latest
2525
jdk: 11
2626
profile: '-PNativeEpoll+DomainSockets'
27+
- os: ubuntu-latest
28+
jdk: 11
29+
profile: '-PNativeIoUring+DomainSockets'
2730
- os: ubuntu-latest
2831
jdk: 25
2932
- os: windows-2022

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
java-version: ${{ inputs.jdk }}
3333
distribution: temurin
3434
- name: Run tests
35-
if: ${{ runner.os != 'Linux' || inputs.profile != '-PNativeIoUring'}}
35+
if: ${{ runner.os != 'Linux' || (inputs.profile != '-PNativeIoUring' && inputs.profile != '-PNativeIoUring+DomainSockets')}}
3636
run: mvn -s .github/maven-ci-settings.xml -q clean verify -B ${{ inputs.profile }}
3737
- name: Run tests
38-
if: ${{ runner.os == 'Linux' && inputs.profile == '-PNativeIoUring' && inputs.io_uring_supported }}
38+
if: ${{ runner.os == 'Linux' && (inputs.profile == '-PNativeIoUring' || inputs.profile == '-PNativeIoUring+DomainSockets') && inputs.io_uring_supported }}
3939
run: |
4040
# io_uring testing requires more locked memory for kernel ring buffers than the default 8MB limit
4141
sudo prlimit --pid $$ --memlock=16777216:16777216

vertx-core/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,29 @@
905905
</properties>
906906
</profile>
907907

908+
<profile>
909+
<id>NativeIoUring+DomainSockets</id>
910+
<properties>
911+
<vertx.surefire.nettyTransport>io_uring</vertx.surefire.nettyTransport>
912+
<vertx.surefire.useDomainSockets>true</vertx.surefire.useDomainSockets>
913+
<vertx.surefire.useModulePath>false</vertx.surefire.useModulePath>
914+
</properties>
915+
<build>
916+
<plugins>
917+
<plugin>
918+
<groupId>org.apache.maven.plugins</groupId>
919+
<artifactId>maven-surefire-plugin</artifactId>
920+
<configuration>
921+
<systemPropertyVariables combine.children="append">
922+
<io.netty.iouring.ringSize>512</io.netty.iouring.ringSize>
923+
<io.netty.iouring.cqSize>1024</io.netty.iouring.cqSize>
924+
</systemPropertyVariables>
925+
</configuration>
926+
</plugin>
927+
</plugins>
928+
</build>
929+
</profile>
930+
908931
<profile>
909932
<id>NativeKQueue</id>
910933
<properties>

vertx-core/src/main/java/io/vertx/core/impl/transports/IoUringTransport.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2011-2026 Contributors to the Eclipse Foundation
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -8,6 +8,7 @@
88
*
99
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
1010
*/
11+
1112
package io.vertx.core.impl.transports;
1213

1314
import io.netty.bootstrap.Bootstrap;
@@ -16,6 +17,7 @@
1617
import io.netty.channel.socket.DatagramChannel;
1718
import io.netty.channel.socket.InternetProtocolFamily;
1819
import io.netty.channel.unix.DomainSocketAddress;
20+
import io.netty.channel.unix.UnixChannelOption;
1921
import io.netty.channel.uring.*;
2022
import io.vertx.core.datagram.DatagramSocketOptions;
2123
import io.vertx.core.net.TcpConfig;
@@ -61,7 +63,7 @@ public IoUringTransport() {
6163

6264
@Override
6365
public boolean supportsDomainSockets() {
64-
return false;
66+
return true;
6567
}
6668

6769
@Override
@@ -72,7 +74,7 @@ public boolean supportFileRegion() {
7274
@Override
7375
public SocketAddress convert(io.vertx.core.net.SocketAddress address) {
7476
if (address.isDomainSocket()) {
75-
throw new IllegalArgumentException("Domain socket not supported by IOUring transport");
77+
return new DomainSocketAddress(address.path());
7678
}
7779
return Transport.super.convert(address);
7880
}
@@ -113,15 +115,15 @@ public ChannelFactory<? extends DatagramChannel> datagramChannelFactory() {
113115
@Override
114116
public ChannelFactory<? extends Channel> channelFactory(boolean domainSocket) {
115117
if (domainSocket) {
116-
throw new IllegalArgumentException();
118+
return IoUringDomainSocketChannel::new;
117119
}
118120
return IoUringSocketChannel::new;
119121
}
120122

121123
@Override
122124
public ChannelFactory<? extends ServerChannel> serverChannelFactory(boolean domainSocket) {
123125
if (domainSocket) {
124-
throw new IllegalArgumentException();
126+
return IoUringServerDomainSocketChannel::new;
125127
}
126128
return IoUringServerSocketChannel::new;
127129
}
@@ -134,26 +136,25 @@ public void configure(DatagramChannel channel, DatagramSocketOptions options) {
134136

135137
@Override
136138
public void configure(TcpConfig config, boolean domainSocket, ServerBootstrap bootstrap) {
137-
if (domainSocket) {
138-
throw new IllegalArgumentException();
139+
if (!domainSocket) {
140+
bootstrap.option(UnixChannelOption.SO_REUSEPORT, config.isSoReusePort());
141+
configOption(bootstrap, config, TcpOption.FASTOPEN, IoUringChannelOption.TCP_FASTOPEN);
142+
configChildOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
143+
configChildOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
144+
configChildOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
139145
}
140-
bootstrap.option(IoUringChannelOption.SO_REUSEPORT, config.isSoReusePort());
141-
configOption(bootstrap, config, TcpOption.FASTOPEN, IoUringChannelOption.TCP_FASTOPEN);
142-
configChildOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
143-
configChildOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
144-
configChildOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
145-
Transport.super.configure(config, false, bootstrap);
146+
Transport.super.configure(config, domainSocket, bootstrap);
146147
}
147148

148149
@Override
149150
public void configure(TcpConfig config, boolean domainSocket, Bootstrap bootstrap) {
150-
if (domainSocket) {
151-
throw new IllegalArgumentException();
151+
if (!domainSocket) {
152+
NioTransport.configOption(bootstrap, config, TcpOption.FASTOPEN_CONNECT,
153+
IoUringChannelOption.TCP_FASTOPEN_CONNECT);
154+
NioTransport.configOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
155+
NioTransport.configOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
156+
NioTransport.configOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
152157
}
153-
NioTransport.configOption(bootstrap, config, TcpOption.FASTOPEN_CONNECT, IoUringChannelOption.TCP_FASTOPEN_CONNECT);
154-
NioTransport.configOption(bootstrap, config, TcpOption.USER_TIMEOUT, IoUringChannelOption.TCP_USER_TIMEOUT);
155-
NioTransport.configOption(bootstrap, config, TcpOption.QUICKACK, IoUringChannelOption.TCP_QUICKACK);
156-
NioTransport.configOption(bootstrap, config, TcpOption.CORK, IoUringChannelOption.TCP_CORK);
157-
Transport.super.configure(config, false, bootstrap);
158+
Transport.super.configure(config, domainSocket, bootstrap);
158159
}
159160
}

0 commit comments

Comments
 (0)