Skip to content

Commit ec36c12

Browse files
committed
Adding the Idle Micro Benchmark into the openj9-systemtest repo.
The Idle Micro Benchmark has been written to test the Idle Tuning feature and its proper working. This test needs to be committed into the openj9-systemtest repo as a stress test. Signed-off-by: Tanvi Kini <[email protected]>
1 parent b08e1c5 commit ec36c12

File tree

15 files changed

+709
-2
lines changed

15 files changed

+709
-2
lines changed

openj9.build/build.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
2121
-->
2222

2323
<project name="openj9.build" default="build">
24-
2524
<!-- Set default for source_root. -->
2625
<property name="source_root" location=".."/>
2726

@@ -52,6 +51,8 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
5251
<ant antfile="${source_root}/openj9.test.load/build.xml" dir="${source_root}/openj9.test.load" inheritAll="false"/>
5352
<ant antfile="${source_root}/openj9.test.sharedClasses/build.xml" dir="${source_root}/openj9.test.sharedClasses" inheritAll="false"/>
5453
<ant antfile="${source_root}/openj9.test.sharedClasses.jvmti/build.xml" dir="${source_root}/openj9.test.sharedClasses.jvmti" inheritAll="false"/>
54+
<ant antfile="${source_root}/openj9.test.idle/build.xml" dir="${source_root}/openj9.test.idle" inheritAll="false"/>
55+
5556
</target>
5657

5758
<target name="build" depends="build-dependencies">

openj9.build/makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,22 @@ test.SharedClasses.SCM23.MultiThreadMultiCL:
532532
echo Running target $@
533533
$(STF_COMMAND) -test=SharedClasses -test-args="sharedClassMode=SCM23,sharedClassTest=MultiThreadMultiCL" $(LOG)
534534
echo Target $@ completed
535+
test.IdleBenchMark_MinIdleWaitTime:
536+
echo Running target $@
537+
$(STF_COMMAND) -test=IdleLoadTest -java-args="-XX:IdleTuningMinIdleWaitTime=180 -Xmx1024m -Xjit:verbose={compilePerformance},vlog=jitlog" $(LOG)
538+
echo Target $@ completed
539+
test.IdleBenchMark_GcOnIdle:
540+
echo Running target $@
541+
$(STF_COMMAND) -test=IdleLoadTest -java-args="-XX:+IdleTuningGcOnIdle -Xtune:virtualized -XX:IdleTuningMinIdleWaitTime=120 -Xmx1024m -verbose:gc -Xverbosegclog:gc.verbose -Xjit:verbose={compilePerformance},vlog=jitlog" $(LOG)
542+
echo Target $@ completed
543+
test.IdleBenchMark_CompactOnIdle:
544+
echo Running target $@
545+
$(STF_COMMAND) -test=IdleLoadTest -java-args="-XX:+IdleTuningCompactOnIdle -Xtune:virtualized -XX:IdleTuningMinIdleWaitTime=120 -Xmx1024m -verbose:gc -Xverbosegclog:gc.verbose -Xjit:verbose={compilePerformance},vlog=jitlog" $(LOG)
546+
echo Target $@ completed
535547

536548
help:
537549
@echo make or make build: Builds openj9-systemtest projects
538550
@echo make test: Runs all openj9-systemtest tests
539551
@echo make $(TEST_TARGETS): Runs all openj9-systemtest tests
540552
@echo make test.xxxx: Runs individual test xxxx
541-
553+

