Skip to content

Commit 527ec3d

Browse files
committed
fio: add iostat and keep the output files
- that we can do more investigation with these output files Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
1 parent 39bf5ca commit 527ec3d

File tree

7 files changed

+74
-19
lines changed

7 files changed

+74
-19
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:20.04
22

3-
RUN apt update && apt install -y fio bash jq
3+
RUN apt update && apt install -y fio bash jq vim atop sysstat util-linux
44

55
ADD ./fio/ /fio/
6-
WORKDIR ["/fio/"]
6+
WORKDIR /fio
77
ENTRYPOINT ["bash", "/fio/run.sh"]

deploy/fio-cmp.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,21 @@ spec:
4949
value: Local-Path
5050
- name: FIRST_VOL_FILE
5151
value: "/volume1/test"
52+
- name: FIRST_VOL_BACKEND_DEVICE
53+
value: "" # the backend device of first volume
5254
- name: SECOND_VOL_NAME
5355
value: Longhorn
5456
- name: SECOND_VOL_FILE
5557
value: "/volume2/test"
58+
- name: SECOND_VOL_BACKEND_DEVICE
59+
value: "" # the backend device of second volume
5660
- name: SIZE
5761
value: "30G" # must be smaller or match the PVC size
5862
- name: CPU_IDLE_PROF
5963
value: "disabled" # must be "enabled" or "disabled"
6064
volumeMounts:
65+
- name: output
66+
mountPath: output/
6167
- name: vol1
6268
mountPath: /volume1/
6369
- name: vol2
@@ -68,8 +74,14 @@ spec:
6874
# devicePath: /volume1/test
6975
#- name: vol2
7076
# devicePath: /volume2/test
77+
securityContext:
78+
privileged: true
7179
restartPolicy: Never
7280
volumes:
81+
- name: output
82+
hostPath:
83+
path: /root/output # replace with your host path for output
84+
type: DirectoryOrCreate
7385
- name: vol1
7486
persistentVolumeClaim:
7587
claimName: kbench-pvc-1

deploy/fio.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ spec:
3030
env:
3131
#- name: QUICK_MODE # for debugging
3232
# value: "1"
33+
- name: LONGHORN_BACKEND_DEVICE
34+
value: "" # the backend device of Longhorn volume
3335
- name: FILE_NAME
3436
value: "/volume/test"
3537
- name: SIZE
@@ -42,6 +44,8 @@ spec:
4244
#volumeDevices:
4345
#- name: vol
4446
# devicePath: /volume/test
47+
securityContext:
48+
privileged: true
4549
restartPolicy: Never
4650
volumes:
4751
- name: vol

fio/cmp_parse.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ if [ -z "SECOND_VOL_NAME" ]; then
1515
exit 1
1616
fi
1717

18-
FIRST_IOPS=${FIRST_VOL_NAME}-iops.json
19-
FIRST_BW=${FIRST_VOL_NAME}-bandwidth.json
20-
FIRST_LAT=${FIRST_VOL_NAME}-latency.json
18+
FIRST_IOPS=/output/${FIRST_VOL_NAME}-iops.json
19+
FIRST_BW=/output/${FIRST_VOL_NAME}-bandwidth.json
20+
FIRST_LAT=/output/${FIRST_VOL_NAME}-latency.json
2121

22-
SECOND_IOPS=${SECOND_VOL_NAME}-iops.json
23-
SECOND_BW=${SECOND_VOL_NAME}-bandwidth.json
24-
SECOND_LAT=${SECOND_VOL_NAME}-latency.json
22+
SECOND_IOPS=/output/${SECOND_VOL_NAME}-iops.json
23+
SECOND_BW=/output/${SECOND_VOL_NAME}-bandwidth.json
24+
SECOND_LAT=/output/${SECOND_VOL_NAME}-latency.json
2525

2626
parse_iops $FIRST_IOPS
2727
FIRST_RAND_READ_IOPS=$RAND_READ_IOPS
@@ -71,7 +71,7 @@ SECOND_CPU_IDLE_PCT_LAT=$CPU_IDLE_PCT_LAT
7171

7272
calc_cmp_lat
7373

74-
RESULT=${FIRST_VOL_NAME}_vs_${SECOND_VOL_NAME}.summary
74+
RESULT=/output/${FIRST_VOL_NAME}_vs_${SECOND_VOL_NAME}.summary
7575

7676
QUICK_MODE_TEXT="Quick Mode: disabled"
7777
if [ -n "$QUICK_MODE" ]; then

fio/cmp_run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ if [ -z "SECOND_VOL_FILE" ]; then
2525
exit 1
2626
fi
2727

