From 3a3482da7136899a726e4922dae8e23b7990f4b5 Mon Sep 17 00:00:00 2001 From: taptap Date: Wed, 24 Jun 2026 16:29:26 +0200 Subject: [PATCH] Fix: Increase sync wait time for 1-connection under network latency - Dynamically scale wait time based on latency and connection count - 1 connection gets additional latency-proportional wait time - Added extra sync calls after server shutdown - Prevents verification failures due to slow disk writes under WAN conditions Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- benchmark_network.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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")