diff --git a/deploy/fio-cmp.yaml b/deploy/fio-cmp.yaml index 51237bc..29fca37 100644 --- a/deploy/fio-cmp.yaml +++ b/deploy/fio-cmp.yaml @@ -57,6 +57,10 @@ spec: value: "30G" # must be smaller or match the PVC size - name: CPU_IDLE_PROF value: "disabled" # must be "enabled" or "disabled" + - name: IO_TYPES + value: "seqread,seqwrite,randread,randwrite" + - name: METRICS + value: "bandwidth,iops,latency" volumeMounts: - name: vol1 mountPath: /volume1/ diff --git a/deploy/fio.yaml b/deploy/fio.yaml index ec9f777..9e80b3b 100644 --- a/deploy/fio.yaml +++ b/deploy/fio.yaml @@ -36,6 +36,10 @@ spec: value: "30G" # must be 10% smaller than the PVC size due to filesystem also took space - name: CPU_IDLE_PROF value: "disabled" # must be "enabled" or "disabled" + - name: IO_TYPES + value: "seqread,seqwrite,randread,randwrite" + - name: METRICS + value: "bandwidth,iops,latency" volumeMounts: - name: vol mountPath: /volume/ diff --git a/fio/bandwidth-quick.fio b/fio/bandwidth-quick.fio deleted file mode 100644 index 2bf3b0a..0000000 --- a/fio/bandwidth-quick.fio +++ /dev/null @@ -1,19 +0,0 @@ -[rand-read-bw] -readwrite=randread -include bw-include.fio -include quick-include.fio - -[rand-write-bw] -readwrite=randwrite -include bw-include.fio -include quick-include.fio - -[seq-read-bw] -readwrite=read -include bw-include.fio -include quick-include.fio - -[seq-write-bw] -readwrite=write -include bw-include.fio -include quick-include.fio diff --git a/fio/bandwidth.fio b/fio/bandwidth.fio deleted file mode 100644 index ecb7db1..0000000 --- a/fio/bandwidth.fio +++ /dev/null @@ -1,19 +0,0 @@ -[rand-read-bw] -readwrite=randread -include bw-include.fio -include common-include.fio - -[rand-write-bw] -readwrite=randwrite -include bw-include.fio -include common-include.fio - -[seq-read-bw] -readwrite=read -include bw-include.fio -include common-include.fio - -[seq-write-bw] -readwrite=write -include bw-include.fio -include common-include.fio diff --git a/fio/cmp_parse.sh b/fio/cmp_parse.sh index 3c280d6..80e3f0d 100755 --- a/fio/cmp_parse.sh +++ b/fio/cmp_parse.sh @@ -5,207 +5,231 @@ set -e CURRENT_DIR="$(dirname "$(readlink -f "$0")")" source $CURRENT_DIR/func.sh -if [ -z "FIRST_VOL_NAME" ]; then - echo Require the first volume name - exit 1 +if [ -z "${1}" ]; then + echo Require FIO IO types + exit 1 fi +IO_TYPES="${1}" -if [ -z "SECOND_VOL_NAME" ]; then - echo Require the second volume name - exit 1 +if [ -z "${2}" ]; then + echo Require FIO metrics + exit 1 fi +METRICS="${2}" -FIRST_IOPS=${FIRST_VOL_NAME}-iops.json -FIRST_BW=${FIRST_VOL_NAME}-bandwidth.json -FIRST_LAT=${FIRST_VOL_NAME}-latency.json +P99_LATENCY="${3:-false}" -SECOND_IOPS=${SECOND_VOL_NAME}-iops.json -SECOND_BW=${SECOND_VOL_NAME}-bandwidth.json -SECOND_LAT=${SECOND_VOL_NAME}-latency.json +if [ -z "FIRST_VOL_NAME" ]; then + echo Require the first volume name + exit 1 +fi -parse_iops $FIRST_IOPS -FIRST_RAND_READ_IOPS=$RAND_READ_IOPS -FIRST_RAND_WRITE_IOPS=$RAND_WRITE_IOPS -FIRST_SEQ_READ_IOPS=$SEQ_READ_IOPS -FIRST_SEQ_WRITE_IOPS=$SEQ_WRITE_IOPS -FIRST_CPU_IDLE_PCT_IOPS=$CPU_IDLE_PCT_IOPS +if [ -z "SECOND_VOL_NAME" ]; then + echo Require the second volume name + exit 1 +fi -parse_iops $SECOND_IOPS -SECOND_RAND_READ_IOPS=$RAND_READ_IOPS -SECOND_RAND_WRITE_IOPS=$RAND_WRITE_IOPS -SECOND_SEQ_READ_IOPS=$SEQ_READ_IOPS -SECOND_SEQ_WRITE_IOPS=$SEQ_WRITE_IOPS -SECOND_CPU_IDLE_PCT_IOPS=$CPU_IDLE_PCT_IOPS +IFS=',' read -r -a io_types_array <<< "${IO_TYPES}" +IFS=',' read -r -a metrics_array <<< "${METRICS}" + +to_uppercase() { + local input_str="$1" + local uppercase_str="${input_str^^}" # Convert to uppercase + echo "$uppercase_str" +} + +parse_metrics() { + local vol_name="$1" + local prefix="$2" + + if [[ -z "$vol_name" || -z "$prefix" ]]; then + echo "parse_metrics: Missing required parameters." >&2 + return 1 + fi + + for METRIC in "${metrics_array[@]}"; do + for IO_TYPE in "${io_types_array[@]}"; do + local output="${vol_name}-${IO_TYPE}-${METRIC}.json" + local parse_func="parse_${IO_TYPE}_${METRIC}" + if [ "$P99_LATENCY" = "true" ]; then + parse_func="parse_${IO_TYPE}_${METRIC}_p99" + fi + + if declare -f "$parse_func" > /dev/null; then + $parse_func "$output" + + local metric=`to_uppercase $METRIC` + local io_type=`to_uppercase $IO_TYPE` + local var_suffix="" + local var_name="" + + var_suffix="${io_type}_${metric^^}" + var_name="${prefix}_${var_suffix}" + declare -g "$var_name=${!var_suffix}" + + var_suffix="CPU_IDLE_PCT_${io_type}_${metric^^}" + var_name="${prefix}_${var_suffix}" + declare -g "$var_name=${!var_suffix}" + else + echo "parse_metrics: Parser function '$parse_func' not found for $output." >&2 + fi + done + done +} + +parse_metrics "$FIRST_VOL_NAME" "FIRST" +parse_metrics "$SECOND_VOL_NAME" "SECOND" calc_cmp_iops +calc_cmp_bandwidth +calc_cmp_latency -parse_bw $FIRST_BW -FIRST_RAND_READ_BW=$RAND_READ_BW -FIRST_RAND_WRITE_BW=$RAND_WRITE_BW -FIRST_SEQ_READ_BW=$SEQ_READ_BW -FIRST_SEQ_WRITE_BW=$SEQ_WRITE_BW -FIRST_CPU_IDLE_PCT_BW=$CPU_IDLE_PCT_BW - -parse_bw $SECOND_BW -SECOND_RAND_READ_BW=$RAND_READ_BW -SECOND_RAND_WRITE_BW=$RAND_WRITE_BW -SECOND_SEQ_READ_BW=$SEQ_READ_BW -SECOND_SEQ_WRITE_BW=$SEQ_WRITE_BW -SECOND_CPU_IDLE_PCT_BW=$CPU_IDLE_PCT_BW - -calc_cmp_bw - -parse_lat $FIRST_LAT -FIRST_RAND_READ_LAT=$RAND_READ_LAT -FIRST_RAND_WRITE_LAT=$RAND_WRITE_LAT -FIRST_SEQ_READ_LAT=$SEQ_READ_LAT -FIRST_SEQ_WRITE_LAT=$SEQ_WRITE_LAT -FIRST_CPU_IDLE_PCT_LAT=$CPU_IDLE_PCT_LAT - -parse_lat $SECOND_LAT -SECOND_RAND_READ_LAT=$RAND_READ_LAT -SECOND_RAND_WRITE_LAT=$RAND_WRITE_LAT -SECOND_SEQ_READ_LAT=$SEQ_READ_LAT -SECOND_SEQ_WRITE_LAT=$SEQ_WRITE_LAT -SECOND_CPU_IDLE_PCT_LAT=$CPU_IDLE_PCT_LAT - -calc_cmp_lat - -RESULT=${FIRST_VOL_NAME}_vs_${SECOND_VOL_NAME}.summary - +# Build the summary with header information QUICK_MODE_TEXT="Quick Mode: disabled" if [ -n "$QUICK_MODE" ]; then - QUICK_MODE_TEXT="Quick Mode: enabled" + QUICK_MODE_TEXT="Quick Mode: enabled" fi SIZE_TEXT="SIZE: 10g" if [ -n "$SIZE" ]; then - SIZE_TEXT="Size: $SIZE" + SIZE_TEXT="Size: $SIZE" +fi + +# Determine the file name suffix and title based on P99_LATENCY +if [ "$P99_LATENCY" = "false" ]; then + FILE_SUFFIX="summary" + TITLE="FIO Benchmark Comparison Summary" +else + FILE_SUFFIX="p99_latency.summary" + TITLE="FIO Benchmark P99 Latency Comparison Summary" fi +RESULT="${FIRST_VOL_NAME}_vs_${SECOND_VOL_NAME}_${FILE_SUFFIX}" + SUMMARY=" -================================ -FIO Benchmark Comparsion Summary +=============================== +$TITLE For: $FIRST_VOL_NAME vs $SECOND_VOL_NAME CPU Idleness Profiling: $CPU_IDLE_PROF $SIZE_TEXT $QUICK_MODE_TEXT -================================ +=============================== " printf -v header "$CMP_FMT" \ - "" $FIRST_VOL_NAME "vs" $SECOND_VOL_NAME ":" "Change" + "" $FIRST_VOL_NAME "vs" $SECOND_VOL_NAME ":" "Change" SUMMARY+=$header -if [ x"$CPU_IDLE_PROF" = x"enabled" ]; then - printf -v cxt "IOPS (Read/Write)\n$CMP_FMT$CMP_FMT$CMP_FMT\n" \ - "Random:" \ - "$(commaize $FIRST_RAND_READ_IOPS) / $(commaize $FIRST_RAND_WRITE_IOPS)" \ - "vs" \ - "$(commaize $SECOND_RAND_READ_IOPS) / $(commaize $SECOND_RAND_WRITE_IOPS)" \ - ":" \ - "$CMP_RAND_READ_IOPS / $CMP_RAND_WRITE_IOPS" \ - "Sequential:" \ - "$(commaize $FIRST_SEQ_READ_IOPS) / $(commaize $FIRST_SEQ_WRITE_IOPS)" \ - "vs" \ - "$(commaize $SECOND_SEQ_READ_IOPS) / $(commaize $SECOND_SEQ_WRITE_IOPS)" \ - ":" \ - "$CMP_SEQ_READ_IOPS / $CMP_SEQ_WRITE_IOPS" \ - "CPU Idleness:" \ - "$FIRST_CPU_IDLE_PCT_IOPS%" \ - "vs" \ - "$SECOND_CPU_IDLE_PCT_IOPS%"\ - ":" \ - "$CMP_CPU_IDLE_PCT_IOPS%" - SUMMARY+=$cxt - - printf -v cxt "Bandwidth in KiB/sec (Read/Write)\n$CMP_FMT$CMP_FMT$CMP_FMT\n" \ - "Random:" \ - "$(commaize $FIRST_RAND_READ_BW) / $(commaize $FIRST_RAND_WRITE_BW)" \ - "vs" \ - "$(commaize $SECOND_RAND_READ_BW) / $(commaize $SECOND_RAND_WRITE_BW)" \ - ":" \ - "$CMP_RAND_READ_BW / $CMP_RAND_WRITE_BW" \ - "Sequential:" \ - "$(commaize $FIRST_SEQ_READ_BW) / $(commaize $FIRST_SEQ_WRITE_BW)" \ - "vs" \ - "$(commaize $SECOND_SEQ_READ_BW) / $(commaize $SECOND_SEQ_WRITE_BW)" \ - ":" \ - "$CMP_SEQ_READ_BW / $CMP_SEQ_WRITE_BW" \ - "CPU Idleness:" \ - "$FIRST_CPU_IDLE_PCT_BW%" \ - "vs" \ - "$SECOND_CPU_IDLE_PCT_BW%" \ - ":" \ - "$CMP_CPU_IDLE_PCT_BW%" - SUMMARY+=$cxt - - printf -v cxt "Latency in ns (Read/Write)\n$CMP_FMT$CMP_FMT$CMP_FMT\n" \ - "Random:" \ - "$(commaize $FIRST_RAND_READ_LAT) / $(commaize $FIRST_RAND_WRITE_LAT)" \ - "vs" \ - "$(commaize $SECOND_RAND_READ_LAT) / $(commaize $SECOND_RAND_WRITE_LAT)" \ - ":" \ - "$CMP_RAND_READ_LAT / $CMP_RAND_WRITE_LAT" \ - "Sequential:" \ - "$(commaize $FIRST_SEQ_READ_LAT) / $(commaize $FIRST_SEQ_WRITE_LAT)" \ - "vs" \ - "$(commaize $SECOND_SEQ_READ_LAT) / $(commaize $SECOND_SEQ_WRITE_LAT)" \ - ":" \ - "$CMP_SEQ_READ_LAT / $CMP_SEQ_WRITE_LAT" \ - "CPU Idleness:" \ - "$FIRST_CPU_IDLE_PCT_LAT%" \ - "vs" \ - "$SECOND_CPU_IDLE_PCT_LAT%" \ - ":" \ - "$CMP_CPU_IDLE_PCT_LAT%" - SUMMARY+=$cxt -else - printf -v cxt "IOPS (Read/Write)\n$CMP_FMT$CMP_FMT\n" \ - "Random:" \ - "$(commaize $FIRST_RAND_READ_IOPS) / $(commaize $FIRST_RAND_WRITE_IOPS)" \ - "vs" \ - "$(commaize $SECOND_RAND_READ_IOPS) / $(commaize $SECOND_RAND_WRITE_IOPS)" \ - ":" \ - "$CMP_RAND_READ_IOPS / $CMP_RAND_WRITE_IOPS" \ - "Sequential:" \ - "$(commaize $FIRST_SEQ_READ_IOPS) / $(commaize $FIRST_SEQ_WRITE_IOPS)" \ - "vs" \ - "$(commaize $SECOND_SEQ_READ_IOPS) / $(commaize $SECOND_SEQ_WRITE_IOPS)" \ - ":" \ - "$CMP_SEQ_READ_IOPS / $CMP_SEQ_WRITE_IOPS" - SUMMARY+=$cxt - - printf -v cxt "Bandwidth in KiB/sec (Read/Write)\n$CMP_FMT$CMP_FMT\n" \ - "Random:" \ - "$(commaize $FIRST_RAND_READ_BW) / $(commaize $FIRST_RAND_WRITE_BW)" \ - "vs" \ - "$(commaize $SECOND_RAND_READ_BW) / $(commaize $SECOND_RAND_WRITE_BW)" \ - ":" \ - "$CMP_RAND_READ_BW / $CMP_RAND_WRITE_BW" \ - "Sequential:" \ - "$(commaize $FIRST_SEQ_READ_BW) / $(commaize $FIRST_SEQ_WRITE_BW)" \ - "vs" \ - "$(commaize $SECOND_SEQ_READ_BW) / $(commaize $SECOND_SEQ_WRITE_BW)" \ - ":" \ - "$CMP_SEQ_READ_BW / $CMP_SEQ_WRITE_BW" - SUMMARY+=$cxt - - printf -v cxt "Latency in ns (Read/Write)\n$CMP_FMT$CMP_FMT\n" \ - "Random:" \ - "$(commaize $FIRST_RAND_READ_LAT) / $(commaize $FIRST_RAND_WRITE_LAT)" \ - "vs" \ - "$(commaize $SECOND_RAND_READ_LAT) / $(commaize $SECOND_RAND_WRITE_LAT)" \ - ":" \ - "$CMP_RAND_READ_LAT / $CMP_RAND_WRITE_LAT" \ - "Sequential:" \ - "$(commaize $FIRST_SEQ_READ_LAT) / $(commaize $FIRST_SEQ_WRITE_LAT)" \ - "vs" \ - "$(commaize $SECOND_SEQ_READ_LAT) / $(commaize $SECOND_SEQ_WRITE_LAT)" \ - ":" \ - "$CMP_SEQ_READ_LAT / $CMP_SEQ_WRITE_LAT" - SUMMARY+=$cxt +# Define a function to add metrics to the summary +add_metrics_to_summary() { + local metric_name="${1}" + local metric_unit="${2}" + + local first_randread="${3}" + local first_cpu_idle_pct_randread="${4}" + local first_randwrite="${5}" + local first_cpu_idle_pct_randwrite="${6}" + local second_randread="${7}" + local second_cpu_idle_pct_randread="${8}" + local second_randwrite="${9}" + local second_cpu_idle_pct_randwrite="${10}" + local cmp_randread="${11}" + local cmp_cpu_idle_pct_randread="${12}" + local cmp_randwrite="${13}" + local cmp_cpu_idle_pct_randwrite="${14}" + + local first_seqread="${15}" + local first_cpu_idle_pct_seqread="${16}" + local first_seqwrite="${17}" + local first_cpu_idle_pct_seqwrite="${18}" + local second_seqread="${19}" + local second_cpu_idle_pct_seqread="${20}" + local second_seqwrite="${21}" + local second_cpu_idle_pct_seqwrite="${22}" + local cmp_seqread="${23}" + local cmp_cpu_idle_pct_seqread="${24}" + local cmp_seqwrite="${25}" + local cmp_cpu_idle_pct_seqwrite="${26}" + + if [ "$CPU_IDLE_PROF" = "enabled" ] && [ "$P99_LATENCY" = "false" ]; then + printf -v cxt "${metric_name} in ${metric_unit} with CPU idleness in percent (Read/Write)\n${CMP_FMT}${CMP_FMT}${CMP_FMT}\n" \ + "Random:" \ + "$(commaize "${first_randread}") ($(commaize "${first_cpu_idle_pct_randread}")) / $(commaize "${first_randwrite}") ($(commaize "${first_cpu_idle_pct_randwrite}"))" \ + "vs" \ + "$(commaize "${second_randread}") ($(commaize "${second_cpu_idle_pct_randread}")) / $(commaize "${second_randwrite}") ($(commaize "${second_cpu_idle_pct_randwrite}"))" ":" \ + "${cmp_randread} (${cmp_cpu_idle_pct_randread}) / ${cmp_randwrite} (${cmp_cpu_idle_pct_randwrite})" \ + "Sequential:" \ + "$(commaize "${first_seqread}") ($(commaize "${first_cpu_idle_pct_seqread}")) / $(commaize "${first_seqwrite}") ($(commaize "${first_cpu_idle_pct_seqwrite}"))" \ + "vs" \ + "$(commaize "${second_seqread}") ($(commaize "${second_cpu_idle_pct_seqread}")) / $(commaize "${second_seqwrite}") ($(commaize "${second_cpu_idle_pct_seqwrite}"))" ":" \ + "${cmp_seqread} (${cmp_cpu_idle_pct_seqread}) / ${cmp_seqwrite} (${cmp_cpu_idle_pct_seqwrite})" + else + printf -v cxt "${metric_name} in KiB/sec (Read/Write)\n${CMP_FMT}${CMP_FMT}${CMP_FMT}\n" \ + "Random:" \ + "$(commaize "${first_randread}") / $(commaize "${first_randwrite}")" \ + "vs" \ + "$(commaize "${second_randread}") / $(commaize "${second_randwrite}")" ":" \ + "${cmp_randread} / ${cmp_randwrite}" \ + "Sequential:" \ + "$(commaize "${first_seqread}") / $(commaize "${first_seqwrite}")" \ + "vs" \ + "$(commaize "${second_seqread}") / $(commaize "${second_seqwrite}")" ":" \ + "${cmp_seqread} / ${cmp_seqwrite}" + fi + SUMMARY+="${cxt}" +} + +# Check CPU_IDLE_PROF status +CPU_IDLE_STATUS="disabled" +if [ "x$CPU_IDLE_PROF" = "xenabled" ]; then + CPU_IDLE_STATUS="enabled" +fi + +# Example usage +if [ "$P99_LATENCY" = "false" ]; then + add_metrics_to_summary "IOPS" "ops" \ + "$FIRST_RANDREAD_IOPS" "$FIRST_CPU_IDLE_PCT_RANDREAD_IOPS" \ + "$FIRST_RANDWRITE_IOPS" "$FIRST_CPU_IDLE_PCT_RANDWRITE_IOPS" \ + "$SECOND_RANDREAD_IOPS" "$SECOND_CPU_IDLE_PCT_RANDREAD_IOPS" \ + "$SECOND_RANDWRITE_IOPS" "$SECOND_CPU_IDLE_PCT_RANDWRITE_IOPS" \ + "$CMP_RANDREAD_IOPS" "$CMP_CPU_IDLE_PCT_RANDREAD_IOPS" \ + "$CMP_RANDWRITE_IOPS" "$CMP_CPU_IDLE_PCT_RANDWRITE_IOPS" \ + "$FIRST_SEQREAD_IOPS" "$FIRST_CPU_IDLE_PCT_SEQREAD_IOPS" \ + "$FIRST_SEQWRITE_IOPS" "$FIRST_CPU_IDLE_PCT_SEQWRITE_IOPS" \ + "$SECOND_SEQREAD_IOPS" "$SECOND_CPU_IDLE_PCT_SEQREAD_IOPS" \ + "$SECOND_SEQWRITE_IOPS" "$SECOND_CPU_IDLE_PCT_SEQWRITE_IOPS" \ + "$CMP_SEQREAD_IOPS" "$CMP_CPU_IDLE_PCT_SEQREAD_IOPS" \ + "$CMP_SEQWRITE_IOPS" "$CMP_CPU_IDLE_PCT_SEQWRITE_IOPS" + + add_metrics_to_summary "Bandwidth" "KiB/sec" \ + "$FIRST_RANDREAD_BANDWIDTH" "$FIRST_CPU_IDLE_PCT_RANDREAD_BANDWIDTH" \ + "$FIRST_RANDWRITE_BANDWIDTH" "$FIRST_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH" \ + "$SECOND_RANDREAD_BANDWIDTH" "$SECOND_CPU_IDLE_PCT_RANDREAD_BANDWIDTH" \ + "$SECOND_RANDWRITE_BANDWIDTH" "$SECOND_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH" \ + "$CMP_RANDREAD_BANDWIDTH" "$CMP_CPU_IDLE_PCT_RANDREAD_BANDWIDTH" \ + "$CMP_RANDWRITE_BANDWIDTH" "$CMP_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH" \ + "$FIRST_SEQREAD_BANDWIDTH" "$FIRST_CPU_IDLE_PCT_SEQREAD_BANDWIDTH" \ + "$FIRST_SEQWRITE_BANDWIDTH" "$FIRST_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH" \ + "$SECOND_SEQREAD_BANDWIDTH" "$SECOND_CPU_IDLE_PCT_SEQREAD_BANDWIDTH" \ + "$SECOND_SEQWRITE_BANDWIDTH" "$SECOND_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH" \ + "$CMP_SEQREAD_BANDWIDTH" "$CMP_CPU_IDLE_PCT_SEQREAD_BANDWIDTH" \ + "$CMP_SEQWRITE_BANDWIDTH" "$CMP_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH" fi +add_metrics_to_summary "Latency" "ns" \ + "$FIRST_RANDREAD_LATENCY" "$FIRST_CPU_IDLE_PCT_RANDREAD_LATENCY" \ + "$FIRST_RANDWRITE_LATENCY" "$FIRST_CPU_IDLE_PCT_RANDWRITE_LATENCY" \ + "$SECOND_RANDREAD_LATENCY" "$SECOND_CPU_IDLE_PCT_RANDREAD_LATENCY" \ + "$SECOND_RANDWRITE_LATENCY" "$SECOND_CPU_IDLE_PCT_RANDWRITE_LATENCY" \ + "$CMP_RANDREAD_LATENCY" "$CMP_CPU_IDLE_PCT_RANDREAD_LATENCY" \ + "$CMP_RANDWRITE_LATENCY" "$CMP_CPU_IDLE_PCT_RANDWRITE_LATENCY" \ + "$FIRST_SEQREAD_LATENCY" "$FIRST_CPU_IDLE_PCT_SEQREAD_LATENCY" \ + "$FIRST_SEQWRITE_LATENCY" "$FIRST_CPU_IDLE_PCT_SEQWRITE_LATENCY" \ + "$SECOND_SEQREAD_LATENCY" "$SECOND_CPU_IDLE_PCT_SEQREAD_LATENCY" \ + "$SECOND_SEQWRITE_LATENCY" "$SECOND_CPU_IDLE_PCT_SEQWRITE_LATENCY" \ + "$CMP_SEQREAD_LATENCY" "$CMP_CPU_IDLE_PCT_SEQREAD_LATENCY" \ + "$CMP_SEQWRITE_LATENCY" "$CMP_CPU_IDLE_PCT_SEQWRITE_LATENCY" + + echo "$SUMMARY" > $RESULT -cat $RESULT +cat $RESULT \ No newline at end of file diff --git a/fio/cmp_run.sh b/fio/cmp_run.sh index 1c39b9a..edf42a1 100755 --- a/fio/cmp_run.sh +++ b/fio/cmp_run.sh @@ -6,29 +6,27 @@ CURRENT_DIR="$(dirname "$(readlink -f "$0")")" source $CURRENT_DIR/func.sh if [ -z "FIRST_VOL_NAME" ]; then - echo Require the first volume name - exit 1 + echo Require the first volume name + exit 1 fi if [ -z "FIRST_VOL_FILE" ]; then - echo Require the first volume file location - exit 1 + echo Require the first volume file location + exit 1 fi if [ -z "SECOND_VOL_NAME" ]; then - echo Require the second volume name - exit 1 + echo Require the second volume name + exit 1 fi if [ -z "SECOND_VOL_FILE" ]; then - echo Require the second volume file location - exit 1 + echo Require the second volume file location + exit 1 fi -#disable parsing in run.sh -export SKIP_PARSE=1 - $CURRENT_DIR/run.sh $FIRST_VOL_FILE $FIRST_VOL_NAME $CURRENT_DIR/run.sh $SECOND_VOL_FILE $SECOND_VOL_NAME -$CURRENT_DIR/cmp_parse.sh +$CURRENT_DIR/cmp_parse.sh "$IO_TYPES" "$METRICS" "false" +$CURRENT_DIR/cmp_parse.sh "$IO_TYPES" "latency" "true" \ No newline at end of file diff --git a/fio/func.sh b/fio/func.sh index 06079a5..e1d5cc0 100644 --- a/fio/func.sh +++ b/fio/func.sh @@ -1,83 +1,189 @@ #!/bin/bash -parse_iops() { - local OUTPUT_IOPS=$1 - RAND_READ_IOPS=`cat $OUTPUT_IOPS | jq '.jobs[0].read.iops_mean'| cut -f1 -d.` - RAND_WRITE_IOPS=`cat $OUTPUT_IOPS | jq '.jobs[1].write.iops_mean'| cut -f1 -d.` - SEQ_READ_IOPS=`cat $OUTPUT_IOPS | jq '.jobs[2].read.iops_mean'| cut -f1 -d.` - SEQ_WRITE_IOPS=`cat $OUTPUT_IOPS | jq '.jobs[3].write.iops_mean'| cut -f1 -d.` - CPU_IDLE_PCT_IOPS=`cat $OUTPUT_IOPS | jq '.cpu_idleness.system' | cut -f1 -d.` +# IOPS +parse_seqread_iops() { + local OUTPUT=${1} + SEQREAD_IOPS=`cat $OUTPUT | jq '.jobs[0].read.iops_mean'| cut -f1 -d.` + CPU_IDLE_PCT_SEQREAD_IOPS=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` } -parse_bw() { - local OUTPUT_BW=$1 - RAND_READ_BW=`cat $OUTPUT_BW | jq '.jobs[0].read.bw_mean'| cut -f1 -d.` - RAND_WRITE_BW=`cat $OUTPUT_BW | jq '.jobs[1].write.bw_mean'| cut -f1 -d.` - SEQ_READ_BW=`cat $OUTPUT_BW | jq '.jobs[2].read.bw_mean'| cut -f1 -d.` - SEQ_WRITE_BW=`cat $OUTPUT_BW | jq '.jobs[3].write.bw_mean'| cut -f1 -d.` - CPU_IDLE_PCT_BW=`cat $OUTPUT_BW| jq '.cpu_idleness.system' | cut -f1 -d.` +parse_seqwrite_iops() { + local OUTPUT=${1} + SEQWRITE_IOPS=`cat $OUTPUT | jq '.jobs[0].write.iops_mean'| cut -f1 -d.` + CPU_IDLE_PCT_SEQWRITE_IOPS=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` } -parse_lat() { - local OUTPUT_LAT=$1 - RAND_READ_LAT=`cat $OUTPUT_LAT | jq '.jobs[0].read.lat_ns.mean'| cut -f1 -d.` - RAND_WRITE_LAT=`cat $OUTPUT_LAT | jq '.jobs[1].write.lat_ns.mean'| cut -f1 -d.` - SEQ_READ_LAT=`cat $OUTPUT_LAT | jq '.jobs[2].read.lat_ns.mean'| cut -f1 -d.` - SEQ_WRITE_LAT=`cat $OUTPUT_LAT | jq '.jobs[3].write.lat_ns.mean'| cut -f1 -d.` - CPU_IDLE_PCT_LAT=`cat $OUTPUT_LAT| jq '.cpu_idleness.system' | cut -f1 -d.` +parse_randread_iops() { + local OUTPUT=${1} + RANDREAD_IOPS=`cat $OUTPUT | jq '.jobs[0].read.iops_mean'| cut -f1 -d.` + CPU_IDLE_PCT_RANDREAD_IOPS=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` } -FMT="%15s%25s\n" -CMP_FMT="%15s%25s%5s%25s%5s%20s\n" +parse_randwrite_iops() { + local OUTPUT=${1} + RANDWRITE_IOPS=`cat $OUTPUT | jq '.jobs[0].write.iops_mean'| cut -f1 -d.` + CPU_IDLE_PCT_RANDWRITE_IOPS=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +# Bandwidth +parse_seqread_bandwidth() { + local OUTPUT=${1} + SEQREAD_BANDWIDTH=`cat $OUTPUT | jq '.jobs[0].read.bw_mean'| cut -f1 -d.` + CPU_IDLE_PCT_SEQREAD_BANDWIDTH=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +parse_seqwrite_bandwidth() { + local OUTPUT=${1} + SEQWRITE_BANDWIDTH=`cat $OUTPUT | jq '.jobs[0].write.bw_mean'| cut -f1 -d.` + CPU_IDLE_PCT_SEQWRITE_BANDWIDTH=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +parse_randread_bandwidth() { + local OUTPUT=${1} + RANDREAD_BANDWIDTH=`cat $OUTPUT | jq '.jobs[0].read.bw_mean'| cut -f1 -d.` + CPU_IDLE_PCT_RANDREAD_BANDWIDTH=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +parse_randwrite_bandwidth() { + local OUTPUT=${1} + RANDWRITE_BANDWIDTH=`cat $OUTPUT | jq '.jobs[0].write.bw_mean'| cut -f1 -d.` + CPU_IDLE_PCT_RANDWRITE_BANDWIDTH=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +# Latency +parse_seqread_latency() { + local OUTPUT=${1} + SEQREAD_LATENCY=`cat $OUTPUT | jq '.jobs[0].read.lat_ns.mean'| cut -f1 -d.` + CPU_IDLE_PCT_SEQREAD_LATENCY=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +parse_seqwrite_latency() { + local OUTPUT=${1} + SEQWRITE_LATENCY=`cat $OUTPUT | jq '.jobs[0].write.lat_ns.mean'| cut -f1 -d.` + CPU_IDLE_PCT_SEQWRITE_LATENCY=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +parse_randread_latency() { + local OUTPUT=${1} + RANDREAD_LATENCY=`cat $OUTPUT | jq '.jobs[0].read.lat_ns.mean'| cut -f1 -d.` + CPU_IDLE_PCT_RANDREAD_LATENCY=`cat $OUTPUT | jq '.cpu_idleness.system' | cut -f1 -d.` +} + +parse_randwrite_latency() { + local OUTPUT=${1} + RANDWRITE_LATENCY=`cat $OUTPUT | jq '.jobs[0].write.lat_ns.mean'| cut -f1 -d.` + 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=`cat $OUTPUT | jq '.jobs[0].read.clat_ns.percentile["99.000000"]'| cut -f1 -d.` +} + +parse_seqwrite_latency_p99() { + local OUTPUT=${1} + SEQWRITE_LATENCY=`cat $OUTPUT | jq '.jobs[0].write.clat_ns.percentile["99.000000"]'| cut -f1 -d.` +} + +parse_randread_latency_p99() { + local OUTPUT=${1} + RANDREAD_LATENCY=`cat $OUTPUT | jq '.jobs[0].read.clat_ns.percentile["99.000000"]'| cut -f1 -d.` +} + +parse_randwrite_latency_p99() { + local OUTPUT=${1} + RANDWRITE_LATENCY=`cat $OUTPUT | jq '.jobs[0].write.clat_ns.percentile["99.000000"]'| cut -f1 -d.` +} + + +FMT="%30s%30s\n" +CMP_FMT="%20s%30s%10s%30s%10s%25s\n" commaize() { - echo $1 | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta' + echo $1 | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta' } calc_cmp_iops() { - DELTA_RAND_READ_IOPS=$(($SECOND_RAND_READ_IOPS-$FIRST_RAND_READ_IOPS)) - CMP_RAND_READ_IOPS=`awk "BEGIN {printf \"%.2f\", - $DELTA_RAND_READ_IOPS*100/$FIRST_RAND_READ_IOPS}"`"%" - DELTA_RAND_WRITE_IOPS=$(($SECOND_RAND_WRITE_IOPS-$FIRST_RAND_WRITE_IOPS)) - CMP_RAND_WRITE_IOPS=`awk "BEGIN {printf \"%.2f\", - $DELTA_RAND_WRITE_IOPS*100/$FIRST_RAND_WRITE_IOPS}"`"%" - DELTA_SEQ_READ_IOPS=$(($SECOND_SEQ_READ_IOPS-$FIRST_SEQ_READ_IOPS)) - CMP_SEQ_READ_IOPS=`awk "BEGIN {printf \"%.2f\", - $DELTA_SEQ_READ_IOPS*100/$FIRST_SEQ_READ_IOPS}"`"%" - DELTA_SEQ_WRITE_IOPS=$(($SECOND_SEQ_WRITE_IOPS-$FIRST_SEQ_WRITE_IOPS)) - CMP_SEQ_WRITE_IOPS=`awk "BEGIN {printf \"%.2f\", - $DELTA_SEQ_WRITE_IOPS*100/$FIRST_SEQ_WRITE_IOPS}"`"%" - CMP_CPU_IDLE_PCT_IOPS=$(($SECOND_CPU_IDLE_PCT_IOPS - $FIRST_CPU_IDLE_PCT_IOPS)) -} - -calc_cmp_bw() { - DELTA_RAND_READ_BW=$(($SECOND_RAND_READ_BW-$FIRST_RAND_READ_BW)) - CMP_RAND_READ_BW=`awk "BEGIN {printf \"%.2f\", - $DELTA_RAND_READ_BW*100/$FIRST_RAND_READ_BW}"`"%" - DELTA_RAND_WRITE_BW=$(($SECOND_RAND_WRITE_BW-$FIRST_RAND_WRITE_BW)) - CMP_RAND_WRITE_BW=`awk "BEGIN {printf \"%.2f\", - $DELTA_RAND_WRITE_BW*100/$FIRST_RAND_WRITE_BW}"`"%" - DELTA_SEQ_READ_BW=$(($SECOND_SEQ_READ_BW-$FIRST_SEQ_READ_BW)) - CMP_SEQ_READ_BW=`awk "BEGIN {printf \"%.2f\", - $DELTA_SEQ_READ_BW*100/$FIRST_SEQ_READ_BW}"`"%" - DELTA_SEQ_WRITE_BW=$(($SECOND_SEQ_WRITE_BW-$FIRST_SEQ_WRITE_BW)) - CMP_SEQ_WRITE_BW=`awk "BEGIN {printf \"%.2f\", - $DELTA_SEQ_WRITE_BW*100/$FIRST_SEQ_WRITE_BW}"`"%" - CMP_CPU_IDLE_PCT_BW=$(($SECOND_CPU_IDLE_PCT_BW - $FIRST_CPU_IDLE_PCT_BW)) -} - -calc_cmp_lat() { - DELTA_RAND_READ_LAT=$(($SECOND_RAND_READ_LAT-$FIRST_RAND_READ_LAT)) - CMP_RAND_READ_LAT=`awk "BEGIN {printf \"%.2f\", - $DELTA_RAND_READ_LAT*100/$FIRST_RAND_READ_LAT}"`"%" - DELTA_RAND_WRITE_LAT=$(($SECOND_RAND_WRITE_LAT-$FIRST_RAND_WRITE_LAT)) - CMP_RAND_WRITE_LAT=`awk "BEGIN {printf \"%.2f\", - $DELTA_RAND_WRITE_LAT*100/$FIRST_RAND_WRITE_LAT}"`"%" - DELTA_SEQ_READ_LAT=$(($SECOND_SEQ_READ_LAT-$FIRST_SEQ_READ_LAT)) - CMP_SEQ_READ_LAT=`awk "BEGIN {printf \"%.2f\", - $DELTA_SEQ_READ_LAT*100/$FIRST_SEQ_READ_LAT}"`"%" - DELTA_SEQ_WRITE_LAT=$(($SECOND_SEQ_WRITE_LAT-$FIRST_SEQ_WRITE_LAT)) - CMP_SEQ_WRITE_LAT=`awk "BEGIN {printf \"%.2f\", - $DELTA_SEQ_WRITE_LAT*100/$FIRST_SEQ_WRITE_LAT}"`"%" - CMP_CPU_IDLE_PCT_LAT=$(($SECOND_CPU_IDLE_PCT_LAT - $FIRST_CPU_IDLE_PCT_LAT)) + DELTA_RANDREAD_IOPS=$((${SECOND_RANDREAD_IOPS:-0}-${FIRST_RANDREAD_IOPS:-0})) + CMP_RANDREAD_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_RANDREAD_IOPS:-0}*100/${FIRST_RANDREAD_IOPS:-0}}"`"%" + DELTA_RANDWRITE_IOPS=$((${SECOND_RANDWRITE_IOPS:-0}-${FIRST_RANDWRITE_IOPS:-0})) + CMP_RANDWRITE_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_RANDWRITE_IOPS:-0}*100/${FIRST_RANDWRITE_IOPS:-0}}"`"%" + DELTA_SEQREAD_IOPS=$((${SECOND_SEQREAD_IOPS:-0}-${FIRST_SEQREAD_IOPS:-0})) + CMP_SEQREAD_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_SEQREAD_IOPS:-0}*100/${FIRST_SEQREAD_IOPS:-0}}"`"%" + DELTA_SEQWRITE_IOPS=$((${SECOND_SEQWRITE_IOPS:-0}-${FIRST_SEQWRITE_IOPS:-0})) + CMP_SEQWRITE_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_SEQWRITE_IOPS:-0}*100/${FIRST_SEQWRITE_IOPS:-0}}"`"%" + + DELTA_CPU_IDLE_PCT_RANDREAD_IOPS=$((${SECOND_CPU_IDLE_PCT_RANDREAD_IOPS:-0}-${FIRST_CPU_IDLE_PCT_RANDREAD_IOPS:-0})) + CMP_CPU_IDLE_PCT_RANDREAD_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_RANDREAD_IOPS:-0}*100/${FIRST_CPU_IDLE_PCT_RANDREAD_IOPS:-0}}"`"%" + DELTA_CPU_IDLE_PCT_RANDWRITE_IOPS=$((${SECOND_CPU_IDLE_PCT_RANDWRITE_IOPS:-0}-${FIRST_CPU_IDLE_PCT_RANDWRITE_IOPS:-0})) + CMP_CPU_IDLE_PCT_RANDWRITE_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_RANDWRITE_IOPS:-0}*100/${FIRST_CPU_IDLE_PCT_RANDWRITE_IOPS:-0}}"`"%" + DELTA_CPU_IDLE_PCT_SEQREAD_IOPS=$((${SECOND_CPU_IDLE_PCT_SEQREAD_IOPS:-0}-${FIRST_CPU_IDLE_PCT_SEQREAD_IOPS:-0})) + CMP_CPU_IDLE_PCT_SEQREAD_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_SEQREAD_IOPS:-0}*100/${FIRST_CPU_IDLE_PCT_SEQREAD_IOPS:-0}}"`"%" + DELTA_CPU_IDLE_PCT_SEQWRITE_IOPS=$((${SECOND_CPU_IDLE_PCT_SEQWRITE_IOPS:-0}-${FIRST_CPU_IDLE_PCT_SEQWRITE_IOPS:-0})) + CMP_CPU_IDLE_PCT_SEQWRITE_IOPS=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_SEQWRITE_IOPS:-0}*100/${FIRST_CPU_IDLE_PCT_SEQWRITE_IOPS:-0}}"`"%" +} + +calc_cmp_bandwidth() { + DELTA_RANDREAD_BANDWIDTH=$((${SECOND_RANDREAD_BANDWIDTH:-0}-${FIRST_RANDREAD_BANDWIDTH:-0})) + CMP_RANDREAD_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_RANDREAD_BANDWIDTH:-0}*100/${FIRST_RANDREAD_BANDWIDTH:-0}}"`"%" + DELTA_RANDWRITE_BANDWIDTH=$((${SECOND_RANDWRITE_BANDWIDTH:-0}-${FIRST_RANDWRITE_BANDWIDTH:-0})) + CMP_RANDWRITE_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_RANDWRITE_BANDWIDTH:-0}*100/${FIRST_RANDWRITE_BANDWIDTH:-0}}"`"%" + DELTA_SEQREAD_BANDWIDTH=$((${SECOND_SEQREAD_BANDWIDTH:-0}-${FIRST_SEQREAD_BANDWIDTH:-0})) + CMP_SEQREAD_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_SEQREAD_BANDWIDTH:-0}*100/${FIRST_SEQREAD_BANDWIDTH:-0}}"`"%" + DELTA_SEQWRITE_BANDWIDTH=$((${SECOND_SEQWRITE_BANDWIDTH:-0}-${FIRST_SEQWRITE_BANDWIDTH:-0})) + CMP_SEQWRITE_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_SEQWRITE_BANDWIDTH:-0}*100/${FIRST_SEQWRITE_BANDWIDTH:-0}}"`"%" + + DELTA_CPU_IDLE_PCT_RANDREAD_BANDWIDTH=$((${SECOND_CPU_IDLE_PCT_RANDREAD_BANDWIDTH:-0}-${FIRST_CPU_IDLE_PCT_RANDREAD_BANDWIDTH:-0})) + CMP_CPU_IDLE_PCT_RANDREAD_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_RANDREAD_BANDWIDTH:-0}*100/${FIRST_CPU_IDLE_PCT_RANDREAD_BANDWIDTH:-0}}"`"%" + DELTA_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH=$((${SECOND_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH:-0}-${FIRST_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH:-0})) + CMP_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH:-0}*100/${FIRST_CPU_IDLE_PCT_RANDWRITE_BANDWIDTH:-0}}"`"%" + DELTA_CPU_IDLE_PCT_SEQREAD_BANDWIDTH=$((${SECOND_CPU_IDLE_PCT_SEQREAD_BANDWIDTH:-0}-${FIRST_CPU_IDLE_PCT_SEQREAD_BANDWIDTH:-0})) + CMP_CPU_IDLE_PCT_SEQREAD_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_SEQREAD_BANDWIDTH:-0}*100/${FIRST_CPU_IDLE_PCT_SEQREAD_BANDWIDTH:-0}}"`"%" + DELTA_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH=$((${SECOND_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH:-0}-${FIRST_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH:-0})) + CMP_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH:-0}*100/${FIRST_CPU_IDLE_PCT_SEQWRITE_BANDWIDTH:-0}}"`"%" +} + +calc_cmp_latency() { + DELTA_RANDREAD_LATENCY=$((${SECOND_RANDREAD_LATENCY:-0}-${FIRST_RANDREAD_LATENCY:-0})) + CMP_RANDREAD_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_RANDREAD_LATENCY:-0}*100/${FIRST_RANDREAD_LATENCY:-0}}"`"%" + DELTA_RANDWRITE_LATENCY=$((${SECOND_RANDWRITE_LATENCY:-0}-${FIRST_RANDWRITE_LATENCY:-0})) + CMP_RANDWRITE_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_RANDWRITE_LATENCY:-0}*100/${FIRST_RANDWRITE_LATENCY:-0}}"`"%" + DELTA_SEQREAD_LATENCY=$((${SECOND_SEQREAD_LATENCY:-0}-${FIRST_SEQREAD_LATENCY:-0})) + CMP_SEQREAD_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_SEQREAD_LATENCY:-0}*100/${FIRST_SEQREAD_LATENCY:-0}}"`"%" + DELTA_SEQWRITE_LATENCY=$((${SECOND_SEQWRITE_LATENCY:-0}-${FIRST_SEQWRITE_LATENCY:-0})) + CMP_SEQWRITE_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_SEQWRITE_LATENCY:-0}*100/${FIRST_SEQWRITE_LATENCY:-0}}"`"%" + + DELTA_CPU_IDLE_PCT_RANDREAD_LATENCY=$((${SECOND_CPU_IDLE_PCT_RANDREAD_LATENCY:-0}-${FIRST_CPU_IDLE_PCT_RANDREAD_LATENCY:-0})) + CMP_CPU_IDLE_PCT_RANDREAD_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_RANDREAD_LATENCY:-0}*100/${FIRST_CPU_IDLE_PCT_RANDREAD_LATENCY:-0}}"`"%" + DELTA_CPU_IDLE_PCT_RANDWRITE_LATENCY=$((${SECOND_CPU_IDLE_PCT_RANDWRITE_LATENCY:-0}-${FIRST_CPU_IDLE_PCT_RANDWRITE_LATENCY:-0})) + CMP_CPU_IDLE_PCT_RANDWRITE_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_RANDWRITE_LATENCY:-0}*100/${FIRST_CPU_IDLE_PCT_RANDWRITE_LATENCY:-0}}"`"%" + DELTA_CPU_IDLE_PCT_SEQREAD_LATENCY=$((${SECOND_CPU_IDLE_PCT_SEQREAD_LATENCY:-0}-${FIRST_CPU_IDLE_PCT_SEQREAD_LATENCY:-0})) + CMP_CPU_IDLE_PCT_SEQREAD_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_SEQREAD_LATENCY:-0}*100/${FIRST_CPU_IDLE_PCT_SEQREAD_LATENCY:-0}}"`"%" + DELTA_CPU_IDLE_PCT_SEQWRITE_LATENCY=$((${SECOND_CPU_IDLE_PCT_SEQWRITE_LATENCY:-0}-${FIRST_CPU_IDLE_PCT_SEQWRITE_LATENCY:-0})) + CMP_CPU_IDLE_PCT_SEQWRITE_LATENCY=`awk "BEGIN {printf \"%.2f\", + ${DELTA_CPU_IDLE_PCT_SEQWRITE_LATENCY:-0}*100/${FIRST_CPU_IDLE_PCT_SEQWRITE_LATENCY:-0}}"`"%" } diff --git a/fio/bw-include.fio b/fio/jobs/bandwidth-include.fio similarity index 100% rename from fio/bw-include.fio rename to fio/jobs/bandwidth-include.fio diff --git a/fio/jobs/bandwidth-quick.fio b/fio/jobs/bandwidth-quick.fio new file mode 100644 index 0000000..8f1e9e6 --- /dev/null +++ b/fio/jobs/bandwidth-quick.fio @@ -0,0 +1,19 @@ +[randread-bandwidth] +readwrite=randread +include bandwidth-include.fio +include quick-include.fio + +[randwrite-bandwidth] +readwrite=randwrite +include bandwidth-include.fio +include quick-include.fio + +[seqread-bandwidth] +readwrite=read +include bandwidth-include.fio +include quick-include.fio + +[seqwrite-bandwidth] +readwrite=write +include bandwidth-include.fio +include quick-include.fio diff --git a/fio/jobs/bandwidth.fio b/fio/jobs/bandwidth.fio new file mode 100644 index 0000000..d652b57 --- /dev/null +++ b/fio/jobs/bandwidth.fio @@ -0,0 +1,19 @@ +[randread-bandwidth] +readwrite=randread +include bandwidth-include.fio +include common-include.fio + +[randwrite-bandwidth] +readwrite=randwrite +include bandwidth-include.fio +include common-include.fio + +[seqread-bandwidth] +readwrite=read +include bandwidth-include.fio +include common-include.fio + +[seqwrite-bandwidth] +readwrite=write +include bandwidth-include.fio +include common-include.fio diff --git a/fio/common-include.fio b/fio/jobs/common-include.fio similarity index 100% rename from fio/common-include.fio rename to fio/jobs/common-include.fio diff --git a/fio/iops-include.fio b/fio/jobs/iops-include.fio similarity index 100% rename from fio/iops-include.fio rename to fio/jobs/iops-include.fio diff --git a/fio/iops-quick.fio b/fio/jobs/iops-quick.fio similarity index 80% rename from fio/iops-quick.fio rename to fio/jobs/iops-quick.fio index 7af961c..6196b88 100644 --- a/fio/iops-quick.fio +++ b/fio/jobs/iops-quick.fio @@ -1,19 +1,19 @@ -[rand-read-iops] +[randread-iops] readwrite=randread include iops-include.fio include quick-include.fio -[rand-write-iops] +[randwrite-iops] readwrite=randwrite include iops-include.fio include quick-include.fio -[seq-read-iops] +[seqread-iops] readwrite=read include iops-include.fio include quick-include.fio -[seq-write-iops] +[seqwrite-iops] readwrite=write include iops-include.fio include quick-include.fio diff --git a/fio/iops.fio b/fio/jobs/iops.fio similarity index 80% rename from fio/iops.fio rename to fio/jobs/iops.fio index 19e4586..325b6c5 100644 --- a/fio/iops.fio +++ b/fio/jobs/iops.fio @@ -1,19 +1,19 @@ -[rand-read-iops] +[randread-iops] readwrite=randread include iops-include.fio include common-include.fio -[rand-write-iops] +[randwrite-iops] readwrite=randwrite include iops-include.fio include common-include.fio -[seq-read-iops] +[seqread-iops] readwrite=read include iops-include.fio include common-include.fio -[seq-write-iops] +[seqwrite-iops] readwrite=write include iops-include.fio include common-include.fio diff --git a/fio/lat-include.fio b/fio/jobs/latency-include.fio similarity index 100% rename from fio/lat-include.fio rename to fio/jobs/latency-include.fio diff --git a/fio/jobs/latency-quick.fio b/fio/jobs/latency-quick.fio new file mode 100644 index 0000000..a1a5a41 --- /dev/null +++ b/fio/jobs/latency-quick.fio @@ -0,0 +1,19 @@ +[randread-latency] +readwrite=randread +include latency-include.fio +include quick-include.fio + +[randwrite-latency] +readwrite=randwrite +include latency-include.fio +include quick-include.fio + +[seqread-latency] +readwrite=read +include latency-include.fio +include quick-include.fio + +[seqwrite-latency] +readwrite=write +include latency-include.fio +include quick-include.fio diff --git a/fio/jobs/latency.fio b/fio/jobs/latency.fio new file mode 100644 index 0000000..241a069 --- /dev/null +++ b/fio/jobs/latency.fio @@ -0,0 +1,19 @@ +[randread-latency] +readwrite=randread +include latency-include.fio +include common-include.fio + +[randwrite-latency] +readwrite=randwrite +include latency-include.fio +include common-include.fio + +[seqread-latency] +readwrite=read +include latency-include.fio +include common-include.fio + +[seqwrite-latency] +readwrite=write +include latency-include.fio +include common-include.fio diff --git a/fio/quick-include.fio b/fio/jobs/quick-include.fio similarity index 100% rename from fio/quick-include.fio rename to fio/jobs/quick-include.fio diff --git a/fio/latency-quick.fio b/fio/latency-quick.fio deleted file mode 100644 index be347cb..0000000 --- a/fio/latency-quick.fio +++ /dev/null @@ -1,19 +0,0 @@ -[rand-read-lat] -readwrite=randread -include lat-include.fio -include quick-include.fio - -[rand-write-lat] -readwrite=randwrite -include lat-include.fio -include quick-include.fio - -[seq-read-lat] -readwrite=read -include lat-include.fio -include quick-include.fio - -[seq-write-lat] -readwrite=write -include lat-include.fio -include quick-include.fio diff --git a/fio/latency.fio b/fio/latency.fio deleted file mode 100644 index 973abf7..0000000 --- a/fio/latency.fio +++ /dev/null @@ -1,19 +0,0 @@ -[rand-read-lat] -readwrite=randread -include lat-include.fio -include common-include.fio - -[rand-write-lat] -readwrite=randwrite -include lat-include.fio -include common-include.fio - -[seq-read-lat] -readwrite=read -include lat-include.fio -include common-include.fio - -[seq-write-lat] -readwrite=write -include lat-include.fio -include common-include.fio diff --git a/fio/parse.sh b/fio/parse.sh index 2a5c843..a2f7ab4 100755 --- a/fio/parse.sh +++ b/fio/parse.sh @@ -5,106 +5,113 @@ set -e CURRENT_DIR="$(dirname "$(readlink -f "$0")")" source $CURRENT_DIR/func.sh -if [ -z $1 ]; -then - echo Require FIO output prefix - exit 1 +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" ] && [ "$P99_LATENCY" = "false" ]; 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}" -PREFIX=${1} -OUTPUT_IOPS=${PREFIX}-iops.json -OUTPUT_BW=${PREFIX}-bandwidth.json -OUTPUT_LAT=${PREFIX}-latency.json - -if [ ! -f "$OUTPUT_IOPS" ]; then - echo "$OUTPUT_IOPS doesn't exist" -else - parse_iops $OUTPUT_IOPS +if [ -z "${2}" ]; then + echo Require FIO metrics + exit 1 fi +METRICS="${2}" -if [ ! -f "$OUTPUT_BW" ]; then - echo "$OUTPUT_BW doesn't exist" -else - parse_bw $OUTPUT_BW +if [ -z "${3}" ]; then + echo Require FIO output prefix + exit 1 fi - -if [ ! -f "$OUTPUT_LAT" ]; then - echo "$OUTPUT_LAT doesn't exist" +PREFIX="${3}" + +P99_LATENCY="${4:-true}" + +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" + if [ "$P99_LATENCY" = "true" ]; then + parse_${TYPE}_${METRIC}_p99 "$OUTPUT" + else + parse_${TYPE}_${METRIC} "$OUTPUT" + fi + done +done + +# Initialize the result file name +# Build the summary with header information +if [ "$P99_LATENCY" = "false" ]; then + RESULT="${PREFIX}.summary" + TITLE="FIO Benchmark Summary" else - parse_lat $OUTPUT_LAT -fi - -RESULT=${1}.summary - -QUICK_MODE_TEXT="Quick Mode: disabled" -if [ -n "$QUICK_MODE" ]; then - QUICK_MODE_TEXT="Quick Mode: enabled" -fi - -SIZE_TEXT="Size: 10g" -if [ -n "$SIZE" ]; then - SIZE_TEXT="Size: $SIZE" + RESULT="${PREFIX}_p99_latency.summary" + TITLE="FIO Benchmark P99 Latency Summary" fi +# Construct the SUMMARY with dynamic content SUMMARY=" -========================= -FIO Benchmark Summary +================================== +$TITLE For: $PREFIX -CPU Idleness Profiling: $CPU_IDLE_PROF -$SIZE_TEXT -$QUICK_MODE_TEXT -========================= +CPU Idleness Profiling: ${CPU_IDLE_PROF:-not provided} +Size: ${SIZE:-10g} +Quick Mode: ${QUICK_MODE:-disabled} +================================== " -if [ x"$CPU_IDLE_PROF" = x"enabled" ]; then - printf -v cxt "IOPS (Read/Write)\n$FMT$FMT$FMT\n"\ - "Random:" \ - "$(commaize $RAND_READ_IOPS) / $(commaize $RAND_WRITE_IOPS)" \ - "Sequential:" \ - "$(commaize $SEQ_READ_IOPS) / $(commaize $SEQ_WRITE_IOPS)" \ - "CPU Idleness:" \ - "$CPU_IDLE_PCT_IOPS%" - SUMMARY+=$cxt - - printf -v cxt "Bandwidth in KiB/sec (Read/Write)\n$FMT$FMT$FMT\n"\ - "Random:" \ - "$(commaize $RAND_READ_BW) / $(commaize $RAND_WRITE_BW)" \ - "Sequential:" \ - "$(commaize $SEQ_READ_BW) / $(commaize $SEQ_WRITE_BW)" \ - "CPU Idleness:" \ - "$CPU_IDLE_PCT_BW%" - SUMMARY+=$cxt - - printf -v cxt "Latency in ns (Read/Write)\n$FMT$FMT\n"\ - "Random:" \ - "$(commaize $RAND_READ_LAT) / $(commaize $RAND_WRITE_LAT)" \ - "Sequential:" \ - "$(commaize $SEQ_READ_LAT) / $(commaize $SEQ_WRITE_LAT)" \ - "CPU Idleness:" \ - "$CPU_IDLE_PCT_LAT%" - SUMMARY+=$cxt -else - printf -v cxt "IOPS (Read/Write)\n$FMT$FMT\n"\ - "Random:" \ - "$(commaize $RAND_READ_IOPS) / $(commaize $RAND_WRITE_IOPS)" \ - "Sequential:" \ - "$(commaize $SEQ_READ_IOPS) / $(commaize $SEQ_WRITE_IOPS)" - SUMMARY+=$cxt - - printf -v cxt "Bandwidth in KiB/sec (Read/Write)\n$FMT$FMT$FMT\n"\ - "Random:" \ - "$(commaize $RAND_READ_BW) / $(commaize $RAND_WRITE_BW)" \ - "Sequential:" \ - "$(commaize $SEQ_READ_BW) / $(commaize $SEQ_WRITE_BW)" - SUMMARY+=$cxt - - printf -v cxt "Latency in ns (Read/Write)\n$FMT$FMT\n"\ - "Random:" \ - "$(commaize $RAND_READ_LAT) / $(commaize $RAND_WRITE_LAT)" \ - "Sequential:" \ - "$(commaize $SEQ_READ_LAT) / $(commaize $SEQ_WRITE_LAT)" - SUMMARY+=$cxt +# Append performance metrics to the summary +if [ "$P99_LATENCY" = "false" ]; then + append_metric "IOPS" "ops" \ + "$RANDREAD_IOPS" "$CPU_IDLE_PCT_RANDREAD_IOPS" \ + "$RANDWRITE_IOPS" "$CPU_IDLE_PCT_RANDWRITE_IOPS" \ + "$SEQREAD_IOPS" "$CPU_IDLE_PCT_SEQREAD_IOPS" \ + "$SEQWRITE_IOPS" "$CPU_IDLE_PCT_SEQWRITE_IOPS" + append_metric "Bandwidth" "KiB/sec" \ + "$RANDREAD_BANDWIDTH" "$CPU_IDLE_PCT_RANDREAD_BANDWIDTH" \ + "$RANDWRITE_BANDWIDTH" "$CPU_IDLE_PCT_RANDWRITE_BANDWIDTH" \ + "$SEQREAD_BANDWIDTH" "$CPU_IDLE_PCT_SEQREAD_BANDWIDTH" \ + "$SEQWRITE_BANDWIDTH" "$CPU_IDLE_PCT_SEQWRITE_BANDWIDTH" fi -echo "$SUMMARY" > $RESULT -cat $RESULT +append_metric "Latency" "ns" \ + "$RANDREAD_LATENCY" "$CPU_IDLE_PCT_RANDREAD_LATENCY" \ + "$RANDWRITE_LATENCY" "$CPU_IDLE_PCT_RANDWRITE_LATENCY" \ + "$SEQREAD_LATENCY" "$CPU_IDLE_PCT_SEQREAD_LATENCY" \ + "$SEQWRITE_LATENCY" "$CPU_IDLE_PCT_SEQWRITE_LATENCY" + +echo "$SUMMARY" > "$RESULT" +cat "$RESULT" diff --git a/fio/run.sh b/fio/run.sh index 22c60ac..2dfbbbc 100755 --- a/fio/run.sh +++ b/fio/run.sh @@ -3,65 +3,45 @@ set -e CURRENT_DIR="$(dirname "$(readlink -f "$0")")" +TEST_FILE="${1:-$FILE_NAME}" +OUTPUT="${2:-test_device}" +TEST_SIZE="${3:-${SIZE:-10g}}" -TEST_FILE=$1 - -# cmdline overrides the environment variable if [ -z "$TEST_FILE" ]; then - TEST_FILE=$FILE_NAME + echo "Require test file name" + exit 1 fi -if [ -z "$TEST_FILE" ]; then - echo Require test file name - exit 1 -fi +echo "TEST_FILE: $TEST_FILE" +echo "TEST_OUTPUT_PREFIX: $OUTPUT" +echo "TEST_SIZE: $TEST_SIZE" if [ x"$CPU_IDLE_PROF" = x"enabled" ]; then - IDLE_PROF="--idle-prof=percpu" + IDLE_PROF="--idle-prof=percpu" fi -echo TEST_FILE: $TEST_FILE +IO_TYPES="${IO_TYPES:-seqread,seqwrite,randread,randwrite}" +METRICS="${METRICS:-bandwidth,iops,latency}" -OUTPUT=$2 -if [ -z $OUTPUT ]; -then - OUTPUT=test_device -fi -echo TEST_OUTPUT_PREFIX: $OUTPUT +echo "IO_TYPES: $IO_TYPES" +echo "METRICS: $METRICS" -TEST_SIZE=$3 -if [ -z "$TEST_SIZE" ]; then - TEST_SIZE=$SIZE -fi -if [ -z "$TEST_SIZE" ]; then - TEST_SIZE="10g" -fi -echo TEST_SIZE: $TEST_SIZE +IFS=',' read -r -a io_types_array <<< "${IO_TYPES}" +IFS=',' read -r -a metrics_array <<< "${METRICS}" -IOPS_FIO="iops.fio" -BW_FIO="bandwidth.fio" -LAT_FIO="latency.fio" -if [ -n "$QUICK_MODE" ]; then - echo QUICK_MODE: enabled - IOPS_FIO="iops-quick.fio" - BW_FIO="bandwidth-quick.fio" - LAT_FIO="latency-quick.fio" -fi +for TYPE in "${io_types_array[@]}"; do + for METRIC in "${metrics_array[@]}"; do + echo "Running $TYPE $METRIC test" -OUTPUT_IOPS=${OUTPUT}-iops.json -OUTPUT_BW=${OUTPUT}-bandwidth.json -OUTPUT_LAT=${OUTPUT}-latency.json + JOB_FILE="$CURRENT_DIR/jobs/$METRIC.fio" + if [ "$QUICK_MODE" = "enabled" ]; then + JOB_FILE="$CURRENT_DIR/jobs/$METRIC-quick.fio" + fi -echo Benchmarking $IOPS_FIO into $OUTPUT_IOPS -fio $CURRENT_DIR/$IOPS_FIO $IDLE_PROF --filename=$TEST_FILE --size=$TEST_SIZE \ - --output-format=json --output=$OUTPUT_IOPS -echo Benchmarking $BW_FIO into $OUTPUT_BW -fio $CURRENT_DIR/$BW_FIO $IDLE_PROF --filename=$TEST_FILE --size=$TEST_SIZE \ - --output-format=json --output=$OUTPUT_BW -echo Benchmarking $LAT_FIO into $OUTPUT_LAT -fio $CURRENT_DIR/$LAT_FIO $IDLE_PROF --filename=$TEST_FILE --size=$TEST_SIZE \ - --output-format=json --output=$OUTPUT_LAT + fio "$CURRENT_DIR/jobs/$METRIC.fio" $IDLE_PROF --section="${TYPE}-${METRIC}" --filename="$TEST_FILE" --size="$TEST_SIZE" --output-format=json --output="${OUTPUT}-${TYPE}-${METRIC}.json" + done +done + +"$CURRENT_DIR/parse.sh" "$IO_TYPES" "$METRICS" "$OUTPUT" "false" +"$CURRENT_DIR/parse.sh" "$IO_TYPES" "latency" "$OUTPUT" "true" -if [ -z "$SKIP_PARSE" ]; then - $CURRENT_DIR/parse.sh $OUTPUT -fi