28+
# clean up the previous result
29+
rm -rf /output/*
30+
2831
#disable parsing in run.sh
2932
export SKIP_PARSE=1
3033

31-
$CURRENT_DIR/run.sh $FIRST_VOL_FILE $FIRST_VOL_NAME
32-
$CURRENT_DIR/run.sh $SECOND_VOL_FILE $SECOND_VOL_NAME
34+
# already cleanup, skip it in run.sh
35+
SKIP_CLEANUP=1 $CURRENT_DIR/run.sh $FIRST_VOL_FILE $FIRST_VOL_NAME $FIRST_VOL_BACKEND_DEVICE
36+
SKIP_CLEANUP=1 $CURRENT_DIR/run.sh $SECOND_VOL_FILE $SECOND_VOL_NAME $SECOND_VOL_BACKEND_DEVICE
3337

3438
$CURRENT_DIR/cmp_parse.sh

fio/parse.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ then
1212
fi
1313

1414
PREFIX=${1}
15-
OUTPUT_IOPS=${PREFIX}-iops.json
16-
OUTPUT_BW=${PREFIX}-bandwidth.json
17-
OUTPUT_LAT=${PREFIX}-latency.json
15+
OUTPUT_IOPS=/output/${PREFIX}-iops.json
16+
OUTPUT_BW=/output/${PREFIX}-bandwidth.json
17+
OUTPUT_LAT=/output/${PREFIX}-latency.json
1818

1919
if [ ! -f "$OUTPUT_IOPS" ]; then
2020
echo "$OUTPUT_IOPS doesn't exist"
@@ -34,7 +34,7 @@ else
3434
parse_lat $OUTPUT_LAT
3535
fi
3636

37-
RESULT=${1}.summary
37+
RESULT=/output/${1}.summary
3838

3939
QUICK_MODE_TEXT="Quick Mode: disabled"
4040
if [ -n "$QUICK_MODE" ]; then

fio/run.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
#sleep 1000000
34
set -e
45

56
CURRENT_DIR="$(dirname "$(readlink -f "$0")")"
@@ -29,7 +30,15 @@ then
2930
fi
3031
echo TEST_OUTPUT_PREFIX: $OUTPUT
3132

32-
TEST_SIZE=$3
33+
BACKEND_DEVICE=$3
34+
if [ -z "$BACKEND_DEVICE" ]; then
35+
BACKEND_DEVICE=$LONGHORN_BACKEND_DEVICE
36+
fi
37+
if [ -z "$BACKEND_DEVICE" ]; then
38+
BACKEND_DEVICE=""
39+
fi
40+
41+
TEST_SIZE=$4
3342
if [ -z "$TEST_SIZE" ]; then
3443
TEST_SIZE=$SIZE
3544
fi
@@ -48,19 +57,45 @@ if [ -n "$QUICK_MODE" ]; then
4857
LAT_FIO="latency-quick.fio"
4958
fi
5059

51-
OUTPUT_IOPS=${OUTPUT}-iops.json
52-
OUTPUT_BW=${OUTPUT}-bandwidth.json
53-
OUTPUT_LAT=${OUTPUT}-latency.json
60+
OUTPUT_IOPS=/output/${OUTPUT}-iops.json
61+
OUTPUT_IOPS_IOSTAT=/output/${OUTPUT}-iops-iostat.log
62+
OUTPUT_BW=/output/${OUTPUT}-bandwidth.json
63+
OUTPUT_BW_IOSTAT=/output/${OUTPUT}-bandwidth-iostat.log
64+
OUTPUT_LAT=/output/${OUTPUT}-latency.json
65+
OUTPUT_LAT_IOSTAT=/output/${OUTPUT}-latency-iostat.log
66+
67+
68+
# clean up the previous result
69+
if [ -z "$SKIP_CLEANUP" ]; then
70+
rm -rf /output/*
71+
fi
5472

5573
echo Benchmarking $IOPS_FIO into $OUTPUT_IOPS
74+
iostat -x -k -t -y 1 $BACKEND_DEVICE > $OUTPUT_IOPS_IOSTAT &
75+
IOSTAT_PID=$!
76+
5677
fio $CURRENT_DIR/$IOPS_FIO $IDLE_PROF --filename=$TEST_FILE --size=$TEST_SIZE \
5778
--output-format=json --output=$OUTPUT_IOPS
79+
echo "Benchmarking $IOPS_FIO into $OUTPUT_IOPS done, kill the iostat process (pid: $IOSTAT_PID)..."
80+
kill -9 $IOSTAT_PID
81+
5882
echo Benchmarking $BW_FIO into $OUTPUT_BW
83+
iostat -x -k -t -y 1 $BACKEND_DEVICE > $OUTPUT_BW_IOSTAT &
84+
IOSTAT_PID=$!
85+
5986
fio $CURRENT_DIR/$BW_FIO $IDLE_PROF --filename=$TEST_FILE --size=$TEST_SIZE \
6087
--output-format=json --output=$OUTPUT_BW
88+
echo "Benchmarking $BW_FIO into $OUTPUT_BW done, kill the iostat process (pid: $IOSTAT_PID)..."
89+
kill -9 $IOSTAT_PID
90+
6191
echo Benchmarking $LAT_FIO into $OUTPUT_LAT
92+
iostat -x -k -t -y 1 $BACKEND_DEVICE > $OUTPUT_LAT_IOSTAT &
93+
IOSTAT_PID=$!
94+
6295
fio $CURRENT_DIR/$LAT_FIO $IDLE_PROF --filename=$TEST_FILE --size=$TEST_SIZE \
6396
--output-format=json --output=$OUTPUT_LAT
97+
echo "Benchmarking $LAT_FIO into $OUTPUT_LAT done, kill the iostat process (pid: $IOSTAT_PID)..."
98+
kill -9 $IOSTAT_PID
6499

65100
if [ -z "$SKIP_PARSE" ]; then
66101
$CURRENT_DIR/parse.sh $OUTPUT

0 commit comments

Comments
 (0)