From 46bc492af8ceb7e38a429b2781edfa9db0c691b0 Mon Sep 17 00:00:00 2001 From: sendaoYan Date: Sat, 14 Sep 2024 17:39:39 +0800 Subject: [PATCH] =?UTF-8?q?perl=E8=84=9A=E6=9C=AC=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E6=A0=A1=E6=B5=8B=E8=A7=84=E5=88=99=EF=BC=8C=E6=A3=80=E6=9F=A5?= =?UTF-8?q?java=E7=A8=8B=E5=BA=8F=E6=9C=80=E5=90=8E=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E5=86=85=E5=AD=98=E4=BD=BF=E7=94=A8=E8=AE=B0=E5=BD=95=EF=BC=8C?= =?UTF-8?q?=E8=B7=9F1/3=E6=97=B6=E5=88=BB=E7=9A=84=E5=86=85=E5=AD=98?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5=E7=9B=B8=E6=AF=94=EF=BC=8C?= =?UTF-8?q?=E8=B6=85=E8=BF=87=E4=BC=A0=E5=85=A5=E7=9A=84=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=99=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codecache/stress/CodecacheMemoryCheck.sh | 4 +- .../stress/check-native-memory-usage.pl | 41 +++++++++---------- .../stress/get-native-memory-usage.pl | 34 ++++++++++++--- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/test/hotspot/jtreg/compiler/codecache/stress/CodecacheMemoryCheck.sh b/test/hotspot/jtreg/compiler/codecache/stress/CodecacheMemoryCheck.sh index e04eb4328f3..2f9a31716b5 100755 --- a/test/hotspot/jtreg/compiler/codecache/stress/CodecacheMemoryCheck.sh +++ b/test/hotspot/jtreg/compiler/codecache/stress/CodecacheMemoryCheck.sh @@ -209,9 +209,9 @@ if grep -q "Unable to open socket file" *-native_memory-summary.log ; then exit 1 fi -( set +x ; perl ${TESTSRC}/get-native-memory-usage.pl `ls *-native_memory-summary.log | sort -n | xargs` ) +( set +x ; perl -w ${TESTSRC}/get-native-memory-usage.pl `ls *-native_memory-summary.log | sort -n | xargs` ) generatePlotPNG -( set +x ; perl ${TESTSRC}/check-native-memory-usage.pl 1 `ls *-native_memory-summary.log | sort -n | xargs` ) +( set +x ; perl -w ${TESTSRC}/check-native-memory-usage.pl "Code-malloc:2.6,Code-mmap:2.8,Compiler-malloc:4.6" `ls *-native_memory-summary.log | sort -n | xargs` ) exitCode=$? mkdir -p native_memory-summary ; mv *-native_memory-summary.log native_memory-summary/ diff --git a/test/hotspot/jtreg/compiler/codecache/stress/check-native-memory-usage.pl b/test/hotspot/jtreg/compiler/codecache/stress/check-native-memory-usage.pl index 4ea94046588..7fbc8275c19 100755 --- a/test/hotspot/jtreg/compiler/codecache/stress/check-native-memory-usage.pl +++ b/test/hotspot/jtreg/compiler/codecache/stress/check-native-memory-usage.pl @@ -19,33 +19,30 @@ # 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 2 `ls *-native_memory-summary.log | sort -n | xargs` +#usage: perl -w ${TESTSRC}/check-native-memory-usage.pl "Code-malloc:2.6,Code-mmap:2.8,Compiler-malloc:4.6" `ls *-native_memory-summary.log | sort -n | xargs` use strict; use warnings; -my $verbose = 2; +use POSIX; +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 ) +die "please input rules and more than 2 jcmd native log files" if( @ARGV < 3 ); +my $rules = shift @ARGV; +my $lastIndexResultHash = parserJcmdResult(pop(@ARGV)); +my $thirdIndexResultHash = parserJcmdResult($ARGV[ceil(scalar(@ARGV)/3)]); + +foreach my $rule ( split /,/, $rules ) { - my $data = parserJcmdResult($file); - foreach my $key ( keys %$data ) + print("rule: $rule\n"); + my($moduleName, $coefficient) = split /:/, $rule; + print("$moduleName: $coefficient\n") if( $verbose > 3 ); + my $lastIndexValue = $lastIndexResultHash->{$moduleName}; + my $thirdIndexValue = $thirdIndexResultHash->{$moduleName}; + die "can't find $moduleName memory usage information!" if( ! defined $lastIndexValue ); + die "can't find $moduleName memory usage information!" if( ! defined $thirdIndexValue ); + my $compareValue = $thirdIndexValue * $coefficient; + if( $lastIndexValue > $compareValue ) { - 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"; - } + die "$moduleName: $lastIndexValue > $compareValue=$thirdIndexValue*$coefficient"; } } diff --git a/test/hotspot/jtreg/compiler/codecache/stress/get-native-memory-usage.pl b/test/hotspot/jtreg/compiler/codecache/stress/get-native-memory-usage.pl index b5213437194..4f0229ee51e 100755 --- a/test/hotspot/jtreg/compiler/codecache/stress/get-native-memory-usage.pl +++ b/test/hotspot/jtreg/compiler/codecache/stress/get-native-memory-usage.pl @@ -19,7 +19,7 @@ # 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}/get-native-memory-usage.pl `ls *-native_memory-summary.log | sort -n | xargs` +#usage: perl -w ${TESTSRC}/get-native-memory-usage.pl `ls *-native_memory-summary.log | sort -n | xargs` use strict; use warnings; use POSIX; @@ -35,11 +35,16 @@ my %resultMinValue; my %resultMinIndex; my %resultQuarterValue; +my %resultThirdValue; +my %resultHalfValue; +my %resultLastValue; my $plotDataDir = "plot-data"; my $lastFile = $ARGV[-1]; $lastFile =~ /^([0-9]+)-.*?/; my $lastIndex = $1; my $quarterIndex = ceil($lastIndex / 4); +my $thirdIndex = ceil($lastIndex / 3); +my $halfIndex = ceil($lastIndex / 2); die "lastIndex undefine!" if( ! defined $lastIndex ); foreach my $key ( sort keys %$baseline ) @@ -78,6 +83,18 @@ { $resultQuarterValue{$key} = $value; } + if( $index == $thirdIndex ) + { + $resultThirdValue{$key} = $value; + } + if( $index == $halfIndex ) + { + $resultHalfValue{$key} = $value; + } + if( $index == $lastIndex ) + { + $resultLastValue{$key} = $value; + } } } @@ -88,7 +105,7 @@ open(my $csvFh, ">native-memory-summary.csv"); open(my $summaryFh, ">native-memory-summary.txt"); -print $summaryFh ("total $lastIndex files, quarter index is $quarterIndex.\n"); +print $summaryFh ("total $lastIndex files, quarter index is $quarterIndex, third index is $thirdIndex, half index is $halfIndex.\n"); foreach my $key ( sort @nameArray ) { print $csvFh "$resultCsv{$key}\n"; @@ -98,9 +115,16 @@ print("$key minimum vaule is $minValue, the minimum value will set to 0.01 to log file.\n"); $minValue = 0.01; } - my $maxMultiple = ceil($resultMaxValue{$key} / $minValue); - my $quartermultiple = ceil($resultQuarterValue{$key} / $minValue); - print $summaryFh "$key\tmax=$resultMaxValue{$key},index=$resultMaxIndex{$key}\tmin=$minValue,index=$resultMinIndex{$key}\tquarter=$resultQuarterValue{$key}\tmax/min=$maxMultiple\tquarter/mix=$quartermultiple\n"; + my $maxMultiple = sprintf("%.1f", $resultMaxValue{$key} / $minValue); + my $quarterMultiple = sprintf("%.1f", $resultLastValue{$key} / $resultQuarterValue{$key}); + my $thirdMultiple = sprintf("%.1f", $resultLastValue{$key} / $resultThirdValue{$key}); + my $halfMultiple = sprintf("%.1f", $resultLastValue{$key} / $resultHalfValue{$key}); + my $thirdSurprise = ""; + if( $thirdMultiple >= 2.0 ) + { + $thirdSurprise = "!!"; + } + print $summaryFh "$key\tmax=$resultMaxValue{$key},index=$resultMaxIndex{$key}\tmin=$minValue,index=$resultMinIndex{$key}\tquarter=$resultQuarterValue{$key},half=$resultHalfValue{$key}\tmax/min=$maxMultiple\tlast/quarter=$quarterMultiple\tlast/third=$thirdMultiple$thirdSurprise\tlast/half=$halfMultiple\n"; #write plot data my @data = split /,/, $resultCsv{$key};