util/analyze-contention-log: call the bash interpreter with -eu flags

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
This commit is contained in:
Eugene Syromiatnikov 2025-07-07 16:13:24 +02:00
parent 707a966f70
commit db6565e5b1
1 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -eu
# Copyright 2025 The OpenSSL Project Authors. All Rights Reserved. # Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
# #
# Licensed under the Apache License 2.0 (the "License"). # Licensed under the Apache License 2.0 (the "License").
@ -37,7 +37,7 @@ awk '
BEGIN {RS = ""; FS = "\n"} BEGIN {RS = ""; FS = "\n"}
{file_num++; print > ("stacktrace" file_num ".txt")}' ./$LOGFILEBASE {file_num++; print > ("stacktrace" file_num ".txt")}' ./$LOGFILEBASE
popd > /dev/null popd > /dev/null
rm $TEMPDIR/individual_files/$LOGFILEBASE rm -f $TEMPDIR/individual_files/$LOGFILEBASE
# #
# Make some associative arrays to track our stats # Make some associative arrays to track our stats
@ -48,7 +48,7 @@ declare -A latency_counts
echo "Gathering latencies" echo "Gathering latencies"
FILECOUNT=$(ls $TEMPDIR/individual_files/stacktrace*.* | wc -l) FILECOUNT=$(ls $TEMPDIR/individual_files/stacktrace*.* | wc -l)
let currentidx=0 currentidx=0
# #
# Look at every stack trace, get and record its latency, and hash value # Look at every stack trace, get and record its latency, and hash value
@ -61,8 +61,8 @@ do
#now compute its sha1sum #now compute its sha1sum
SHA1SUM=$(sha1sum $i | awk '{print $1}') SHA1SUM=$(sha1sum $i | awk '{print $1}')
filenames["$SHA1SUM"]=$i filenames["$SHA1SUM"]=$i
let CUR_LATENCY=0 CUR_LATENCY=0
let LATENCY_COUNT=0 LATENCY_COUNT=0
# #
# If we already have a latency total for this hash value # If we already have a latency total for this hash value
@ -71,8 +71,8 @@ do
# #
if [[ -v total_latency["$SHA1SUM"] ]] if [[ -v total_latency["$SHA1SUM"] ]]
then then
let CUR_LATENCY=${total_latency["$SHA1SUM"]} CUR_LATENCY=${total_latency["$SHA1SUM"]}
let LATENCY_COUNT=${latency_counts["$SHA1SUM"]} LATENCY_COUNT=${latency_counts["$SHA1SUM"]}
fi fi
# #
@ -82,7 +82,7 @@ do
total_latency["$SHA1SUM"]=$(dc -e "$CUR_LATENCY $LATENCY + p") total_latency["$SHA1SUM"]=$(dc -e "$CUR_LATENCY $LATENCY + p")
latency_counts["$SHA1SUM"]=$(dc -e "$LATENCY_COUNT 1 + p") latency_counts["$SHA1SUM"]=$(dc -e "$LATENCY_COUNT 1 + p")
echo -e -n "FILE $currentidx/$FILECOUNT \r" echo -e -n "FILE $currentidx/$FILECOUNT \r"
let currentidx=$currentidx+1 currentidx=$((currentidx + 1))
done done
# #