fix(perf): bench jq direction bug + libaio + json note guard [#709]
- write tests read .write.* explicitly (jq // kept read=0 for writes) - libaio1 installed everywhere (real aio engine, no sync cap) - fio stdout notes stripped before jq parse Ticket: https://projects.knownelement.com/issues/709
This commit is contained in:
@@ -30,33 +30,31 @@ b meta path "$BENCH_DIR"
|
||||
b meta runtime "$RUNTIME"
|
||||
b meta size "$SIZE"
|
||||
|
||||
run_fio() { # $1=testname $2=fio-args...
|
||||
local name="$1"; shift
|
||||
# fio may print human notes (e.g. sync-engine warnings) before the JSON on
|
||||
# stdout; strip everything before the opening brace so jq always gets JSON.
|
||||
parse_fio() { # $1=json-file $2=testname $3=read|write
|
||||
sed -n '/^{/,$p' "$1" | jq -r --arg n "$2" --arg d "$3" '
|
||||
.jobs[0] as $j |
|
||||
($n) + "|iops=" + ($j[$d].iops | tostring) + "|" +
|
||||
"bw_kbps=" + ($j[$d].bw | tostring) + "|" +
|
||||
"p99_ms=" + (($j[$d].clat_ns.percentile["99.000000"] // 0) / 1000000 | tostring)' | while IFS='|' read -r n rest; do
|
||||
printf 'BENCH|%s|%s|%s\n' "$HOSTID" "$n" "$rest"
|
||||
done
|
||||
}
|
||||
|
||||
run_fio() { # $1=testname $2=read|write $3+=fio-args
|
||||
local name="$1"; local dir="$2"; shift 2
|
||||
fio --name="$name" --output-format=json --timeout=120 "$@" \
|
||||
> "$BENCH_DIR/.fio-out.json" 2>"$BENCH_DIR/.fio-err" || {
|
||||
b "fio_${name}" ERROR; return; }
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
while IFS='|' read -r n rest; do
|
||||
printf 'BENCH|%s|%s|%s\n' "$HOSTID" "$n" "$rest"
|
||||
done < <(jq -r --arg n "$name" '
|
||||
.jobs[0] as $j |
|
||||
($n) + "|iops=" + ($j.read.iops // $j.write.iops | tostring) + "|" +
|
||||
"bw_kbps=" + (($j.read.bw // $j.write.bw) | tostring) + "|" +
|
||||
"p99_ms=" + (($j.read.clat_ns.percentile["99.000000"] // $j.write.clat_ns.percentile["99.000000"] // 0) / 1000000 | tostring)' \
|
||||
"$BENCH_DIR/.fio-out.json")
|
||||
else
|
||||
# no jq: minimal grep fallback
|
||||
grep -oE '"(iops|bw)":[0-9.]+' "$BENCH_DIR/.fio-out.json" | head -2 | while IFS=: read -r k v; do
|
||||
b "fio_${name}_${k}" "$v"
|
||||
done
|
||||
fi
|
||||
parse_fio "$BENCH_DIR/.fio-out.json" "$name" "$dir"
|
||||
}
|
||||
|
||||
# 4k random read/write (IOPS), 1M sequential read/write (MB/s); direct to skip cache
|
||||
run_fio randread4k --filename="$BENCH_DIR/perf-test-file" --rw=randread --bs=4k --direct=1 --iodepth=16 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio randwrite4k --filename="$BENCH_DIR/perf-test-file" --rw=randwrite --bs=4k --direct=1 --iodepth=16 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio seqread1m --filename="$BENCH_DIR/perf-test-file" --rw=read --bs=1M --direct=1 --iodepth=8 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio seqwrite1m --filename="$BENCH_DIR/perf-test-file" --rw=write --bs=1M --direct=1 --iodepth=8 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio randread4k read --filename="$BENCH_DIR/perf-test-file" --rw=randread --bs=4k --direct=1 --iodepth=16 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio randwrite4k write --filename="$BENCH_DIR/perf-test-file" --rw=randwrite --bs=4k --direct=1 --iodepth=16 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio seqread1m read --filename="$BENCH_DIR/perf-test-file" --rw=read --bs=1M --direct=1 --iodepth=8 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
run_fio seqwrite1m write --filename="$BENCH_DIR/perf-test-file" --rw=write --bs=1M --direct=1 --iodepth=8 --time_based --runtime="$RUNTIME" --size="$SIZE"
|
||||
|
||||
rm -f "$BENCH_DIR/.fio-out.json" "$BENCH_DIR/.fio-err"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user