Skip to content

Commit 47592c6

Browse files
committed
Soak: enhanced RSS leak detection with first/last ratio check
1 parent 6ab88f9 commit 47592c6

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

scripts/soak-test.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -371,21 +371,24 @@ FINAL_DIAG="/tmp/cbm-diagnostics-${SERVER_PID}.json"
371371

372372
PASS=true
373373

374-
# Check 1: RSS growth
375-
# For short runs (<10min): check absolute ceiling (warmup noise dominates slope)
376-
# For long runs (>=10min): use linear regression on post-warmup samples (skip first 20%)
374+
# Check 1: Memory leak detection via RSS trend
375+
# This is the primary leak detector on ALL platforms (including Windows
376+
# where LeakSanitizer is unavailable). Catches both linear leaks (slope)
377+
# and step-function leaks (first vs last comparison).
377378
TOTAL_SAMPLES=$(awk -F, 'NR>1 && $3>0 { n++ } END { print n+0 }' "$METRICS_CSV")
378379
MAX_RSS=$(awk -F, 'NR>1 && $3>0 { if ($3>max) max=$3 } END { printf "%.0f", max/1024/1024 }' "$METRICS_CSV")
379-
echo "RSS max: ${MAX_RSS}MB (${TOTAL_SAMPLES} samples)" | tee -a "$SUMMARY"
380+
FIRST_RSS=$(awk -F, 'NR==2 && $3>0 { printf "%.0f", $3/1024/1024 }' "$METRICS_CSV")
381+
LAST_RSS=$(awk -F, '$3>0 { last=$3 } END { printf "%.0f", last/1024/1024 }' "$METRICS_CSV")
382+
echo "RSS: first=${FIRST_RSS}MB last=${LAST_RSS}MB max=${MAX_RSS}MB (${TOTAL_SAMPLES} samples)" | tee -a "$SUMMARY"
380383

381384
if [ "$DURATION_MIN" -lt 10 ]; then
382-
# Short run: absolute ceiling check
383-
if [ "${MAX_RSS:-0}" -gt 100 ] 2>/dev/null; then
384-
echo "FAIL: RSS ${MAX_RSS}MB > 100MB ceiling" | tee -a "$SUMMARY"
385+
# Short run: absolute ceiling (warmup noise dominates slope)
386+
if [ "${MAX_RSS:-0}" -gt 200 ] 2>/dev/null; then
387+
echo "FAIL: RSS ${MAX_RSS}MB > 200MB ceiling" | tee -a "$SUMMARY"
385388
PASS=false
386389
fi
387390
else
388-
# Long run: slope after skipping warmup (first 20% of samples)
391+
# Long run: linear regression on post-warmup samples (skip first 20%)
389392
RSS_SLOPE=$(awk -F, -v skip="$((TOTAL_SAMPLES / 5))" '
390393
NR>1 && $3>0 {
391394
row++
@@ -399,7 +402,17 @@ else
399402
}' "$METRICS_CSV")
400403
echo "RSS slope (post-warmup): ${RSS_SLOPE} KB/hr" | tee -a "$SUMMARY"
401404
if [ "${RSS_SLOPE:-0}" -gt 500 ] 2>/dev/null; then
402-
echo "FAIL: RSS slope ${RSS_SLOPE} KB/hr > 500 KB/hr threshold" | tee -a "$SUMMARY"
405+
echo "FAIL: RSS slope ${RSS_SLOPE} KB/hr > 500 KB/hr" | tee -a "$SUMMARY"
406+
PASS=false
407+
fi
408+
fi
409+
410+
# Check 1b: RSS ratio (last / first) — catches step-function leaks
411+
if [ "${FIRST_RSS:-0}" -gt 0 ] 2>/dev/null; then
412+
RSS_RATIO=$(awk "BEGIN { printf \"%.1f\", ${LAST_RSS} / ${FIRST_RSS} }")
413+
echo "RSS ratio (last/first): ${RSS_RATIO}x" | tee -a "$SUMMARY"
414+
if awk "BEGIN { exit (${LAST_RSS} / ${FIRST_RSS} > 3.0) ? 0 : 1 }" 2>/dev/null; then
415+
echo "FAIL: RSS grew ${RSS_RATIO}x (last=${LAST_RSS}MB vs first=${FIRST_RSS}MB)" | tee -a "$SUMMARY"
403416
PASS=false
404417
fi
405418
fi

0 commit comments

Comments
 (0)