Fix: Dynamic wait times based on actual transfer duration

- Wait time now uses actual transfer_ms from client output
- Formula: transfer_time/1000 + latency_margin + sync_margin + extra_for_1conn
- For 250ms transfer on LAN: ~0.25 + 2 + 3 + 0 = ~5.25s (vs 10-19s before)
- For 1 connection: extra 5s margin
- Minimum wait: 5s

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
taptap
2026-06-24 17:01:12 +02:00
parent bc21b7b39a
commit dd1f934570
+14 -11
View File
@@ -232,22 +232,25 @@ run_fastsync() {
local output local output
output=$(timeout 600 "$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 # Extract actual transfer time from client output
# For 1 connection: much more time needed as data is sequential local transfer_ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0")
# For high latency: extra margin for TCP retransmissions and jitter local transfer_ms_int=$(echo "$transfer_ms" | awk '{printf "%d", $1+0}')
local wait_time=5
if [ "$nconn" -eq 1 ]; then # Wait: transfer time + latency-based margin + disk sync margin
wait_time=$(( 15 + LATENCY_MS / 5 + (DATA_SIZE_MB / 20) )) # For 1 connection, add extra margin as it's sequential
else local latency_margin=$(( LATENCY_MS * 2 ))
wait_time=$(( 5 + LATENCY_MS / 10 + (DATA_SIZE_MB / 50) )) local sync_margin=3
fi local extra_for_1conn=0
[ "$wait_time" -lt 10 ] && wait_time=10 [ "$nconn" -eq 1 ] && extra_for_1conn=5
local wait_time=$(( transfer_ms_int / 1000 + latency_margin / 10 + sync_margin + extra_for_1conn ))
[ "$wait_time" -lt 5 ] && wait_time=5
sleep $wait_time sleep $wait_time
kill "$spid" 2>/dev/null || true kill "$spid" 2>/dev/null || true
wait "$spid" 2>/dev/null || true wait "$spid" 2>/dev/null || true
sync sync
sleep 2 sleep 1
local ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0") 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") local mbs=$(echo "$output" | grep -oP 'throughput_mbs=\K[0-9.]+' || echo "0")