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

Adding the Idle Micro Benchmark into the openj9-systemtest repo. #13

Open
wants to merge 5 commits into
base: master
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
2 changes: 1 addition & 1 deletion openj9.build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-excepti
-->

<project name="openj9.build" default="build">

<!-- Set default for source_root. -->
<property name="source_root" location=".."/>

Expand Down Expand Up @@ -52,6 +51,7 @@ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-excepti
<ant antfile="${source_root}/openj9.test.load/build.xml" dir="${source_root}/openj9.test.load" inheritAll="false"/>
<ant antfile="${source_root}/openj9.test.sharedClasses/build.xml" dir="${source_root}/openj9.test.sharedClasses" inheritAll="false"/>
<ant antfile="${source_root}/openj9.test.sharedClasses.jvmti/build.xml" dir="${source_root}/openj9.test.sharedClasses.jvmti" inheritAll="false"/>
<ant antfile="${source_root}/openj9.test.idle/build.xml" dir="${source_root}/openj9.test.idle" inheritAll="false"/>
<ant antfile="${source_root}/openj9.test.jlm/build.xml" dir="${source_root}/openj9.test.jlm" inheritAll="false"/>
</target>

Expand Down
25 changes: 24 additions & 1 deletion openj9.build/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -416,19 +416,28 @@ test.SharedClasses.SCM23.MultiThread \
test.SharedClasses.SCM23.MultiThreadMultiCL
SHARED_CLASSES_TESTS:=$(filter-out $(EXCLUDE),$(SHARED_CLASSES_TESTS))


IDLE_TESTS:=test.IdleBenchMark_MinIdleWaitTime \
test.IdleBenchMark_GcOnIdle \
test.IdleBenchMark_CompactOnIdle
IDLE_TESTS:=$(filter-out $(EXCLUDE),$(IDLE_TESTS))

JLM_TESTS:=test.TestIBMJlmLocal \
test.TestIBMJlmRemoteClassAuth \
test.TestIBMJlmRemoteClassNoAuth \
test.TestIBMJlmRemoteMemoryAuth \
test.TestIBMJlmRemoteMemoryNoAuth
JLM_TESTS:=$(filter-out $(EXCLUDE),$(JLM_TESTS))


TEST_TARGETS:=test.list \
test.help \
$(DAA_TESTS) \
$(GC_TESTS) \
$(SHARED_CLASSES_TESTS) \
$(IDLE_TESTS) \
$(JLM_TESTS)

TEST_TARGETS:=$(filter-out $(EXCLUDE),$(TEST_TARGETS))

.PHONY: build configure clean refresh_source test $(TEST_TARGETS)
Expand All @@ -455,6 +464,7 @@ test: $(TEST_TARGETS)
test.daa: $(DAA_TESTS)
test.gc: $(GC_TESTS)
test.SharedClasses: $(SHARED_CLASSES_TESTS)
test.idle: $(IDLE_TESTS)
test.jlm: $(JLM_TESTS)

test.list:
Expand Down Expand Up @@ -541,6 +551,18 @@ test.SharedClasses.SCM23.MultiThreadMultiCL:
echo Running target $@
$(STF_COMMAND) -test=SharedClasses -test-args="sharedClassMode=SCM23,sharedClassTest=MultiThreadMultiCL" $(LOG)
echo Target $@ completed
test.IdleBenchMark_MinIdleWaitTime:
echo Running target $@
$(STF_COMMAND) -test=IdleLoadTest -test-args="variation=MinIdleWaitTime" $(LOG)
echo Target $@ completed
test.IdleBenchMark_GcOnIdle:
echo Running target $@
$(STF_COMMAND) -test=IdleLoadTest -test-args="variation=GcOnIdle" $(LOG)
echo Target $@ completed
test.IdleBenchMark_CompactOnIdle:
echo Running target $@
$(STF_COMMAND) -test=IdleLoadTest -test-args="variation=CompactOnIdle" $(LOG)
echo Target $@ completed
test.TestIBMJlmLocal:
echo Running target $@
$(STF_COMMAND) -test=TestIBMJlmLocal $(LOG)
Expand All @@ -562,9 +584,10 @@ test.TestIBMJlmRemoteMemoryNoAuth:
$(STF_COMMAND) -test=TestIBMJlmRemoteMemoryNoAuth $(LOG)
echo Target $@ completed


help:
@echo make or make build: Builds openj9-systemtest projects
@echo make test: Runs all openj9-systemtest tests
@echo make $(TEST_TARGETS): Runs all openj9-systemtest tests
@echo make test.xxxx: Runs individual test xxxx


109 changes: 109 additions & 0 deletions openj9.test.idle/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2017 IBM Corp.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which accompanies this distribution
and is available at http://eclipse.org/legal/epl-2.0 or the Apache License,
Version 2.0 which accompanies this distribution and is available at
https://www.apache.org/licenses/LICENSE-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception [1] and GNU General Public License,
version 2 with the OpenJDK Assembly Exception [2].

