Skip to content

Commit c834593

Browse files
committed
Merge branch 'native-image'
2 parents c6bdda0 + c7c029a commit c834593

File tree

11 files changed

+403
-27
lines changed

11 files changed

+403
-27
lines changed

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,26 @@
55
### VARIABLES ###
66
#
77
export PATH :=$(CURDIR):$(CURDIR)/scripts:$(PATH)
8+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
9+
HARDWARE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
10+
GPG_KEYNAME := $(shell cat pom.xml | grep -oPm1 "(?<=<gpg.keyname>)[^<]+")
811

912
### TARGETS ###
1013
#
1114

1215
binary: clean ## Build the binary distribution
1316
@mvnw package -P assemblies -Dgpg.skip=true -Dmaven.test.skip
1417

18+
native-image: clean ## Build the native image
19+
@mvnw package -DskipTests -P native-image -P '!java-packaging'
20+
native-image -jar target/perf-test.jar -H:Features="com.rabbitmq.perf.NativeImageFeature"
21+
22+
23+
package-native-image: native-image ## Package the native image
24+
cp perf-test target/perf-test_$(OS)_$(HARDWARE)
25+
@mvnw checksum:files -P native-image
26+
gpg --armor --local-user $(GPG_KEYNAME) --detach-sign target/perf-test_$(OS)_$(HARDWARE)
27+
1528
help:
1629
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
1730

@@ -33,7 +46,7 @@ run: compile ## Run PerfTest, pass exec arguments via ARGS, e.g. ARGS="-x 1 -y 1
3346
signed-binary: clean ## Build a GPG signed binary
3447
@mvnw package -P assemblies
3548

36-
doc: clean ## Generate PerfTest documentation
49+
doc: ## Generate PerfTest documentation
3750
@mvnw asciidoctor:process-asciidoc
3851

3952
.PHONY: binary help clean compile jar run signed-binary

pom.xml

Lines changed: 166 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
<asciidoctor.maven.plugin.version>1.5.6</asciidoctor.maven.plugin.version>
9393
<asciidoctorj.version>1.5.6</asciidoctorj.version>
9494
<jruby.version>1.7.26</jruby.version>
95+
<!-- For GraalVM native image -->
96+
<maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
97+
<maven-jar-plugin.version>3.1.0</maven-jar-plugin.version>
98+
<slf4j.version>1.7.25</slf4j.version>
99+
<graal-sdk.version>1.0.0-rc9</graal-sdk.version>
100+
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
95101
</properties>
96102

97103
<dependencies>
@@ -149,7 +155,6 @@
149155
<optional>true</optional>
150156
</dependency>
151157

152-
153158
<dependency>
154159
<groupId>org.junit.jupiter</groupId>
155160
<artifactId>junit-jupiter-engine</artifactId>
@@ -669,6 +674,166 @@
669674
</build>
670675
</profile>
671676

