Skip to content

Commit

Permalink
1. avoid break the while loop in getMemoryUsageFromProc and useJcmdPr…
Browse files Browse the repository at this point in the history
…intMemoryUsage; 2. support mmap mememory in check-native-memory-usage.pl
  • Loading branch information
sendaoYan committed Sep 14, 2024
1 parent 4046443 commit 441c58f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ if [ "${COMPILEJAVA}" = "" ]; then
COMPILEJAVA="${TESTJAVA}"
fi

loopCount=40
if [[ -n "$1" ]] ; then
loopCount=$1
fi

# set platform-dependent variables
OS=`uname -s`
case "$OS" in
Expand Down Expand Up @@ -83,9 +88,15 @@ useJcmdPrintMemoryUsage()
{
pid=$1
javaLog=$2
i=0
while ! grep -q "For random generator using seed" ${javaLog}
do
sleep 0.1 #wait util java main function start finish
if [[ $i -ge 100 ]] ; then
echo "The tested java seems work abnormally!"
exit 1
fi
let i++
done
i=0
rm -rf *-native_memory-summary.log
Expand Down Expand Up @@ -114,9 +125,15 @@ getMemoryUsageFromProc()
{
pid=$1
javaLog=$2
i=0
while ! grep -q "For random generator using seed" ${javaLog}
do
sleep 0.1 #wait util java main function start finish
if [[ $i -ge 100 ]] ; then
echo "The tested java seems work abnormally!"
exit 1
fi
let i++
done
mkdir -p plot-data
rm -rf proc-*.csv plot-data/proc-*.txt
Expand Down Expand Up @@ -172,12 +189,12 @@ generatePlotPNG()

set -x
commonJvmOptions="-Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-DeoptimizeRandom \
-XX:CompileCommand=dontinline,compiler.codecache.stress.Helper$TestCase::method -XX:NativeMemoryTracking=summary"
-XX:CompileCommand=dontinline,compiler.codecache.stress.Helper\$TestCase::method -XX:NativeMemoryTracking=summary"

rm -rf java.log plot-data
mkdir -p plot-data
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -XX:+SegmentedCodeCache ${commonJvmOptions} \
-Dtest.src=${TESTSRC} -cp ${TESTCLASSPATH} compiler.codecache.stress.UnexpectedDeoptimizationTestLoop 40 &> java.log &
-Dtest.src=${TESTSRC} -cp ${TESTCLASSPATH} compiler.codecache.stress.UnexpectedDeoptimizationTestLoop ${loopCount} &> java.log &
pid=$!
ps -ef | grep java | grep UnexpectedDeoptimizationTestLoop &> ps-java.log
getMemoryUsageFromProc ${pid} java.log 2> proc-detail-stderr.log &
Expand All @@ -187,9 +204,11 @@ if grep -q "Unable to open socket file" *-native_memory-summary.log ; then
exit 1
fi

perl ${TESTSRC}/get-native-memory-usage.pl `ls *-native_memory-summary.log | sort -n | xargs`
( set +x ; perl ${TESTSRC}/get-native-memory-usage.pl `ls *-native_memory-summary.log | sort -n | xargs` )
generatePlotPNG
perl ${TESTSRC}/check-native-memory-usage.pl 1 `ls *-native_memory-summary.log | sort -n | xargs`
( set +x ; perl ${TESTSRC}/check-native-memory-usage.pl 1 `ls *-native_memory-summary.log | sort -n | xargs` )
exitCode=$?

mkdir -p native_memory-summary ; mv *-native_memory-summary.log native_memory-summary/

exit ${exitCode}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Copyright (c) 2024 Alibaba Group Holding Limited. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code 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 General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.

# @test
# @key stress randomness
# @summary check memory usage of optimizations and deoptimizations
# @library /test/lib /
# @modules java.base/jdk.internal.misc java.management
# @build sun.hotspot.WhiteBox compiler.codecache.stress.Helper compiler.codecache.stress.TestCaseImpl
# @build compiler.codecache.stress.UnexpectedDeoptimizationTest
# @build compiler.codecache.stress.UnexpectedDeoptimizationTestLoop
# @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
# @run shell/manual CodecacheMemoryCheckPress.sh

bash ${TESTSRC}/CodecacheMemoryCheck.sh 400
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#usage: perl ${TESTSRC}/check-native-memory-usage.pl 10 `ls *-native_memory-summary.log | sort -n | xargs`
#usage: perl ${TESTSRC}/check-native-memory-usage.pl 2 `ls *-native_memory-summary.log | sort -n | xargs`
use strict;
use warnings;
my $verbose = 0;
my $verbose = 2;

die "please input multiple and more than 2 jcmd native log files" if( @ARGV < 3 );
my $multiple = shift @ARGV;
Expand Down Expand Up @@ -70,8 +70,19 @@ sub parserJcmdResult
{
$number = $1;
die "filename=$filename\tline=$line can't get name!\n" if( length($name) <= 0 );
print("name=$name\t\tnumber=$number\n") if( $verbose == 1 );
$malloc{$name} = $number;
my $key = "$name" . "-malloc";
print("name=$key\t\tnumber=$number\n") if( $verbose == 1 );
$malloc{$key} = $number;
next;
}
if( $line =~ /\(mmap:.*committed=([0-9]+)KB/ )
{
$number = $1;
die "filename=$filename\tline=$line can't get name!\n" if( length($name) <= 0 );
my $key = "$name" . "-mmap";
print("name=$key\t\tnumber=$number\n") if( $verbose == 1 );
$malloc{$key} = $number;
next;
}
}
close($fh);
Expand Down

0 comments on commit 441c58f

Please sign in to comment.