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:
+14
-11
@@ -232,22 +232,25 @@ run_fastsync() {
|
||||
local output
|
||||
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
|
||||
# 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
|
||||
# Extract actual transfer time from client output
|
||||
local transfer_ms=$(echo "$output" | grep -oP 'ms=\K[0-9.]+' || echo "0")
|
||||
local transfer_ms_int=$(echo "$transfer_ms" | awk '{printf "%d", $1+0}')
|
||||
|
||||
# Wait: transfer time + latency-based margin + disk sync margin
|
||||
# For 1 connection, add extra margin as it's sequential
|
||||
local latency_margin=$(( LATENCY_MS * 2 ))
|
||||
local sync_margin=3
|
||||
local extra_for_1conn=0
|
||||
[ "$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
|
||||
kill "$spid" 2>/dev/null || true
|
||||
wait "$spid" 2>/dev/null || true
|
||||
sync
|
||||
sleep 2
|
||||
sleep 1
|
||||
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user