forked from dragonwell-project/dragonwell11
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add codecache memory leak presess test draft
- Loading branch information
Showing
3 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
test/hotspot/jtreg/compiler/codecache/stress/CodecacheMemoryCheck.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/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/timeout=3600 CodecacheMemoryCheck.sh | ||
|
||
|
||
# set a few environment variables so that the shell-script can run stand-alone | ||
# in the source directory | ||
if [ "${TESTSRC}" = "" ] ; then | ||
TESTSRC="." | ||
fi | ||
if [ "${TESTJAVA}" = "" ] ; then | ||
echo "TESTJAVA not set. Test cannot execute." | ||
echo "FAILED!!!" | ||
exit 1 | ||
fi | ||
if [ "${COMPILEJAVA}" = "" ]; then | ||
COMPILEJAVA="${TESTJAVA}" | ||
fi | ||
|
||
# set platform-dependent variables | ||
OS=`uname -s` | ||
case "$OS" in | ||
SunOS ) | ||
PATHSEP=":" | ||
FILESEP="/" | ||
;; | ||
Linux ) | ||
PATHSEP=":" | ||
FILESEP="/" | ||
;; | ||
Darwin ) | ||
PATHSEP=":" | ||
FILESEP="/" | ||
;; | ||
AIX ) | ||
PATHSEP=":" | ||
FILESEP="/" | ||
;; | ||
CYGWIN* ) | ||
PATHSEP=";" | ||
FILESEP="/" | ||
;; | ||
Windows* ) | ||
PATHSEP=";" | ||
FILESEP="\\" | ||
;; | ||
* ) | ||
echo "Unrecognized system!" | ||
exit 1; | ||
;; | ||
esac | ||
|
||
UseJcmdPrintMemoryUsage() | ||
{ | ||
pid=$1 | ||
javaLog=$2 | ||
while ! grep -q "For random generator using seed" ${javaLog} | ||
do | ||
sleep 0.1 #wait util java main function start finish | ||
done | ||
i=0 | ||
rm -rf *-native_memory-summary.log | ||
while kill -0 ${pid} 2>/dev/null | ||
do | ||
${TESTJAVA}${FS}bin${FS}jcmd ${pid} VM.native_memory summary &> ${i}-native_memory-summary.log | ||
if [[ 0 -ne $? ]] ; then | ||
if grep -q "Exception" ${i}-native_memory-summary.log ; then | ||
#The target java process has been teminated/finished | ||
#java.io.IOException: No such process | ||
#com.sun.tools.attach.AttachNotSupportedException: Unable to parse namespace | ||
#java.io.IOException: Premature EOF | ||
rm -rf ${i}-native_memory-summary.log | ||
break | ||
else | ||
echo "jcmd command execute fail!" | ||
exit 1 | ||
fi | ||
fi | ||
let i++ | ||
sleep 2 | ||
done | ||
} | ||
|
||
set -x | ||
commonJvmOptions="-Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-DeoptimizeRandom \ | ||
-XX:CompileCommand=dontinline,compiler.codecache.stress.Helper$TestCase::method -XX:NativeMemoryTracking=summary" | ||
|
||
rm -rf java.log | ||
${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${TESTJAVAOPTS} -XX:+SegmentedCodeCache ${commonJvmOptions} \ | ||
-Dtest.src=${TESTSRC} -cp ${TESTCLASSPATH} compiler.codecache.stress.UnexpectedDeoptimizationTestLoop &> java.log & | ||
pid=$! | ||
ps -ef | grep java | grep UnexpectedDeoptimizationTestLoop &> ps-java.log | ||
UseJcmdPrintMemoryUsage ${pid} java.log 2> jcmd-detail-stderr.log | ||
if grep -q "Unable to open socket file" *-native_memory-summary.log ; then | ||
echo 'jcmd report error: "-native_memory-summary.log"' | ||
exit 1 | ||
fi | ||
perl ${TESTSRC}/check-native-memory-usage.pl 10 `ls *-native_memory-summary.log | sort -n | xargs` |
33 changes: 33 additions & 0 deletions
33
test/hotspot/jtreg/compiler/codecache/stress/UnexpectedDeoptimizationTestLoop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
|
||
package compiler.codecache.stress; | ||
|
||
public class UnexpectedDeoptimizationTestLoop extends UnexpectedDeoptimizationTest { | ||
public static void main(String[] args) { | ||
for (int i = 0; i < 25; i++) { | ||
new CodeCacheStressRunner(new UnexpectedDeoptimizationTest()).runTest(); | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
test/hotspot/jtreg/compiler/codecache/stress/check-native-memory-usage.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/perl -w | ||
# 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. | ||
#usage: ~/jdk11u-dev/test/hotspot/jtreg/compiler/codecache/stress/check-native-memory-usage.pl 10 `ls *-native_memory-summary.log | sort -n | xargs` | ||
use strict; | ||
use warnings; | ||
my $verbose = 0; | ||
|
||
die "please input multiple and more than 2 jcmd native log files" if( @ARGV < 3 ); | ||
my $multiple = shift @ARGV; | ||
my $baseline = parserJcmdResult(shift(@ARGV)); | ||
foreach my $file ( @ARGV ) | ||
{ | ||
my $data = parserJcmdResult($file); | ||
foreach my $key ( keys %$data ) | ||
{ | ||
my $currentValue = $data->{$key}; | ||
my $baselineValue = $baseline->{$key}; | ||
print("$file:$key: $currentValue -> $baselineValue\n") if($verbose == 2); | ||
my $coefficient = 1; | ||
$coefficient = 5 if( "Code" eq "$key" ); | ||
$coefficient = 20 if( "Class" eq "$key" ); | ||
$coefficient = 20 if( "Module" eq "$key" ); | ||
$coefficient = 20 if( "Synchronizer" eq "$key" ); | ||
$coefficient = 10 if( "ArenaChunk" eq "$key" ); | ||
my $compareValue = $baselineValue * $multiple * $coefficient; | ||
if( $currentValue > $compareValue ) | ||
{ | ||
die "$file:$key: $currentValue > $compareValue=$baselineValue*$multiple*$coefficient"; | ||
} | ||
} | ||
} | ||
|
||
sub parserJcmdResult | ||
{ | ||
my ($filename) = @_; | ||
my %malloc; | ||
my $name; | ||
my $number; | ||
open(my $fh, "<$filename") or die "Can't open file '$filename' $!"; | ||
foreach my $line ( <$fh> ) | ||
{ | ||
chomp($line); | ||
if( $line =~ /^-\s*(.*)\s+\(/ ) | ||
{ | ||
$name = $1; | ||
$name =~ s/\s+//g; | ||
$number = -1; | ||
next; | ||
} | ||
if( $line =~ /\(malloc=([0-9]+)KB/ ) | ||
{ | ||
$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; | ||
} | ||
} | ||
close($fh); | ||
return \%malloc; | ||
}; |