[1] https://www.gnu.org/software/classpath/license.html
[2] http://openjdk.java.net/legal/assembly-exception.html

SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
-->

<project name="openj9.test.idle" default="build">

<!-- Set default for source_root. -->
<property name="source_root" location="../"/>

<!-- Set default for STF location. -->
<!-- Assumes source repositories are checked out under a common root - e.g. and the repository
has been built in-situ - i.e.
stf repository: /home/userid/git/stf
java.svt repository: /home/userid/git/java.svt
If the stf repository has been cloned or built to a different location, the stf_root property
must be set on the command line - e.g. -Dstf_root=/my_stf_build_dir
-->
<property name="stf_root" location="${source_root}/../stf"/>

<!-- Import settings used by multiple projects. -->
<import file="${source_root}/openj9.build/include/top.xml"/>

<!-- For modularity you need a directory above the package structure to hold the module.java file -->
<property name="module" value="test.idle" />
<property name="src_dir" value="src/${module}" />
<property name="bin_dir" value="bin" />

<property name="jar_file" value="${bin_dir}/${module}.jar" />

<!-- We need junit and stf to compile this project. -->
<path id="project.class.path">
<path refid="junit.class.path" />
<path refid="stf.class.path" />
</path>

<!-- Projects which need to be built before this one. -->
<!-- dir must be set on the ant task otherwise the basedir property is not set to a new value in the subant task. -->
<target name="build-dependencies">
<!-- <ant antfile="${stf_root}/stf.build/build.xml" dir="${stf_root}/stf.build" inheritAll="false"/> -->
</target>

<target name="build" depends="build-no-natives, build-natives">
</target>

<target name="build-no-natives" depends="build-dependencies, check-prereqs, build-archives">
</target>

<target name="build-natives">
</target>

<target name="build-archives" depends="build-jar">
</target>

<target name="build-jar" depends="build-java, create-bin-dir">
<jar destfile="${jar_file}">
<fileset dir="${bin_dir}" includes="**/*.class" />
</jar>
</target>

<target name="build-java" depends="check-prereqs, create-bin-dir">
<!--
The Ant javac task only checks time dependencies between .java files and their .class files,
so fails to recompile in situations such as the signatures of a dependent method changing.
The depend target checks the dependencies and deletes any .class files older than the files
which depend on them, thereby ensuring recompilation.
-->
<depend srcdir="${src_dir}" destdir="${bin_dir}" classpathref="project.class.path">
<include name="**/*.java"/>
</depend>
<javac srcdir="${src_dir}"
destdir="${bin_dir}"
fork="true"
executable="${java8_compiler}"
debug="true"
classpathref="project.class.path"
encoding="UTF-8"
includeantruntime="false"
failonerror="true">
<include name="**/*.java"/>
</javac>
</target>

<target name="create-bin-dir">
<mkdir dir="${bin_dir}"/>
</target>

<target name="clean">
<delete dir="${bin_dir}"/>
</target>

</project>
29 changes: 29 additions & 0 deletions openj9.test.idle/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
openj9.test.idle
- This project contains a stress version of the Idle Micro Benchmark test which aims to test the Idle detection and management feature available in J9 vm. For more information on the feature and related -XX JVM options, visit : https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.lnx.80.doc/diag/appendixes/cmdline/commands_jvm_xx.html.
- The test has been written to have alternating active and idle cycles.
- Active cycles are periods of time when the test will perform CPU and Memory Intensive operations to consume CPU cycles and Heap Memory.
- Idle cycles are longer periods of time where the test sleeps/ performs no activity.
- Idle detection and management are enabled/disabled via newly added JVM options.
- The Idle detection feature is available on all platforms whereas Idle management feature is supported only on Linux x86 platforms.
- The test exercises the newly added JVM options and checks if they behave as expected under stress conditions.

- There are 3 variations to this test

1. MinIdleWaitTime
- Tests the -XX:IdleTuningMinIdleWaitTime option. This is the minimum amount of time the application needs to be idle to be detected as Idle.
- Applicable on all platforms.
- Uses the following Java arguments while running the test
-XX:IdleTuningMinIdleWaitTime=180 -Xmx1024m -Xjit:verbose={compilePerformance},vlog=jitlog

2. GcOnIdle
- Tests the -XX:+IdleTuningGcOnIdle and when enabled, GC kicks in during the Idle cycle and reduces the footprint of the application.
- Applicable only on Linux_x86-32 and Linux_x86-64 platforms as of now.
- Uses the following JVM arguments while running the test
-XX:+IdleTuningGcOnIdle -Xtune:virtualized -XX:IdleTuningMinIdleWaitTime=120 -Xmx1024m -verbose:gc -Xverbosegclog:gc.verbose -Xjit:verbose={compilePerformance},vlog=jitlog" $(LOG)

