Skip to content

Commit

Permalink
1. 数据量有可能被split整除,因此tail部分有可能为零;2. 统一将获取结果为0的数据置为1,避免后续出现除零错误
Browse files Browse the repository at this point in the history
  • Loading branch information
sendaoYan committed Sep 17, 2024
1 parent 9795118 commit 4c7cc4d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pid=$!
ps -ef | grep java | grep UnexpectedDeoptimizationTestLoop &> ps-java.log
getMemoryUsageFromProc ${pid} java.log 2> proc-detail-stderr.log &
useJcmdPrintMemoryUsage ${pid} java.log 2> jcmd-detail-stderr.log
if grep -q "Unable to open socket file" *-native_memory-summary.log ; then
if ( set +x ; grep -q "Unable to open socket file" *-native_memory-summary.log ) ; then
echo 'jcmd report error: "-native_memory-summary.log"'
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,12 @@
die "key=$key != name=$name" if( $name ne $key );

print $csvFh "$resultCsv{$key}\n";
my $minValue = $resultMinValue{$key};
if( $minValue == 0 )
{
print("$key minimum vaule is $minValue, the minimum value will set to 0.01 to log file.\n");
$minValue = 0.01;
}
my $maxMultiple = sprintf("%.1f", $resultMaxValue{$key} / $minValue);
my $maxMultiple = sprintf("%.1f", $resultMaxValue{$key} / $resultMinValue{$key});
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 = "";
my $isIncreasementalResult = isIncreasemental(@data);
my $isIncreasementalResult = isIncreasemental($name, @data);
$isIncreasementalResultHash{$name} = $isIncreasementalResult;
my $isMemoryLeak = "";
if( $thirdMultiple >= 2.5 )
Expand All @@ -139,7 +133,7 @@
$isMemoryLeak = "\tMemoryLeak!!!"
}
}
print $summaryFh "$key\tmax=$resultMaxValue{$key},index=$resultMaxIndex{$key}\tmin=$minValue,index=$resultMinIndex{$key}\tquarter=$resultQuarterValue{$key},third=$resultThirdValue{$key},half=$resultHalfValue{$key}\tmax/min=$maxMultiple,last/quarter=$quarterMultiple,last/half=$halfMultiple,last/third=$thirdMultiple$thirdSurprise\tisIncreasemental=$isIncreasementalResult$isMemoryLeak\n";
print $summaryFh "$key\tmax=$resultMaxValue{$key},index=$resultMaxIndex{$key}\tmin=$resultMinValue{$key},index=$resultMinIndex{$key}\tquarter=$resultQuarterValue{$key},third=$resultThirdValue{$key},half=$resultHalfValue{$key}\tmax/min=$maxMultiple,last/quarter=$quarterMultiple,last/half=$halfMultiple,last/third=$thirdMultiple$thirdSurprise\tisIncreasemental=$isIncreasementalResult$isMemoryLeak\n";

#write plot data
my $i = 0;
Expand Down Expand Up @@ -203,6 +197,14 @@ sub parserJcmdResult
die "filename=$filename\tline=$line can't get name!\n" if( length($name) <= 0 );
my $key = "$name" . "-malloc";
print("name=$key\t\tnumber=$number\n") if( $verbose == 1 );
if( $number == 0 )
{
if( $verbose > 0 )
{
warn("$key value is 0");
}
$number = 0.01;
}
$malloc{$key} = $number;
next;
}
Expand All @@ -212,6 +214,14 @@ sub parserJcmdResult
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 );
if( $number == 0 )
{
if( $verbose > 0 )
{
warn("$key value is 0");
}
$number = 1;
}
$malloc{$key} = $number;
next;
}
Expand All @@ -222,12 +232,13 @@ sub parserJcmdResult

sub isIncreasemental
{
my $name = shift(@_);
my @array = @_;
my $length = scalar(@array);
my $windowLength = floor($length/$split);
warn("windowLength=$windowLength\n") if( $verbose > 0 );
warn("$name: windowLength=$windowLength\n") if( $verbose > 0 );
my $count = $windowLength * $split;
warn("count=$count, $length=$length\n") if( $verbose > 0 );;
warn("$name: count=$count, $length=$length\n") if( $verbose > 0 );;
my $previousSum = 0;
my $steady = 0;
my $result = 0;
Expand All @@ -242,11 +253,11 @@ sub isIncreasemental
$currentSum += $array[$i*$windowLength+$j];
}
$currentSum /= $windowLength;
warn("currentSum=$currentSum, previousSum=$previousSum\n") if( $verbose >= 3 );
warn("$name: currentSum=$currentSum, previousSum=$previousSum\n") if( $verbose >= 3 );
if( $currentSum < $previousSum )
{
$result++;
warn("currentSum=$currentSum, previousSum=$previousSum\n") if( $verbose >= 1 );
warn("$name: currentSum=$currentSum, previousSum=$previousSum\n") if( $verbose >= 1 );
}
elsif( $currentSum == $previousSum )
{
Expand All @@ -255,25 +266,34 @@ sub isIncreasemental
$previousSum = $currentSum;
}

# warn("$name: steady=$steady, split=$split\n") if( $verbose >= 0 );
#calculate the tail data
my $currentSum = 0;
foreach my $i ( $count .. ($length-1) )
{
$currentSum += $array[$i];;
}
$currentSum /= ($length-$count);
if( $currentSum < $previousSum )
if( ($length-$count) != 0 )
{
$result++;
warn("currentSum=$currentSum, previousSum=$previousSum\n") if( $verbose >= 1 );
my $currentSum = 0;
foreach my $i ( $count .. ($length-1) )
{
$currentSum += $array[$i];;
}
$currentSum /= ($length-$count);
if( $currentSum < $previousSum )
{
$result++;
warn("$name: currentSum=$currentSum, previousSum=$previousSum\n") if( $verbose >= 1 );
}
elsif( $currentSum == $previousSum || abs($currentSum-$previousSum) > 0.1 )
{
$steady++;
}
}
elsif( $currentSum == $previousSum )
else
{
$steady++;
warn("$name: tail count is zero.\n");
warn("$name: tail count is zero.\n") if( $verbose >= 1 );
}

#statistics the result
warn("steady=$steady, split=$split\n") if( $verbose >= 2 );
warn("$name: steady=$steady, split=$split\n") if( $verbose >= 2 );
if( $steady == $split )
{
$result = -1;
Expand Down

0 comments on commit 4c7cc4d

Please sign in to comment.