mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-03 06:36:35 +00:00
feat(bench): record write latency in preflight queue samples
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
This commit is contained in:
@@ -286,18 +286,48 @@ marker="$GUARD_DIR/$host"
|
||||
case "${QUEUE_FIXTURE:-quiet}" in
|
||||
missing) exit 2 ;;
|
||||
hung) exec sleep 60 ;;
|
||||
diskstats-*)
|
||||
QUEUE_SAMPLE_DIR="$(mktemp -d "$GUARD_DIR/diskstats.XXXXXXXX")"
|
||||
export QUEUE_SAMPLE_DIR
|
||||
trap 'rm -rf -- "$QUEUE_SAMPLE_DIR"' EXIT
|
||||
printf '10.00 0.00\n' >"$QUEUE_SAMPLE_DIR/uptime"
|
||||
cat >"$QUEUE_SAMPLE_DIR/diskstats" <<'STATS'
|
||||
259 0 nvme0n1 0 0 0 0 20 0 80 40 0 0 100
|
||||
259 1 nvme1n1 0 0 0 0 30 0 80 60 0 0 100
|
||||
STATS
|
||||
cp "$QUEUE_SAMPLE_DIR/diskstats" "$QUEUE_SAMPLE_DIR/after"
|
||||
if [[ "$QUEUE_FIXTURE" != diskstats-idle ]]; then
|
||||
writes=24
|
||||
write_ms=48
|
||||
case "$QUEUE_FIXTURE" in
|
||||
diskstats-reset-count) writes=19 ;;
|
||||
diskstats-reset-time) write_ms=39 ;;
|
||||
esac
|
||||
printf '259 0 nvme0n1 0 0 0 0 %s 0 96 %s 0 0 250\n' "$writes" "$write_ms" >"$QUEUE_SAMPLE_DIR/after"
|
||||
printf '259 1 nvme1n1 0 0 0 0 46 0 128 76 0 0 150\n' >>"$QUEUE_SAMPLE_DIR/after"
|
||||
fi
|
||||
advance_diskstats() {
|
||||
printf '15.00 0.00\n' >"$QUEUE_SAMPLE_DIR/uptime"
|
||||
cp "$QUEUE_SAMPLE_DIR/after" "$QUEUE_SAMPLE_DIR/diskstats"
|
||||
}
|
||||
export -f advance_diskstats
|
||||
command=$(printf '%s\n' "$command" | sed \
|
||||
's@/proc/uptime@"$QUEUE_SAMPLE_DIR/uptime"@g; s@/proc/diskstats@"$QUEUE_SAMPLE_DIR/diskstats"@g; s@^sleep 5$@advance_diskstats@')
|
||||
bash -c "$command"
|
||||
exit
|
||||
;;
|
||||
reset)
|
||||
n=0
|
||||
[[ ! -f "$marker" ]] || read -r n < "$marker"
|
||||
n=$((n+1))
|
||||
printf '%s\n' "$n" > "$marker"
|
||||
if [[ "$host" == host-b && "$n" == 2 ]]; then
|
||||
echo '0.050000 0.800000'
|
||||
echo '0.050000 0.800000 0 NA NA'
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo '0.050000 0.070000'
|
||||
echo '0.050000 0.070000 0 NA NA'
|
||||
SSH
|
||||
cat > "$GUARD_BIN/curl" <<'CURL'
|
||||
#!/usr/bin/env bash
|
||||
@@ -369,4 +399,28 @@ if PATH="$GUARD_BIN:$PATH" QUEUE_FIXTURE=hung "$SCRIPT_DIR/wait_cluster_disk_que
|
||||
fi
|
||||
rg -q 'failed or timed out' "$TMP_DIR/queue-timeout.log"
|
||||
|
||||
queue_cmd=("$SCRIPT_DIR/wait_cluster_disk_queue.sh"
|
||||
--target a=host-a --devices a=nvme0n1+nvme1n1 --timeout-secs 11)
|
||||
|
||||
for fixture in diskstats-write diskstats-idle; do
|
||||
PATH="$GUARD_BIN:$PATH" QUEUE_FIXTURE="$fixture" "${queue_cmd[@]}" >"$TMP_DIR/$fixture.tsv"
|
||||
printf 'sample\tnode\tmean_queue\tpeak_queue\tcompleted_writes\twrite_ms_per_op\tpeak_write_ms_per_op\n' >"$TMP_DIR/expected.tsv"
|
||||
for sample in 1 2; do
|
||||
if [[ "$fixture" == diskstats-write ]]; then
|
||||
printf '%s\ta\t0.020000\t0.030000\t20\t1.200000\t2.000000\n' "$sample"
|
||||
else
|
||||
printf '%s\ta\t0.000000\t0.000000\t0\tNA\tNA\n' "$sample"
|
||||
fi
|
||||
done >>"$TMP_DIR/expected.tsv"
|
||||
diff -u "$TMP_DIR/expected.tsv" "$TMP_DIR/$fixture.tsv"
|
||||
done
|
||||
|
||||
for fixture in diskstats-reset-count diskstats-reset-time; do
|
||||
if PATH="$GUARD_BIN:$PATH" QUEUE_FIXTURE="$fixture" "${queue_cmd[@]}" >"$TMP_DIR/$fixture.log" 2>&1; then
|
||||
echo "expected $fixture to fail an otherwise quiet sample" >&2
|
||||
exit 1
|
||||
fi
|
||||
rg -q 'disk queue sample failed or timed out' "$TMP_DIR/$fixture.log"
|
||||
done
|
||||
|
||||
echo "object batch benchmark enhanced tests passed"
|
||||
|
||||
@@ -73,6 +73,7 @@ trap 'exit 143' TERM
|
||||
|
||||
# Only validated device names are placed in the SSH command. The sampler uses
|
||||
# monotonic uptime and the weighted I/O milliseconds from /proc/diskstats.
|
||||
# Write completions and write milliseconds describe the same sampling window.
|
||||
sample=$(cat <<'REMOTE'
|
||||
set -eu
|
||||
export LC_ALL=C
|
||||
@@ -81,8 +82,8 @@ snapshot() {
|
||||
BEGIN { n=split(devices,d," "); for(i=1;i<=n;i++) want[d[i]]=1 }
|
||||
FNR==NR { t=$1; next }
|
||||
$3 in want {
|
||||
if (NF<14 || $14 !~ /^[0-9]+$/) exit 2
|
||||
print $3,t,$14
|
||||
if (NF<14 || $8 !~ /^[0-9]+$/ || $11 !~ /^[0-9]+$/ || $14 !~ /^[0-9]+$/) exit 2
|
||||
print $3,t,$14,$8,$11
|
||||
got++
|
||||
}
|
||||
END { if (got!=n) exit 2 }
|
||||
@@ -93,10 +94,36 @@ sleep 5
|
||||
after=$(snapshot)
|
||||
printf '%s\n--\n%s\n' "$before" "$after" | awk '
|
||||
$0=="--" { second=1; next }
|
||||
!second { if ($1 in t) bad=1; t[$1]=$2; w[$1]=$3; count++; next }
|
||||
{ if (!($1 in t) || seen[$1]++ || $2<=t[$1] || $3<w[$1]) { bad=1; next }
|
||||
q=($3-w[$1])/(1000*($2-t[$1])); sum+=q; if(q>peak)peak=q; got++ }
|
||||
END { if (bad||!count||got!=count) exit 2; printf "%.6f %.6f\n",sum/count,peak }
|
||||
!second {
|
||||
if ($1 in t) bad=1
|
||||
t[$1]=$2; w[$1]=$3; writes[$1]=$4; write_ms[$1]=$5
|
||||
count++
|
||||
next
|
||||
}
|
||||
{
|
||||
if (!($1 in t) || seen[$1]++ || $2<=t[$1] || $3<w[$1] || $4<writes[$1] || $5<write_ms[$1]) {
|
||||
bad=1
|
||||
next
|
||||
}
|
||||
q=($3-w[$1])/(1000*($2-t[$1]))
|
||||
sum+=q
|
||||
if (q>peak) peak=q
|
||||
completed=$4-writes[$1]
|
||||
if (completed>0) {
|
||||
elapsed_ms=$5-write_ms[$1]
|
||||
total_completed+=completed
|
||||
total_write_ms+=elapsed_ms
|
||||
await_ms=elapsed_ms/completed
|
||||
if (await_ms>peak_write_ms) peak_write_ms=await_ms
|
||||
}
|
||||
got++
|
||||
}
|
||||
END {
|
||||
if (bad||!count||got!=count) exit 2
|
||||
printf "%.6f %.6f %.0f",sum/count,peak,total_completed
|
||||
if (total_completed>0) printf " %.6f %.6f\n",total_write_ms/total_completed,peak_write_ms
|
||||
else printf " NA NA\n"
|
||||
}
|
||||
'
|
||||
REMOTE
|
||||
)
|
||||
@@ -104,7 +131,7 @@ REMOTE
|
||||
end=$((SECONDS+budget))
|
||||
streak=0
|
||||
sample_number=0
|
||||
printf 'sample\tnode\tmean_queue\tpeak_queue\n'
|
||||
printf 'sample\tnode\tmean_queue\tpeak_queue\tcompleted_writes\twrite_ms_per_op\tpeak_write_ms_per_op\n'
|
||||
while ((end-SECONDS >= 5)); do
|
||||
sample_number=$((sample_number+1))
|
||||
remaining=$((end-SECONDS))
|
||||
@@ -125,12 +152,13 @@ while ((end-SECONDS >= 5)); do
|
||||
quiet=true
|
||||
for i in "${!targets[@]}"; do
|
||||
result=$(cat "$artifacts/$i")
|
||||
if [[ ! "$result" =~ ^([0-9]+\.[0-9]+)\ ([0-9]+\.[0-9]+)$ ]]; then
|
||||
if [[ ! "$result" =~ ^([0-9]+\.[0-9]+)\ ([0-9]+\.[0-9]+)\ ([0-9]+)\ (NA|[0-9]+\.[0-9]+)\ (NA|[0-9]+\.[0-9]+)$ ]]; then
|
||||
echo "invalid disk queue sample from ${targets[i]%%=*}" >&2; exit 1
|
||||
fi
|
||||
mean="${BASH_REMATCH[1]}"
|
||||
peak="${BASH_REMATCH[2]}"
|
||||
printf '%s\t%s\t%s\t%s\n' "$sample_number" "${targets[i]%%=*}" "$mean" "$peak"
|
||||
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$sample_number" "${targets[i]%%=*}" "$mean" "$peak" \
|
||||
"${BASH_REMATCH[3]}" "${BASH_REMATCH[4]}" "${BASH_REMATCH[5]}"
|
||||
if ! awk -v mean="$mean" -v peak="$peak" 'BEGIN {exit !(mean<=0.25 && peak<=0.75)}'; then quiet=false; fi
|
||||
done
|
||||
if [[ "$quiet" == true ]]; then
|
||||
|
||||
Reference in New Issue
Block a user