3. CompactOnIdle
- Tests the -XX:+IdleTuningCompactOnIdle and when enabled, GC performs compaction on the heap during idle cycle to create contiguious free memory spaces for newer allocations.
- Applicable only on Linux_x86-32 and Linux_x86-64 platforms as of now.
- Uses the following JVM arguments while running the test
-XX:+IdleTuningCompactOnIdle -Xtune:virtualized -XX:IdleTuningMinIdleWaitTime=120 -Xmx1024m -verbose:gc -Xverbosegclog:gc.verbose -Xjit:verbose={compilePerformance},vlog=jitlog

159 changes: 159 additions & 0 deletions openj9.test.idle/src/test.idle/net/openj9/test/CombinedLoad.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*******************************************************************************
* Copyright (c) 2017 IBM Corp.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which accompanies this distribution
* and is available at http://eclipse.org/legal/epl-2.0 or the Apache License,
* Version 2.0 which accompanies this distribution and is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception [1] and GNU General Public License,
* version 2 with the OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package net.openj9.test;

import java.io.File;
import java.io.IOException;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.Calendar;
import java.util.Date;
import java.awt.image.BufferedImage;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.imageio.ImageIO;
import java.lang.management.ManagementFactory;

import net.openj9.test.LargeObj;


public class CombinedLoad implements Callable<Long>
{
private int workloadImageNumber;
private long threadId;
private long busyTime = 0;
private long memoryLimitInBytes = 0L;
private final int numObjs = 10000;
private long numtrans = 0;

public CombinedLoad(int workloadTypeNum, long mSec, long memLimitInBytes) {
workloadImageNumber = workloadTypeNum;
busyTime = mSec * 1000000L ;
memoryLimitInBytes = memLimitInBytes;
}

public long getTrans() {
return numtrans;
}

public void resetTrans() {
numtrans = 0;
}

public long getThreadId() {
return threadId;
}

public Long call() {
Date dateobj;
Calendar calobj;
long startTime = 0;
long currTime = 0;
float diff = 0;
LargeObj[] memoryFill = new LargeObj[numObjs];
DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
java.lang.management.MemoryMXBean membean = ManagementFactory.getMemoryMXBean();
long heapInBytes = 0L;

threadId = Thread.currentThread().getId();
startTime = System.nanoTime();
System.out.println("Test Application: CPU: Thread: " + threadId + " busy looping start");
do {
File iFile;
BufferedImage image;

if ( System.getProperty("isIdle").equals("true") ) {
System.out.println("App is going IDLE.. Stop working.. zzzzzz");
break;
}

// This loop tries to wake up JIT by running for 30 secs
long busyTime = 30000 * 1000000L;
while ((System.nanoTime() - startTime) < busyTime) {
Random rand = new Random();
double result = java.lang.Math.log(rand.nextDouble());
}

for (int i = 0; i < 10000 ; i++) {

dateobj = new Date();
calobj = Calendar.getInstance();
currTime = System.nanoTime();
diff = (float) ((float) (currTime - startTime) / (float) 1000000);
for (int j = 0; j < numObjs; j++) {
memoryFill[j] = new LargeObj(diff);
}

if (diff == 1.000000 || diff == 2.000000 || diff == 3.000000 || diff == 4.000000 || diff == 5.000000) {
System.out.println("CurrTime: " + currTime + " startTime: " + startTime + " busyTime: " + busyTime + " diff: " + diff);
}
if (diff > 6) {
break;
}
}

try {
if( System.getProperty("isIdle").equals("true") ) {
System.out.println("App is going IDLE.. Stop working.. zzzzzz");
break;
}
switch(workloadImageNumber) {
case 0:
iFile = new File("images/1KbImage.jpg");
break;
case 1:
iFile = new File("images/500KbImage.jpg");
break;
case 2:
iFile = new File("images/1MbImage.jpg");
break;
case 3:
iFile = new File("images/1point5MbImage.jpg");
break;
case 4:
iFile = new File("images/2MbImage.jpg");
break;
case 5:
iFile = new File("images/5MbImage.jpg");
break;
case 6:
iFile = new File("images/15point5MbImage.png");
break;
default :
iFile = new File("images/1MbImage.jpg");
}
image = ImageIO.read(iFile);
}catch (IOException e) {
System.err.println("Error reading image file\n");
}

iFile = null;
image = null;
currTime = System.nanoTime();
numtrans++;
heapInBytes = membean.getHeapMemoryUsage().getUsed();

} while((currTime - startTime) < busyTime && heapInBytes <= memoryLimitInBytes);

System.out.println("Test Application: Thread: " + threadId + " busy looping done; Num-trans: " + numtrans);
return threadId;
}
}
Loading