Skip to content

Commit

Permalink
Expose P99 latency
Browse files Browse the repository at this point in the history
It's 99th percentile. It means that 99% of the requests should be faster than given latency.

Longhorn 8254

Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit committed Apr 7, 2024
1 parent 8ad41e6 commit 3e53866
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
21 changes: 21 additions & 0 deletions fio/func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ parse_randwrite_latency() {
CPU_IDLE_PCT_RANDWRITE_LATENCY=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.`
}

# Latency 99th percentile
parse_seqread_latency_p99() {
local OUTPUT=${1}
SEQREAD_LATENCY_P99=`cat $OUTPUT | jq '.jobs[0].read.clat_ns.percentile["99.000000"]'| cut -f1 -d.`
}

parse_seqwrite_latency_p99() {
local OUTPUT=${1}
SEQWRITE_LATENCY_P99=`cat $OUTPUT | jq '.jobs[0].write.clat_ns.percentile["99.000000"]'| cut -f1 -d.`
}

parse_randread_latency_p99() {
local OUTPUT=${1}
RANDREAD_LATENCY_P99=`cat $OUTPUT | jq '.jobs[0].read.clat_ns.percentile["99.000000"]'| cut -f1 -d.`
}

parse_randwrite_latency_p99() {
local OUTPUT=${1}
RANDWRITE_LATENCY_P99=`cat $OUTPUT | jq '.jobs[0].write.clat_ns.percentile["99.000000"]'| cut -f1 -d.`
}


FMT="%25s%25s\n"
CMP_FMT="%20s%30s%10s%30s%10s%25s\n"
Expand Down
92 changes: 92 additions & 0 deletions fio/parse_p99.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

set -e

CURRENT_DIR="$(dirname "$(readlink -f "$0")")"
source $CURRENT_DIR/func.sh

append_metric() {
local metric_name="${1}"
local metric_unit="${2}"
local randread="${3}"
local cpu_idle_pct_randread="${4}"
local randwrite="${5}"
local cpu_idle_pct_randwrite="${6}"
local seqread="${7}"
local cpu_idle_pct_seqread="${8}"
local seqwrite="${9}"
local cpu_idle_pct_seqwrite="${10}"

if [ "$CPU_IDLE_PROF" = "enabled" ]; then
# If CPU idle profiling is enabled, include it in the output
printf -v cxt "%s in %s with CPU idleness in percent (Read/Write)\n$FMT$FMT\n" \
"$metric_name" "$metric_unit" \
"Random:" \
"$(commaize "${randread:-0}") ($(commaize "${cpu_idle_pct_randread:-0}")) / $(commaize "${randwrite:-0}") ($(commaize "${cpu_idle_pct_randwrite:-0}"))" \
"Sequential:" \
"$(commaize "${seqread:-0}") ($(commaize "${cpu_idle_pct_seqread:-0}")) / $(commaize "${seqwrite:-0}") ($(commaize "${cpu_idle_pct_seqwrite:-0}"))"
else
# If CPU idle profiling is not enabled, exclude it from the output
printf -v cxt "%s in %s (Read/Write)\n$FMT$FMT\n" \
"$metric_name" "$metric_unit" \
"Random:" \
"$(commaize "${randread:-0}") / $(commaize "${randwrite:-0}")" \
"Sequential:" \
"$(commaize "${seqread:-0}") / $(commaize "${seqwrite:-0}")"
fi
SUMMARY+="$cxt"
}


if [ -z "${1}" ]; then
echo Require FIO IO types
exit 1
fi
IO_TYPES="${1}"

if [ -z "${2}" ]; then
echo Require FIO metrics
exit 1
fi
METRICS="${2}"

if [ -z "${3}" ]; then
echo Require FIO output prefix
exit 1
fi
PREFIX="${3}"


IFS=',' read -r -a io_types_array <<< "${IO_TYPES}"
IFS=',' read -r -a metrics_array <<< "${METRICS}"

for TYPE in "${io_types_array[@]}"; do
for METRIC in "${metrics_array[@]}"; do
OUTPUT="${PREFIX}-${TYPE}-${METRIC}.json"
parse_${TYPE}_${METRIC}_p99 "$OUTPUT"
done
done


# Initialize the result file name
RESULT=${PREFIX}.p99_summary

# Build the summary with header information
SUMMARY="
=========================
FIO Benchmark Latency P99 Summary
For: $PREFIX
CPU Idleness Profiling: ${CPU_IDLE_PROF:-not provided}
Size: ${SIZE:-10g}
Quick Mode: ${QUICK_MODE:-disabled}
=========================
"

append_metric "Latency" "ns" \
"$RANDREAD_LATENCY_P99" "$CPU_IDLE_PCT_RANDREAD_LATENCY" \
"$RANDWRITE_LATENCY_P99" "$CPU_IDLE_PCT_RANDWRITE_LATENCY" \
"$SEQREAD_LATENCY_P99" "$CPU_IDLE_PCT_SEQREAD_LATENCY" \
"$SEQWRITE_LATENCY_P99" "$CPU_IDLE_PCT_SEQWRITE_LATENCY"

echo "$SUMMARY" > "$RESULT"
cat "$RESULT"
3 changes: 2 additions & 1 deletion fio/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ for TYPE in "${io_types_array[@]}"; do
done

if [ -z "$SKIP_PARSE" ]; then
"$CURRENT_DIR/parse.sh" "$IO_TYPES" "$METRICS" "$OUTPUT"
"$CURRENT_DIR/parse.sh" "$IO_TYPES" "$METRICS" "$OUTPUT"
"$CURRENT_DIR/parse_p99.sh" "$IO_TYPES" "latency" "$OUTPUT"
fi

0 comments on commit 3e53866

Please sign in to comment.