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

Additional JMH tests (legacy) #3

Open
wants to merge 7 commits into
base: java21
Choose a base branch
from
Open
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
77 changes: 77 additions & 0 deletions hazelcast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
<pax.exam.version>2.6.0</pax.exam.version>
<pax.runner.version>1.8.6</pax.runner.version>
<javax.inject.version>1</javax.inject.version>
<jmh.version>1.37</jmh.version>
<uberjar.name>benchmarks</uberjar.name>
</properties>

<build>
Expand Down Expand Up @@ -203,6 +205,7 @@
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>default-shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
Expand Down Expand Up @@ -298,6 +301,68 @@
</filters>
</configuration>
</execution>
<execution>
<id>jmh-shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${uberjar.name}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>run-benchmarks</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>org.openjdk.jmh.Main</argument>
<argument>.*</argument>
<argument>-bm</argument>
<argument>avgt</argument>
<argument>-f</argument>
<argument>1</argument>
<argument>-tu</argument>
<argument>ms</argument>
<argument>-rff</argument>
<argument>jmh-results.csv</argument>
<argument>-o</argument>
<argument>jmh-results.txt</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -570,6 +635,18 @@
</build>

<dependencies>

<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>provided</scope>
</dependency>
<!-- Needed for TPC -->
<dependency>
<groupId>com.hazelcast</groupId>
Expand Down
35 changes: 30 additions & 5 deletions hazelcast/src/test/java/com/hazelcast/cluster/JoinStressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,40 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.TearDown;
import org.openjdk.jmh.annotations.Warmup;

@RunWith(HazelcastSerialClassRunner.class)
@Category(NightlyTest.class)
@State(Scope.Benchmark)
@Warmup(iterations = 5)
@BenchmarkMode({ Mode.AverageTime })
@Fork(value = 1, jvmArgs = { "-Xms1G", "-Xmx1G", "-XX:+UseG1GC" })
@Measurement(iterations = 5)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class JoinStressTest extends HazelcastTestSupport {

@Param({"10", "50", "100", "500", "1000", "5000"})
int count;

private static final long TEN_MINUTES_IN_MILLIS = 10 * 60 * 1000L;
private ILogger logger = Logger.getLogger(JoinStressTest.class);

@Before
@After
@Setup(Level.Invocation)
@TearDown(Level.Invocation)
public void tearDown() throws Exception {
HazelcastInstanceFactory.terminateAll();
}
Expand All @@ -88,8 +113,8 @@ public void testMulticastJoinWithManyNodes() throws InterruptedException {
}

@Test(timeout = TEN_MINUTES_IN_MILLIS)
@Benchmark
public void testJoinCompletesCorrectlyWhenMultipleNodesStartedParallel() {
int count = 10;
final TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(count);
final HazelcastInstance[] instances = new HazelcastInstance[count];
final CountDownLatch latch = new CountDownLatch(count);
Expand Down Expand Up @@ -244,6 +269,7 @@ private void initNetworkConfig(NetworkConfig networkConfig, int basePort, int po
}

@Test(timeout = 300000)
@Benchmark
public void testJoinWhenMemberClosedInBetween() throws InterruptedException {
//Test is expecting to all can join safely.
// On the failed case the last opened instance throws java.lang.IllegalStateException: Node failed to start!
Expand All @@ -254,11 +280,10 @@ public void testJoinWhenMemberClosedInBetween() throws InterruptedException {
HazelcastInstance i4 = Hazelcast.newHazelcastInstance(config);

final IMap<Integer, Integer> map = i4.getMap("a");
int numThreads = 40;
final int loop = 5000;

Thread[] threads = new Thread[numThreads];
for (int i = 0; i < numThreads; i++) {
Thread[] threads = new Thread[count];
for (int i = 0; i < count; i++) {
threads[i] = new Thread(() -> {
Random random = new Random();
for (int j = 0; j < loop; j++) {
Expand All @@ -285,7 +310,7 @@ public void testJoinWhenMemberClosedInBetween() throws InterruptedException {
//Should not throw java.lang.IllegalStateException: Node failed to start!
Hazelcast.newHazelcastInstance(config);

for (int i = 0; i < numThreads; i++) {
for (int i = 0; i < count; i++) {
threads[i].join();
}
}
Expand Down
88 changes: 88 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@
<module>hazelcast-build-utils</module>
<module>hazelcast-sql</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
<version>5.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>


<properties>
<main.basedir>${project.basedir}</main.basedir>
Expand Down Expand Up @@ -343,6 +355,71 @@
</executions>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>jmh-shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>benchmarks</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>run-benchmarks</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.openjdk.jmh.Main</argument>
<argument>.*</argument>
<argument>-bm</argument>
<argument>avgt</argument>
<argument>-f</argument>
<argument>1</argument>
<argument>-tu</argument>
<argument>ms</argument>
<argument>-rff</argument>
<argument>jmh-results.csv</argument>
<argument>-o</argument>
<argument>jmh-results.txt</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -1216,5 +1293,16 @@
<version>10.1.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.37</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Loading