Skip to content

Commit

Permalink
Merge pull request #21 from judovana/dynamicAll
Browse files Browse the repository at this point in the history
make  detection of all GCs dynamic
  • Loading branch information
judovana committed Feb 29, 2024
2 parents 4f9411e + ced0baf commit 8b3ba8f
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bin/par.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
#
# set up GC_SPECIFIC_OPTS for parallel collector
# and append par tag to gc log file name
export GC_SPECIFIC_OPTS="-XX:+UseParallelGC -XX:+UseParallelOldGC"
export GC_SPECIFIC_OPTS="-XX:+UseParallelGC"
export GC_LOG_FILE="${GC_LOG_FILE}-par"
export OUT_LOG_FILE="${OUT_LOG_FILE}-par"
30 changes: 30 additions & 0 deletions bin/parold.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# JBoss, Home of Professional Open Source
# Copyright 2011, Red Hat and individual contributors
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
# @authors Andrew Dinn
#
# setup script to use parallel collector
#
# set up GC_SPECIFIC_OPTS for parallel collector
# and append par tag to gc log file name
export GC_SPECIFIC_OPTS="-XX:+UseParallelGC -XX:+UseParallelOldGC"
export GC_LOG_FILE="${GC_LOG_FILE}-parold"
export OUT_LOG_FILE="${OUT_LOG_FILE}-parold"
29 changes: 29 additions & 0 deletions bin/runparold-nocoops.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
#
# JBoss, Home of Professional Open Source
# Copyright 2011, Red Hat and individual contributors
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
# @authors Andrew Dinn
#
WD=`dirname $0`
. $WD/setup.sh
. $WD/parold.sh
. $WD/nocoops.sh
exec $WD/run.sh $*
28 changes: 28 additions & 0 deletions bin/runparold.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# JBoss, Home of Professional Open Source
# Copyright 2011, Red Hat and individual contributors
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
# @authors Andrew Dinn
#
WD=`dirname $0`
. $WD/setup.sh
. $WD/parold.sh
exec $WD/run.sh $*
47 changes: 32 additions & 15 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ done
readonly CH_SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
set -ex

function ljava() {
function getjava() {
if [ "x$JAVA_HOME" != "x" ]; then
LJAVA=${JAVA_HOME}/bin/java
LJAR=${JAVA_HOME}/bin/jar
Expand All @@ -30,9 +30,12 @@ function ljava() {
fi
}

function checkXX() {
${LJAVA} -XX:+PrintFlagsFinal -version 2>/dev/null | grep -e ${1}
}

function globalInfo() {
uname -a > outlog-global
ljava
${LJAVA} -version 2>>outlog-global || true
echo "NOCOMP=${NOCOMP}">>outlog-global
echo "GC=${GC}">>outlog-global
Expand Down Expand Up @@ -99,44 +102,59 @@ function tapResults() {
) || true
}

getjava

GC=${1}
if [ "x$GC" == "x" ] ; then
#todo add generational zgc since jdk21, todo add generational shenandoah sicnce jdk23?
if [ "x$OTOOL_garbageCollector" == "xshentraver" ] ; then
GC=shenandoah
elif [ "x$OTOOL_garbageCollector" == "xALL" ] ; then
if [ "x$OTOOL_JDK_VERSION" == "x" ] ; then
GC="shenandoah zgc cms par g1" ## unset, main set set
elif [ "0$OTOOL_JDK_VERSION" -le 7 ] ; then
GC=" cms par g1" ## we claim adoptium jdk8 as 7, as it do not have shenandoah.
elif [ "0$OTOOL_JDK_VERSION" -ge 8 -a "0$OTOOL_JDK_VERSION" -le 11 ] ; then
GC="shenandoah cms par g1" # zgc arrived in jdk11
elif [ "0$OTOOL_JDK_VERSION" -gt 11 -a "0$OTOOL_JDK_VERSION" -le 20 ] ; then
GC="shenandoah zgc g1" # no more cms or par
else
# in jdk 21 arrived generational zgc
GC="shenandoah zgc g1 zgcgen" # zgcgem arrived in jdk21
GC=""
if checkXX UseShenandoahGC ; then
GC="$GC shenandoah"
fi
if checkXX UseZGC ; then
GC="$GC zgc"
if checkXX ZGenerational ; then
GC="$GC zgcgen"
fi
fi
if checkXX UseConcMarkSweepGC ; then
GC="$GC cms"
fi
if checkXX UseParallelGC ; then
GC="$GC par"
if checkXX UseParallelOldGC ; then
GC="$GC parold"
fi
fi
if checkXX UseG1GC ; then
GC="$GC g1"
fi
elif [ "x$OTOOL_garbageCollector" == "xdefaultgc" ] ; then
if [ "0$OTOOL_JDK_VERSION" -le 8 ] ; then
GC=par
echo "double checking default gc is correct:"
checkXX UseParallelGC | grep true
else
GC=g1
echo "double checking default gc is correct:"
checkXX UseG1GC | grep true
fi
else
GC="$OTOOL_garbageCollector"
fi
fi

echo "GC=$GC" >&2

if [ "x$GC" == "x" ] ; then
echo 'expected exactly one command line argument - garbage collector [g1|cms|par|shenandoah] or use OTOOL_garbageCollector variabnle with same values + two more - "defaultgc" and "ALL", wich will cause this to use default gc or iterate through all GCs (time will be divided). You should accompany it by OTOOL_JDK_VERSION=<8..21> so the proper set of jdks is chosen. Use NOCOMP=-nocoops to disable compressed oops.' >&2
exit 1
fi

if [ ! "x$STAMP" == "x" ] ; then
ljava
arch=`uname -m | sed "s/[^a-zA-Z0-9_]//g"`
os=`uname -o | sed "s/[^a-zA-Z0-9_]//g"`
jdk=`${LJAVA} -version 2>&1 | head -n1 | sed -E "s/[^0-9]+/-/g"`
Expand Down Expand Up @@ -177,7 +195,6 @@ if [ ! -e ${CH_SCRIPT_DIR}/target ] ; then
mvn $MVOPTS install
popd
else
ljava
pushd $CH_SCRIPT_DIR/src/main/java/
${LJAVAC} -d $CH_SCRIPT_DIR/target/classes `find . -type f | grep ".java$"`
pushd $CH_SCRIPT_DIR/target/classes
Expand Down

0 comments on commit 8b3ba8f

Please sign in to comment.