forked from parzonka/prm4j-eval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavamop
executable file
·108 lines (91 loc) · 4.66 KB
/
javamop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
#
# Compiles, runs and evaluations JavaMOP aspects with the DaCapo-9.12-bach benchmark using aspectj load-time weaving.
#
#
# usage: ./javamop <list of parametric properties> <list of benchmarks>
# Runs an evaluation of JavaMOP monitoring a parametric property in the given list of parametric properties
# and benchmark in the given list of DacCapo benchmarks.
#
# examples: ./javamop HasNext avrora
# ./javamop "HasNext UnsafeMapIterator" "avrora h2 tradebeans"
#
# usage: ./javamop (parameterless)
# Runs an evaluation of JavaMOP monitoring a parametric properties in {HasNext UnsafeIterator UnsafeMapIterator
# SafeSyncCollection SafeSyncMap} using a DacCapo benchmark in {avrora batik eclipse fop h2 jython luindex
# pmd sunflow tomcat tradebeans tradesoap xalan}.
#
# notes: A list of all monitored properties can be found in target/jars/mop; each jar is a property
# A list of all benchmarks can be found at http://dacapobench.org/benchmarks.html
# Benchmark "lusearch" is not used because of random crashes in lucine on the evaluation hardware.
#
#
# CONFIGURATION:
invocations=5 # sets the number of JVM invocations
maxIterations=25 # sets the maximal number iterations per JVM invocation
######################################################################################################################
if [ -z "$1" ]; then
paramProperties="HasNext UnsafeIterator UnsafeMapIterator SafeSyncCollection SafeSyncMap"
else
paramProperties=$1
fi
if [ -z "$2" ]; then
benchmarks="avrora batik eclipse fop h2 jython luindex pmd sunflow tomcat tradebeans tradesoap xalan"
else
benchmarks=$2
fi
# remember directory where this script is called (some benchmarks need absolute paths)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Resolving maven dependencies... (may take a while)"
mvn dependency:resolve --update-snapshots
# get and process classpath from maven pom
mvn -q dependency:build-classpath -Dmdep.outputFile=dependency-outputfile
tr ':' '\n' < dependency-outputfile > dependency-list
# get classpaths to local maven repo
AJC=$(grep "aspectjtools" dependency-list)
RT=$(grep "aspectjrt" dependency-list)
WEAVER=$(grep "aspectjweaver" dependency-list)
JAVAMOPRT=$(grep "javamoprt" dependency-list)
GUAVA=$(grep "guava" dependency-list)
APACHEMATH=$(grep "math3" dependency-list)
DACAPO=$(grep "dacapo" dependency-list)
# cleanup tempfiles
rm dependency-outputfile dependency-list
# create working and target directories
rm -rf target
mkdir -p target/classes/META-INF target/jars/mop
mkdir -p logs
# compile the aspect into classes
echo "Compiling aspect..."
java -jar $AJC -cp "${RT}:${JAVAMOPRT}:$DACAPO:$GUAVA:$APACHEMATH" src/main/java/mop/* -d target/classes -6
# create jar with callback
javac src/main/java/prm4jeval/*.java -d target/classes -cp "$DACAPO:$APACHEMATH:$GUAVA"
jar cf target/jars/Callback.jar -C target/classes .
echo "Will perform ${invocations} JVM invocations with parametric properties in (${paramProperties}) and benchmarks in (${benchmarks}) until reaching static state (max. $maxIterations iterations)."
# load-time weaving via aspectjweaver, will run the specified number of invocations with up to 25 iterations
for invocation in $(jot $invocations 1) ; do
for paramProperty in $paramProperties ; do
# create custom aop-ajc.xml and put in META-INF
sed 's/<aspectname>/mop.'$paramProperty'MonitorAspect/g' src/main/resources/mop/aop-ajc.xml > target/classes/META-INF/aop-ajc.xml
# repackage each aspect into a single jars with the custom aop-ajc.xml
jar cf target/jars/mop/${paramProperty}.jar -C target/classes META-INF/aop-ajc.xml -C target/classes mop/${paramProperty}Monitor.class -C target/classes mop/${paramProperty}Monitor_Set.class -C target/classes mop/${paramProperty}MonitorAspect.class -C target/classes mop/MemoryLogger.class
# cleanup custom aop-ajc.xml
rm target/classes/META-INF/aop-ajc.xml
for benchmark in $benchmarks ; do
STATUS=0
while [ $STATUS -eq 0 ]; do
echo "Starting benchmark [javamop:$benchmark:$paramProperty] JVM invocation $invocation..."
java -Xmx2048M -javaagent:"$WEAVER" -Xbootclasspath/a:"$RT" \
-Dprm4jeval.outputfile=logs/javamop.log \
-Dprm4jeval.statsLogging=true \
-Dprm4jeval.benchmark="${benchmark}" \
-Dprm4jeval.paramProperty="${paramProperty}" \
-Dprm4jeval.invocation="${invocation}" \
-Dprm4jeval.maxIterations=${maxIterations} \
-cp "$DACAPO:$GUAVA:$JAVAMOPRT:$APACHEMATH:${DIR}/target/jars/mop/$paramProperty.jar:${DIR}/target/jars/Callback.jar" \
Harness --no-validation -c prm4jeval.EvalCallback $benchmark
STATUS=$?
done
done
done
done