Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io_uring integration via new transport API #5320

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/ci-5.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ jobs:
jdk: 11
- os: ubuntu-latest
jdk: 11
profile: '-PtestNativeTransport'
profile: '-PNativeEpoll'
- os: ubuntu-latest
jdk: 11
profile: '-PtestDomainSockets'
profile: '-PNativeIoUring'
- os: ubuntu-latest
jdk: 11
profile: '-PNativeEpoll+DomainSockets'
- os: ubuntu-latest
jdk: 21
- os: windows-latest
jdk: 11
stable: true
# - os: macos-latest
# jdk: 11
# profile: '-PNativeKQueue'
uses: ./.github/workflows/ci.yml
with:
branch: ${{ github.event.pull_request.head.sha || github.ref_name }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on:
inputs:
branch:
required: true
type: string
type: 'string'
jdk:
default: 8
type: string
type: 'string'
os:
default: ubuntu-latest
type: string
type: 'string'
profile:
default: ''
type: string
type: 'string'
jobs:
Test:
name: Run tests
Expand Down
114 changes: 97 additions & 17 deletions vertx-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<apacheds-protocol-dns.version>2.0.0.AM27</apacheds-protocol-dns.version>
<generated.dir>${project.basedir}/src/main/generated</generated.dir>
<jmh.version>1.37</jmh.version>
<vertx.testNativeTransport>false</vertx.testNativeTransport>
<vertx.testTransport>jdk</vertx.testTransport>
<vertx.testDomainSockets>false</vertx.testDomainSockets>
</properties>

Expand Down Expand Up @@ -88,6 +88,11 @@
<artifactId>netty-transport-classes-epoll</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-classes-io_uring</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-classes-kqueue</artifactId>
Expand Down Expand Up @@ -247,7 +252,7 @@
<buildDirectory>${project.build.directory}</buildDirectory>
<vertx.version>${project.version}</vertx.version>
<vertx.handle100Continue>true</vertx.handle100Continue>
<vertx.useNativeTransport>${vertx.testNativeTransport}</vertx.useNativeTransport>
<vertx.transport>${vertx.testTransport}</vertx.transport>
<vertx.useDomainSockets>${vertx.testDomainSockets}</vertx.useDomainSockets>
<vertx.threadChecks>true</vertx.threadChecks>
</systemPropertyVariables>
Expand Down Expand Up @@ -360,29 +365,24 @@
<include>io/vertx/it/transport/TransportTest.java</include>
</includes>
<classpathDependencyExcludes>
<classpathDependencyExclude>io.netty:netty-transport-classes-io_uring</classpathDependencyExclude>
<classpathDependencyExclude>io.netty:netty-transport-classes-epoll</classpathDependencyExclude>
<classpathDependencyExclude>io.netty:netty-transport-classes-kqueue</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</execution>
<execution>
<id>service-loaded-native</id>
<id>io_uring</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>io/vertx/it/transport/ServiceLoadedTransportTest.java</include>
<include>io/vertx/it/transport/IoUringTest.java</include>
</includes>
<additionalClasspathElements>
<additionalClasspathElement>${project.basedir}/src/test/classpath/customtransport</additionalClasspathElement>
</additionalClasspathElements>
<classpathDependencyExcludes>
<classpathDependencyExclude>io.netty:netty-transport-native-epoll</classpathDependencyExclude>
<classpathDependencyExclude>io.netty:netty-transport-classes-epoll</classpathDependencyExclude>
<classpathDependencyExclude>io.netty:netty-transport-native-kqueue</classpathDependencyExclude>
<classpathDependencyExclude>io.netty:netty-transport-classes-kqueue</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</execution>
Expand Down Expand Up @@ -648,26 +648,51 @@

<profiles>

<!-- Run tests with native transport -->
<profile>
<id>testNativeTransport</id>
<id>NativeEpoll</id>
<properties>
<vertx.testTransport>epoll</vertx.testTransport>
<vertx.testDomainSockets>false</vertx.testDomainSockets>
<vertx.testUseModulePath>false</vertx.testUseModulePath>
</properties>
</profile>

<profile>
<id>NativeIoUring</id>
<properties>
<vertx.testNativeTransport>true</vertx.testNativeTransport>
<vertx.testTransport>io_uring</vertx.testTransport>
<vertx.testDomainSockets>false</vertx.testDomainSockets>
<vertx.surefire.useModulePath>false</vertx.surefire.useModulePath>
</properties>
</profile>

<!-- Run tests with native transport and domain sockets -->
<profile>
<id>testDomainSockets</id>
<id>NativeEpoll+DomainSockets</id>
<properties>
<vertx.testNativeTransport>true</vertx.testNativeTransport>
<vertx.testTransport>epoll</vertx.testTransport>
<vertx.testDomainSockets>true</vertx.testDomainSockets>
<vertx.surefire.useModulePath>false</vertx.surefire.useModulePath>
</properties>
</profile>

<profile>
<id>NativeKQueue</id>
<properties>
<vertx.testTransport>kqueue</vertx.testTransport>
<vertx.testDomainSockets>false</vertx.testDomainSockets>
<vertx.testUseModulePath>false</vertx.testUseModulePath>
</properties>
</profile>

<profile>
<id>NativeKQueue+DomainSockets</id>
<properties>
<vertx.testTransport>kqueue</vertx.testTransport>
<vertx.testDomainSockets>true</vertx.testDomainSockets>
<vertx.testUseModulePath>false</vertx.testUseModulePath>
</properties>
</profile>

<profile>
<id>benchmarks</id>
<build>
Expand Down Expand Up @@ -743,10 +768,35 @@
</profile>

<profile>
<id>linux</id>
<id>linux-x86_64</id>
<activation>
<os>
<family>linux</family>
<arch>x86_64</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-x86_64</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-io_uring</artifactId>
<classifier>linux-x86_64</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>linux-amd64</id>
<activation>
<os>
<family>linux</family>
<arch>amd64</arch>
</os>
</activation>
<dependencies>
Expand All @@ -756,6 +806,36 @@
<classifier>linux-x86_64</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-io_uring</artifactId>
<classifier>linux-x86_64</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

<profile>
<id>linux-aarch64</id>
<activation>
<os>
<family>linux</family>
<arch>aarch64</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-io_uring</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>test</scope>
</dependency>
</dependencies>
</profile>

Expand Down
39 changes: 27 additions & 12 deletions vertx-core/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1022,10 +1022,24 @@ Vert.x can run with http://netty.io/wiki/native-transports.html[native transport
{@link examples.CoreExamples#configureNative()}
----

NOTE: preferring native transport will not prevent the application to execute (for example if a JAR is missing).
If your application requires native transport, you need to check {@link io.vertx.core.Vertx#isNativeTransportEnabled()}.
NOTE: preferring native transport will not prevent the application to execute (for example a native dependency might be missing). If your application requires native transport, you need to check {@link io.vertx.core.Vertx#isNativeTransportEnabled()}.

=== Native Linux Transport
You can also explicitly configure the transport to use:

[source,$lang]
----
{@link examples.CoreExamples#configureTransport()}
----

=== Native epoll

Native on Linux gives you extra networking options:

* `SO_REUSEPORT`
* `TCP_QUICKACK`
* `TCP_CORK`
* `TCP_FASTOPEN`
* `TCP_USER_TIMEOUT`

You need to add the following dependency in your classpath:

Expand All @@ -1039,20 +1053,21 @@ You need to add the following dependency in your classpath:
</dependency>
----

Native on Linux gives you extra networking options:
=== Native io_uring

* `SO_REUSEPORT`
* `TCP_QUICKACK`
* `TCP_CORK`
* `TCP_FASTOPEN`
* `TCP_USER_TIMEOUT`
You need to add the following dependency in your classpath:

[source,$lang]
[source,xml]
----
{@link examples.CoreExamples#configureLinuxOptions}
<dependency>
<groupId>io.netty</groupId>
<classifier>linux-x86_64</classifier>
<artifactId>netty-transport-native-io_uring</artifactId>
<!--<version>Should align with netty version that Vert.x uses</version>-->
</dependency>
----

=== Native BSD Transport
=== Native kqueue

You need to add the following dependency in your classpath:

Expand Down
14 changes: 14 additions & 0 deletions vertx-core/src/main/java/examples/CoreExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.vertx.core.net.SocketAddress;
import io.vertx.core.spi.VertxMetricsFactory;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.core.transport.Transport;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -472,6 +473,19 @@ public void configureNative() {
System.out.println("Running with native: " + usingNative);
}

public void configureTransport() {

// Use epoll/kqueue/io_uring native transport depending on OS
Transport transport = Transport.nativeTransport();

// Or use a very specific transport
transport = Transport.EPOLL;

Vertx vertx = Vertx.builder()
.withTransport(transport)
.build();
}

public void configureLinuxOptions(Vertx vertx, boolean fastOpen, boolean cork, boolean quickAck, boolean reusePort) {
// Available on Linux
vertx.createHttpServer(new HttpServerOptions()
Expand Down
Loading
Loading