openj9.test.idle/build.xml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (c) 2017 IBM Corp.
4+
5+
This program and the accompanying materials are made available under the
6+
terms of the Eclipse Public License 2.0 which accompanies this distribution
7+
and is available at http://eclipse.org/legal/epl-2.0 or the Apache License,
8+
Version 2.0 which accompanies this distribution and is available at
9+
https://www.apache.org/licenses/LICENSE-2.0.
10+
11+
This Source Code may also be made available under the following Secondary
12+
Licenses when the conditions for such availability set forth in the
13+
Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
14+
version 2 with the GNU Classpath Exception [1] and GNU General Public License,
15+
version 2 with the OpenJDK Assembly Exception [2].
16+
17+
[1] https://www.gnu.org/software/classpath/license.html
18+
[2] http://openjdk.java.net/legal/assembly-exception.html
19+
20+
SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
21+
-->
22+
23+
<project name="openj9.test.idle" default="build">
24+
25+
<!-- Set default for source_root. -->
26+
<property name="source_root" location="../"/>
27+
28+
<!-- Set default for STF location. -->
29+
<!-- Assumes source repositories are checked out under a common root - e.g. and the repository
30+
has been built in-situ - i.e.
31+
stf repository: /home/userid/git/stf
32+
java.svt repository: /home/userid/git/java.svt
33+
If the stf repository has been cloned or built to a different location, the stf_root property
34+
must be set on the command line - e.g. -Dstf_root=/my_stf_build_dir
35+
-->
36+
<property name="stf_root" location="${source_root}/../stf"/>
37+
38+
<!-- Import settings used by multiple projects. -->
39+
<import file="${source_root}/openj9.build/include/top.xml"/>
40+
41+
<!-- For modularity you need a directory above the package structure to hold the module.java file -->
42+
<property name="module" value="test.idle" />
43+
<property name="src_dir" value="src/${module}" />
44+
<property name="bin_dir" value="bin" />
45+
46+
<property name="jar_file" value="${bin_dir}/${module}.jar" />
47+
48+
<!-- We need junit and stf to compile this project. -->
49+
<path id="project.class.path">
50+
<path refid="junit.class.path" />
51+
<path refid="stf.class.path" />
52+
</path>
53+
54+
<!-- Projects which need to be built before this one. -->
55+
<!-- dir must be set on the ant task otherwise the basedir property is not set to a new value in the subant task. -->
56+
<target name="build-dependencies">
57+
<!-- <ant antfile="${stf_root}/stf.build/build.xml" dir="${stf_root}/stf.build" inheritAll="false"/> -->
58+
</target>
59+
60+
<target name="build" depends="build-no-natives, build-natives">
61+
</target>
62+
63+
<target name="build-no-natives" depends="build-dependencies, check-prereqs, build-archives">
64+
</target>
65+
66+
<target name="build-natives">
67+
</target>
68+
69+
<target name="build-archives" depends="build-jar">
70+
</target>
71+
72+
<target name="build-jar" depends="build-java, create-bin-dir">
73+
<jar destfile="${jar_file}">
74+
<fileset dir="${bin_dir}" includes="**/*.class" />
75+
</jar>
76+
</target>
77+
78+
<target name="build-java" depends="check-prereqs, create-bin-dir">
79+
<!--
80+
The Ant javac task only checks time dependencies between .java files and their .class files,
81+
so fails to recompile in situations such as the signatures of a dependent method changing.
82+
The depend target checks the dependencies and deletes any .class files older than the files
83+
which depend on them, thereby ensuring recompilation.
84+
-->
85+
<depend srcdir="${src_dir}" destdir="${bin_dir}" classpathref="project.class.path">
86+
<include name="**/*.java"/>
87+
</depend>
88+
<javac srcdir="${src_dir}"
89+
destdir="${bin_dir}"
90+
fork="true"
91+
executable="${java8_compiler}"
92+
debug="true"
93+
classpathref="project.class.path"
94+
encoding="UTF-8"
95+
includeantruntime="false"
96+
failonerror="true">
97+
<include name="**/*.java"/>
98+
</javac>
99+
</target>
100+
101+
<target name="create-bin-dir">
102+
<mkdir dir="${bin_dir}"/>
103+
</target>
104+
105+
<target name="clean">
106+
<delete dir="${bin_dir}"/>
107+
</target>
108+
109+
</project>
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2017 IBM Corp.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which accompanies this distribution
6+
* and is available at http://eclipse.org/legal/epl-2.0 or the Apache License,
7+
* Version 2.0 which accompanies this distribution and is available at
8+
* https://www.apache.org/licenses/LICENSE-2.0.
9+
*
10+
* This Source Code may also be made available under the following Secondary
11+
* Licenses when the conditions for such availability set forth in the
12+
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
13+
* version 2 with the GNU Classpath Exception [1] and GNU General Public License,
14+
* version 2 with the OpenJDK Assembly Exception [2].
15+
*
16+
* [1] https://www.gnu.org/software/classpath/license.html
17+
* [2] http://openjdk.java.net/legal/assembly-exception.html
18+
*
19+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
20+
*******************************************************************************/
21+
package net.openj9.test;
22+
23+
import java.io.File;
24+
import java.io.IOException;
25+
import java.util.Random;
26+
import java.util.concurrent.Callable;
27+
import java.util.Calendar;
28+
import java.util.Date;
29+
import java.awt.image.BufferedImage;
30+
import java.text.DateFormat;
31+
import java.text.SimpleDateFormat;
32+
import javax.imageio.ImageIO;
33+
import java.lang.management.ManagementFactory;
34+
35+
import net.openj9.test.LargeObj;
36+
37+
38+
public class CombinedLoad implements Callable<Long>
39+
{
40+
private int workloadImageNumber;
41+
private long threadId;
42+
private long busyTime = 0;
43+
private long memoryLimitInBytes = 0L;
44+
private final int numObjs = 10000;
45+
private long numtrans = 0;
46+
47+
public CombinedLoad(int workloadTypeNum, long mSec, long memLimitInBytes) {
48+
workloadImageNumber = workloadTypeNum;
49+
busyTime = mSec * 1000000L ;
50+
memoryLimitInBytes = memLimitInBytes;
51+
}
52+
53+
public long getTrans() {
54+
return numtrans;
55+
}
56+
57+
public void resetTrans() {
58+
numtrans = 0;
59+
}
60+
61+
public long getThreadId() {
62+
return threadId;
63+
}
64+
65+
public Long call() {
66+
Date dateobj;
67+
Calendar calobj;
68+
long startTime = 0;
69+
long currTime = 0;
70+
float diff = 0;
71+
LargeObj[] memoryFill = new LargeObj[numObjs];
72+
DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
73+
java.lang.management.MemoryMXBean membean = ManagementFactory.getMemoryMXBean();
74+
long heapInBytes = 0L;
75+
76+
threadId = Thread.currentThread().getId();
77+
startTime = System.nanoTime();
78+
System.out.println("Test Application: CPU: Thread: " + threadId + " busy looping start");
79+
do {
80+
File iFile;
81+
BufferedImage image;
82+
83+
if ( System.getProperty("isIdle").equals("true") ) {
84+
System.out.println("App is going IDLE.. Stop working.. zzzzzz");
85+
break;
86+
}
87+
88+
// This loop tries to wake up JIT by running for 30 secs
89+
long busyTime = 30000 * 1000000L;
90+
while ((System.nanoTime() - startTime) < busyTime) {
91+
Random rand = new Random();
92+
double result = java.lang.Math.log(rand.nextDouble());
93+
}
94+
95+
for (int i = 0; i < 10000 ; i++) {
96+
97+
dateobj = new Date();
98+
calobj = Calendar.getInstance();
99+
currTime = System.nanoTime();
100+
diff = (float) ((float) (currTime - startTime) / (float) 1000000);
101+
for (int j = 0; j < numObjs; j++) {
102+
memoryFill[j] = new LargeObj(diff);
103+
}
104+
105+
if (diff == 1.000000 || diff == 2.000000 || diff == 3.000000 || diff == 4.000000 || diff == 5.000000) {
106+
System.out.println("CurrTime: " + currTime + " startTime: " + startTime + " busyTime: " + busyTime + " diff: " + diff);
107+
}
108+
if (diff > 6) {
109+
break;
110+
}
111+
}
112+
113+
try {
114+
if( System.getProperty("isIdle").equals("true") ) {
115+
System.out.println("App is going IDLE.. Stop working.. zzzzzz");
116+
break;
117+
}
118+
switch(workloadImageNumber) {
119+
case 0:
120+
iFile = new File("images/1KbImage.jpg");
121+
break;
122+
case 1:
123+
iFile = new File("images/500KbImage.jpg");
124+
break;
125+
case 2:
126+
iFile = new File("images/1MbImage.jpg");
127+
break;
128+
case 3:
129+
iFile = new File("images/1point5MbImage.jpg");
130+
break;
131+
case 4:
132+
iFile = new File("images/2MbImage.jpg");
133+
break;
134+
case 5:
135+
iFile = new File("images/5MbImage.jpg");
136+
break;
137+
case 6:
138+
iFile = new File("images/15point5MbImage.png");
139+
break;
140+
default :
141+
iFile = new File("images/1MbImage.jpg");
142+
}
143+
image = ImageIO.read(iFile);
144+
}catch (IOException e) {
145+
System.err.println("Error reading image file\n");
146+
}
147+
148+
iFile = null;
149+
image = null;
150+
currTime = System.nanoTime();
151+
numtrans++;
152+
heapInBytes = membean.getHeapMemoryUsage().getUsed();
153+
154+
} while((currTime - startTime) < busyTime && heapInBytes <= memoryLimitInBytes);
155+
156+
System.out.println("Test Application: Thread: " + threadId + " busy looping done; Num-trans: " + numtrans);
157+
return threadId;
158+
}
159+
}

0 commit comments

Comments
 (0)