Skip to content

Commit 0023ea3

Browse files
committed
JBTM-4014-perf-test draft
1 parent 2bf0144 commit 0023ea3

File tree

6 files changed

+513
-1
lines changed

6 files changed

+513
-1
lines changed

narayana/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<module>ArjunaJTS/jts</module>
8888
<module>ArjunaJTA/jta</module>
8989
<module>ArjunaCore/arjuna</module>
90+
<module>stm</module>
9091
<module>tools</module>
9192
</modules>
9293

@@ -175,4 +176,4 @@
175176
</dependency>
176177
</dependencies>
177178
</dependencyManagement>
178-
</project>
179+
</project>

narayana/stm/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
mvn clean package
3+
java -jar target/benchmarks.jar
4+
5+
6+
I created 3 benchmarks (see https://github.com/jbosstm/performance/pull/185):
7+
LocalJTABenchmark.benchmark: starts a JTA txn and enlists a single XAResource and commits
8+
STMBenchmark.baseLineBenchmark: adds two integers together
9+
STMBenchmark.benchmark: starts an AtomicAction and increments and decrements two integers backed by transaction memory
10+
11+
I ran the benchmarks three times taking the best result from each.
12+
13+
Comparing the the % difference between the pr/2414 and main branches I found that
14+
15+
LocalJTABenchmark.benchmark: pr/2414 is 10% better
16+
STMBenchmark.baseLineBenchmark pr/2414 is 0.2% worse
17+
STMBenchmark.benchmark: pr/2414 is 0.25% worse
18+
19+
So if the LocalJTABenchmark result is repeatable then I think 10% gain is significant.
20+

narayana/stm/pom.xml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.jboss.narayana.stm</groupId>
6+
<artifactId>stm-benchmark</artifactId>
7+
<version>7.3.1.Final-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<name>JMH benchmarks: stm vs local jta</name>
11+
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.openjdk.jmh</groupId>
15+
<artifactId>jmh-core</artifactId>
16+
<version>${jmh.version}</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.openjdk.jmh</groupId>
20+
<artifactId>jmh-generator-annprocess</artifactId>
21+
<version>${jmh.version}</version>
22+
<scope>provided</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.jboss.narayana.arjunacore</groupId>
26+
<artifactId>arjunacore</artifactId>
27+
<version>${project.version}</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.jboss.narayana.jta</groupId>
31+
<artifactId>jta</artifactId>
32+
<version>${project.version}</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.jboss.narayana.stm</groupId>
36+
<artifactId>stm</artifactId>
37+
<version>${project.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>jakarta.transaction</groupId>
41+
<artifactId>jakarta.transaction-api</artifactId>
42+
<version>2.0.1</version>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.jboss</groupId>
47+
<artifactId>jboss-transaction-spi</artifactId>
48+
<version>7.6.1.Final</version>
49+
<exclusions>
50+
<exclusion>
51+
<groupId>org.jboss.logging</groupId>
52+
<artifactId>jboss-logging-spi</artifactId>
53+
</exclusion>
54+
</exclusions>
55+
</dependency>
56+
</dependencies>
57+
58+
<properties>
59+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
60+
<jmh.version>1.37</jmh.version>
61+
<javac.target>1.8</javac.target>
62+
<uberjar.name>benchmarks</uberjar.name>
63+
</properties>
64+
65+
<build>
66+
<plugins>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-compiler-plugin</artifactId>
70+
<version>3.8.0</version>
71+
<configuration>
72+
<compilerVersion>${javac.target}</compilerVersion>
73+
<source>${javac.target}</source>
74+
<target>${javac.target}</target>
75+
</configuration>
76+
</plugin>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-shade-plugin</artifactId>
80+
<version>3.2.1</version>
81+
<executions>
82+
<execution>
83+
<phase>package</phase>
84+
<goals>
85+
<goal>shade</goal>
86+
</goals>
87+
<configuration>
88+
<finalName>${uberjar.name}</finalName>
89+
<transformers>
90+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
91+
<mainClass>org.openjdk.jmh.Main</mainClass>
92+
</transformer>
93+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
94+
</transformers>
95+
<filters>
96+
<filter>
97+
<!--
98+
Shading signed JARs will fail without this.
99+
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
100+
-->
101+
<artifact>*:*</artifact>
102+
<excludes>
103+
<exclude>META-INF/*.SF</exclude>
104+
<exclude>META-INF/*.DSA</exclude>
105+
<exclude>META-INF/*.RSA</exclude>
106+
</excludes>
107+
</filter>
108+
</filters>
109+
</configuration>
110+
</execution>
111+
</executions>
112+
</plugin>
113+
</plugins>
114+
<pluginManagement>
115+
<plugins>
116+
<plugin>
117+
<artifactId>maven-clean-plugin</artifactId>
118+
<version>2.5</version>
119+
</plugin>
120+
<plugin>
121+
<artifactId>maven-deploy-plugin</artifactId>
122+
<version>2.8.1</version>
123+
</plugin>
124+
<plugin>
125+
<artifactId>maven-install-plugin</artifactId>
126+
<version>2.5.1</version>
127+
</plugin>
128+
<plugin>
129+
<artifactId>maven-jar-plugin</artifactId>
130+
<version>2.4</version>
131+
</plugin>
132+
<plugin>
133+
<artifactId>maven-javadoc-plugin</artifactId>
134+
<version>2.9.1</version>
135+
</plugin>
136+
<plugin>
137+
<artifactId>maven-resources-plugin</artifactId>
138+
<version>2.6</version>
139+
</plugin>
140+
<plugin>
141+
<artifactId>maven-site-plugin</artifactId>
142+
<version>3.3</version>
143+
</plugin>
144+
<plugin>
145+
<artifactId>maven-source-plugin</artifactId>
146+
<version>2.2.1</version>
147+
</plugin>
148+
<plugin>
149+
<artifactId>maven-surefire-plugin</artifactId>
150+
<version>2.17</version>
151+
</plugin>
152+
</plugins>
153+
</pluginManagement>
154+
</build>
155+
</project>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
Copyright The Narayana Authors
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
7+
8+
package org.jboss.narayana.stm;
9+
10+
import javax.transaction.xa.XAException;
11+
import javax.transaction.xa.XAResource;
12+
import javax.transaction.xa.Xid;
13+
import java.io.Serializable;
14+
15+
/*
16+
* Currently XAResources must be serializable so we can
17+
* recreate them in the event of a failure. It is likely
18+
* that other mechanisms will be added later to remove
19+
* this necessity, although serialization will still be
20+
* supported.
21+
*/
22+
23+
public class DummyXA implements XAResource, Serializable
24+
{
25+
private static final long serialVersionUID = -2285367224867593569L;
26+
27+
public DummyXA(boolean print)
28+
{
29+
_timeout = 0; // no timeout
30+
_print = print;
31+
}
32+
33+
public void commit (Xid xid, boolean onePhase) throws XAException
34+
{
35+
if (_print)
36+
System.out.println("DummyXA.commit called");
37+
}
38+
39+
public void end (Xid xid, int flags) throws XAException
40+
{
41+
if (_print)
42+
System.out.println("DummyXA.end called");
43+
}
44+
45+
public void forget (Xid xid) throws XAException
46+
{
47+
if (_print)
48+
System.out.println("DummyXA.forget called");
49+
}
50+
51+
public int getTransactionTimeout () throws XAException
52+
{
53+
if (_print)
54+
System.out.println("DummyXA.getTransactionTimeout called");
55+
56+
return _timeout;
57+
}
58+
59+
public int prepare (Xid xid) throws XAException
60+
{
61+
if (_print)
62+
System.out.println("DummyXA.prepare called");
63+
64+
return XAResource.XA_OK;
65+
}
66+
67+
public Xid[] recover (int flag) throws XAException
68+
{
69+
if (_print)
70+
System.out.println("DummyXA.recover called");
71+
72+
return null;
73+
}
74+
75+
public void rollback (Xid xid) throws XAException
76+
{
77+
if (_print)
78+
System.out.println("DummyXA.rollback called");
79+
}
80+
81+
public boolean setTransactionTimeout (int seconds) throws XAException
82+
{
83+
if (_print)
84+
System.out.println("DummyXA.setTransactionTimeout called");
85+
86+
_timeout = seconds;
87+
88+
return true;
89+
}
90+
91+
public void start (Xid xid, int flags) throws XAException
92+
{
93+
if (_print)
94+
System.out.println("DummyXA.start called");
95+
}
96+
97+
public boolean isSameRM (XAResource xares) throws XAException
98+
{
99+
if (_print)
100+
System.out.println("DummyXA.isSameRM called");
101+
102+
return (xares == this);
103+
}
104+
105+
private int _timeout;
106+
private boolean _print;
107+
108+
}

0 commit comments

Comments
 (0)