677+
<profile>
678+
<id>java-packaging</id>
679+
<activation>
680+
<property>
681+
<name>!native-image</name>
682+
</property>
683+
</activation>
684+
<build>
685+
<plugins>
686+
<plugin>
687+
<groupId>org.codehaus.mojo</groupId>
688+
<artifactId>build-helper-maven-plugin</artifactId>
689+
<version>${build-helper-maven-plugin.version}</version>
690+
<executions>
691+
<execution>
692+
<id>add-source</id>
693+
<phase>generate-sources</phase>
694+
<goals>
695+
<goal>add-source</goal>
696+
</goals>
697+
<configuration>
698+
<sources>
699+
<source>src/java-packaging/java</source>
700+
</sources>
701+
</configuration>
702+
</execution>
703+
</executions>
704+
</plugin>
705+
</plugins>
706+
</build>
707+
</profile>
708+
709+
<profile>
710+
<id>native-image</id>
711+
<dependencies>
712+
713+
<dependency>
714+
<groupId>org.graalvm.sdk</groupId>
715+
<artifactId>graal-sdk</artifactId>
716+
<version>${graal-sdk.version}</version>
717+
</dependency>
718+
719+
<dependency>
720+
<groupId>org.slf4j</groupId>
721+
<artifactId>slf4j-simple</artifactId>
722+
<version>${slf4j.version}</version>
723+
</dependency>
724+
725+
</dependencies>
726+
<build>
727+
<plugins>
728+
<plugin>
729+
<artifactId>maven-compiler-plugin</artifactId>
730+
<version>${maven.compiler.plugin.version}</version>
731+
<configuration>
732+
<source>1.8</source>
733+
<target>1.8</target>
734+
<compilerArgs>
735+
<arg>-Xlint:deprecation</arg>
736+
<arg>-Xlint:unchecked</arg>
737+
</compilerArgs>
738+
<excludes>
739+
<exclude>com/rabbitmq/perf/WebServer.java</exclude>
740+
</excludes>
741+
</configuration>
742+
</plugin>
743+
<plugin>
744+
<groupId>org.apache.maven.plugins</groupId>
745+
<artifactId>maven-assembly-plugin</artifactId>
746+
<version>${maven-assembly-plugin.version}</version>
747+
<configuration>
748+
<finalName>${project.artifactId}</finalName>
749+
<descriptors>
750+
<descriptor>src/assembly/jar-for-native-image.xml</descriptor>
751+
</descriptors>
752+
<appendAssemblyId>false</appendAssemblyId>
753+
<archive>
754+
<manifest>
755+
<mainClass>com.rabbitmq.perf.NativePerfTest</mainClass>
756+
</manifest>
757+
</archive>
758+
</configuration>
759+
<executions>
760+
<execution>
761+
<id>assemble-all</id>
762+
<phase>package</phase>
763+
<goals>
764+
<goal>single</goal>
765+
</goals>
766+
</execution>
767+
</executions>
768+
</plugin>
769+
<plugin>
770+
<groupId>org.apache.maven.plugins</groupId>
771+
<artifactId>maven-jar-plugin</artifactId>
772+
<version>${maven-jar-plugin.version}</version>
773+
<executions>
774+
<execution>
775+
<id>default-jar</id>
776+
<phase>none</phase>
777+
</execution>
778+
</executions>
779+
</plugin>
780+
<plugin>
781+
<groupId>org.codehaus.mojo</groupId>
782+
<artifactId>build-helper-maven-plugin</artifactId>
783+
<version>${build-helper-maven-plugin.version}</version>
784+
<executions>
785+
<execution>
786+
<id>add-source</id>
787+
<phase>generate-sources</phase>
788+
<goals>
789+
<goal>add-source</goal>
790+
</goals>
791+
<configuration>
792+
<sources>
793+
<source>src/graalvm/java</source>
794+
</sources>
795+
</configuration>
796+
</execution>
797+
</executions>
798+
</plugin>
799+
<plugin>
800+
<groupId>net.nicoulaj.maven.plugins</groupId>
801+
<artifactId>checksum-maven-plugin</artifactId>
802+
<version>${checksum.maven.plugin.version}</version>
803+
<configuration>
804+
<fileSets>
805+
<fileSet>
806+
<directory>${project.build.directory}</directory>
807+
<includes>
808+
<include>perf-test_*</include>
809+
</includes>
810+
</fileSet>
811+
</fileSets>
812+
<algorithms>
813+
<algorithm>MD5</algorithm>
814+
<algorithm>SHA-1</algorithm>
815+
</algorithms>
816+
</configuration>
817+
</plugin>
818+
<plugin>
819+
<groupId>org.apache.maven.plugins</groupId>
820+
<artifactId>maven-gpg-plugin</artifactId>
821+
<version>${maven.gpg.plugin.version}</version>
822+
<configuration>
823+
<keyname>${gpg.keyname}</keyname>
824+
<excludes>
825+
<exclude>*.jar</exclude>
826+
<exclude>*.md5</exclude>
827+
<exclude>*.sha1</exclude>
828+
<exclude>*.asc</exclude>
829+
</excludes>
830+
</configuration>
831+
</plugin>
832+
</plugins>
833+
834+
</build>
835+
</profile>
836+
672837
<profile>
673838
<id>ossrh-release</id>
674839
<build>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
4+
<!-- TODO: a jarjar format would be better -->
5+
<id>jar-for-native-image</id>
6+
<formats>
7+
<format>jar</format>
8+
</formats>
9+
<includeBaseDirectory>false</includeBaseDirectory>
10+
<dependencySets>
11+
<dependencySet>
12+
<outputDirectory>/</outputDirectory>
13+
<useProjectArtifact>true</useProjectArtifact>
14+
<unpack>true</unpack>
15+
<scope>runtime</scope>
16+
<excludes>
17+
<exclude>ch.qos.logback:logback-classic</exclude>
18+
<exclude>ch.qos.logback:logback-core</exclude>
19+
</excludes>
20+
</dependencySet>
21+
</dependencySets>
22+
</assembly>

src/docs/asciidoc/installation.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ To verify a PerfTest installation, use:
2424

