diff --git a/benchmark_network.sh b/benchmark_network.sh index 0ccbbe3..e1a8a31 100755 --- a/benchmark_network.sh +++ b/benchmark_network.sh @@ -232,14 +232,22 @@ run_fastsync() { local output output=$(timeout 300 "$CLIENT_BIN" -h "$HOST" -p "$port" -s "$SRC_DIR" -n "$nconn" 2>&1) || true - # With network latency, wait longer for all data to be written - # 1 conn needs more time under latency - local wait_time=8 - [ "$nconn" -eq 1 ] && wait_time=10 + # With network latency, wait longer for all data to be written and synced to disk + # Scale wait time based on latency: base wait + (latency factor * connection count factor) + # 1 connection needs significantly more time under high latency + local base_wait=$(( LATENCY_MS * 2 / 10 )) + local conn_factor=$(( 16 / nconn )) + local wait_time=$(( base_wait + conn_factor + 5 )) + [ "$wait_time" -lt 10 ] && wait_time=10 + [ "$nconn" -eq 1 ] && wait_time=$(( wait_time + LATENCY_MS / 5 + 5 )) + + info "Waiting ${wait_time}s for sync to complete..." sleep $wait_time kill "$spid" 2>/dev/null || true wait "$spid" 2>/dev/null || true sync + sleep 2 + sync 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")