Fix: Multiple benchmark script bugs

- benchmark_network.sh:
  - Removed info() call in run_fastsync that contaminated output parsing
  - Reduced excessive wait times (was up to 66s for WAN)
  - More reasonable dynamic wait based on latency
- compare_rsync.sh:
  - Fixed hardcoded -n 4 connections, now accepts connection count parameter
  - Replaced slow md5sum verification with fast file count+size check
  - Added latency-aware wait times for 1 connection
- benchmark.sh:
  - Added sync after client to ensure disk writes complete
  - Added EXIT trap for tc netem cleanup and process cleanup
  - Removed duplicate manual cleanup
- benchmark_comprehensive.sh:
  - Added latency-aware wait times for 1 connection in run_fastsync
  - Added documentation note that rsync/cp bypass tc netem (use benchmark_network.sh for fair TCP comparison)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
taptap
2026-06-24 16:35:31 +02:00
parent 3a3482da71
commit 83f129314e
4 changed files with 63 additions and 18 deletions
+15 -5
View File
@@ -159,7 +159,9 @@ run_with_timer() {
}
# ── Run fastSyncAI ──────────────────────────────────────────────────────────
# Usage: run_fastsync <connection_count>
run_fastsync() {
local nconn=${1:-4}
local dst_dir="$DST_DIR_BASE/fastsync_$$"
mkdir -p "$dst_dir"
@@ -173,10 +175,13 @@ run_fastsync() {
# Run client and capture output
local client_output
client_output=$(timeout 120 "$CLIENT_BIN" -h "$HOST" -p "$PORT" -s "$SRC_DIR" -n 4 2>&1) || true
client_output=$(timeout 120 "$CLIENT_BIN" -h "$HOST" -p "$PORT" -s "$SRC_DIR" -n "$nconn" 2>&1) || true
# Wait for server to finish writing all files
sleep 3
# With latency, 1 connection needs more time
local wait_time=3
[ "$nconn" -eq 1 ] && [ "$LATENCY_MS" -gt 0 ] && wait_time=$(( 3 + LATENCY_MS / 10 + 2 ))
sleep $wait_time
# Clean up server
kill "$srv_pid" 2>/dev/null || true
wait "$srv_pid" 2>/dev/null || true
@@ -188,9 +193,14 @@ run_fastsync() {
ms=$(echo "$client_output" | grep "^BENCH:" | grep -oP 'ms=\K[0-9.]+' || echo "0")
mbs=$(echo "$client_output" | grep "^BENCH:" | grep -oP 'throughput_mbs=\K[0-9.]+' || echo "0")
# Verify files
if diff <(cd "$SRC_DIR" && find . -type f -exec md5sum {} \; | sort) \
<(cd "$dst_dir" && find . -type f -exec md5sum {} \; | sort) > /dev/null 2>&1; then
# Verify files using fast size-only check (much faster than md5sum)
local src_count dst_count src_size dst_size
src_count=$(find "$SRC_DIR" -type f | wc -l)
dst_count=$(find "$dst_dir" -type f | wc -l)
src_size=$(find "$SRC_DIR" -type f -printf '%s\n' | awk '{sum+=$1} END {print sum}')
dst_size=$(find "$dst_dir" -type f -printf '%s\n' | awk '{sum+=$1} END {print sum}')
if [ "$src_count" -eq "$dst_count" ] && [ "$src_size" -eq "$dst_size" ]; then
echo "${ms}|${mbs}|1"
else
echo "${ms}|${mbs}|0"