2525
$ bin/runjava com.rabbitmq.perf.PerfTest --help
2626

27+
=== From Native Executable
28+
29+
PerfTest is also distributed as a native executable binary. This is an experimental
30+
feature, see the link:#native-executable[dedicated section] for more information.
31+
2732
=== For Cloud Foundry
2833

2934
There is a https://github.com/rabbitmq/rabbitmq-perf-test-for-cf[template project]

src/docs/asciidoc/monitoring.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ These metrics are enabled with the `-mjt` or `--metrics-jvm-thread` flag.
3939
on the JVM used, its version, and the GC settings. They can be useful to correlate the GC
4040
activity with PerfTest behavior, e.g. abnormal low throughput because of very frequent
4141
garbage collection. These metrics are enabled with the `-mjgc` or `--metrics-jvm-gc` flag.
42+
* JVM class loader metrics: the number of loaded and unloaded classes. These metrics
43+
are enabled with the `-mcl` or `--metrics-class-loader` flag.
4244
* Processor metrics: there metrics report CPU activity as gathered by the JVM.
4345
They can be enabled with the `-mjp` or `--metrics-processor` flag.
4446

47+
[WARNING]
48+
====
49+
The JVM-related metrics are not available when using the
50+
link:#native-executable[native executable].
51+
====
4552

4653
=== Tags
4754

src/docs/asciidoc/usage-advanced.adoc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ the content-type can be specified:
3333
bin/runjava com.rabbitmq.perf.PerfTest --consumers 0 \
3434
--body content1.json,content2.json --body-content-type application/json
3535

36-
== Working with many queues
36+
== Working With Many Queues
3737

3838
PertTest supports balancing the publishing and the consumption
3939
across a sequence of queues, e.g.:
@@ -114,7 +114,7 @@ at the OS level, as some distributions use very low limits.
114114
Here the recommendations are the same as for the broker, so you
115115
can refer to our https://www.rabbitmq.com/networking.html#os-tuning[networking guide].
116116

117-
== Workloads with a Large Number of Clients
117+
== Workloads With a Large Number of Clients
118118

119119
A typical connected device workload (a.k.a "IoT workload") involves
120120
many producers and consumers (dozens or hundreds of thousands)
@@ -277,6 +277,23 @@ a certificate/key pair generated by the aforementioned profile:
277277
JAVA_OPTS="-Djavax.net.ssl.trustStore=/path/to/server_key.p12 -Djavax.net.ssl.trustStorePassword=bunnies -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.keyStore=/path/to/client_key.p12 -Djavax.net.ssl.keyStorePassword=bunnies -Djavax.net.ssl.keyStoreType=PKCS12" \
278278
bin/runjava com.rabbitmq.perf.PerfTest -h amqps://localhost:5671
279279

280+
== Native Executable
281+
282+
PerfTest is also distributed as a https://www.graalvm.org/docs/reference-manual/aot-compilation/[native executable]
283+
built with https://www.graalvm.org/[GraalVM]. The native executable has the following
284+
advantages: it doesn't need a JVM to run, it has faster startup time
285+
and lower runtime memory overhead compared to a Java VM.
286+
287+
PerfTest native executable has also some limitations:
288+
289+
* link:#supported-metrics[JVM metrics] are not supported
290+
* it is not possible to configure logging
291+
292+
[WARNING]
293+
====
294+
The native executable is considered an experimental feature.
295+
====
296+
280297
== Result Reporting in HTML
281298

282299
The `PerfTest HTML extension` are a set of tools
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2018 Pivotal Software, Inc. All rights reserved.
2+
//
3+
// This software, the RabbitMQ Java client library, is triple-licensed under the
4+
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2
5+
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see
6+
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL,
7+
// please see LICENSE-APACHE2.
8+
//
9+
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
10+
// either express or implied. See the LICENSE file for specific language governing
11+
// rights and limitations of this software.
12+
//
13+
// If you have any questions regarding licensing, please contact us at
14+
15+
16+
package com.rabbitmq.perf;
17+
18+
import java.io.IOException;
19+
20+
/**
21+
* Stub to skip logback configuration.
22+
* <p>
23+
* Logback doesn't play well with a GraalVM native image, so
24+
* we use SL4J simple. Configuration happens at native image
25+
* generation time in {@link NativeImageFeature}.
26+
*
27+
* @since 2.4.0
28+
*/
29+
public class Log {
30+
31+
public static void configureLog() throws IOException {
32+
}
33+
34+
}

0 commit comments

Comments
 (0)