diff --git a/benchmark_network.sh b/benchmark_network.sh index 22a67fb..8b0ceb7 100755 --- a/benchmark_network.sh +++ b/benchmark_network.sh @@ -25,8 +25,8 @@ set -euo pipefail # ── Defaults ────────────────────────────────────────────────────────────── -DATA_SIZE_MB=${2:-100} -RUN_COUNT=${3:-3} +DATA_SIZE_MB=${2:-50} +RUN_COUNT=${3:-1} SCENARIO="${1:---lan}" # ── Parse scenario ──────────────────────────────────────────────────────── @@ -59,7 +59,7 @@ case "$SCENARIO" in esac # ── Ports ──────────────────────────────────────────────────────────────── -FASTSYNC_PORT=19399 +FASTSYNC_PORT=19410 RSYNC_PORT=19400 HOST="127.0.0.1" @@ -227,28 +227,27 @@ run_fastsync() { "$SERVER_BIN" -p "$port" -d "$dst" >/dev/null 2>&1 & local spid=$! - sleep 0.5 + sleep 1 local output - output=$(timeout 300 "$CLIENT_BIN" -h "$HOST" -p "$port" -s "$SRC_DIR" -n "$nconn" 2>&1) || true + output=$(timeout 600 "$CLIENT_BIN" -h "$HOST" -p "$port" -s "$SRC_DIR" -n "$nconn" 2>&1) || true # With network latency, wait for all data to be written and synced to disk - # Base wait: proportional to latency (round-trip * 2 for safety margin) - # Connection factor: more connections = faster transfer = less extra wait needed - # 1 connection needs more time as data is sent sequentially - local base_wait=$(( LATENCY_MS / 10 )) - [ "$base_wait" -lt 2 ] && base_wait=2 - local conn_factor=$(( 10 / nconn )) - local wait_time=$(( base_wait + conn_factor + 3 )) - [ "$wait_time" -lt 5 ] && wait_time=5 - [ "$nconn" -eq 1 ] && wait_time=$(( wait_time + LATENCY_MS / 20 + 3 )) + # For 1 connection: much more time needed as data is sequential + # For high latency: extra margin for TCP retransmissions and jitter + local wait_time=5 + if [ "$nconn" -eq 1 ]; then + wait_time=$(( 15 + LATENCY_MS / 5 + (DATA_SIZE_MB / 20) )) + else + wait_time=$(( 5 + LATENCY_MS / 10 + (DATA_SIZE_MB / 50) )) + fi + [ "$wait_time" -lt 10 ] && wait_time=10 sleep $wait_time kill "$spid" 2>/dev/null || true wait "$spid" 2>/dev/null || true sync - sleep 1 - sync + sleep 2 local ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0") local mbs=$(echo "$output" | grep -oP 'throughput_mbs=\K[0-9.]+' || echo "0")