#!/usr/bin/env bash # Clean, reproducible knee sweep: ROLLBACK latency vs N at the DEFAULT threshold # (65536). Fresh file per trial, fresh psql session, R repeats, median reported. # Only the ROLLBACK is timed (\timing on sits immediately before it). # # Self-validating: each trial also prints the file mode AFTER rollback; it must # equal the committed baseline, proving the undo chain was actually applied. A # trial where it does not is reported as INVALID rather than silently trusted. set -u PORT=${PORT:-5467} BIN=$HOME/undo-v2-inst/bin PSQL="$BIN/psql -p $PORT -U postgres -X -q -t -A" REPEATS=${REPEATS:-5} NS=${NS:-"100 500 1000 1500 2000 2500 3000 4000 6000 10000 20000"} THRS=${THRS:-"65536"} $PSQL -c "CREATE EXTENSION IF NOT EXISTS test_fileops;" >/dev/null 2>&1 median() { sort -n | awk '{a[NR]=$1} END{ if(NR==0){print "NA"} else if(NR%2){print a[(NR+1)/2]} else {printf "%.3f\n",(a[NR/2]+a[NR/2+1])/2} }'; } # baseline mode we commit before the txn (decimal 420 = 0644, preserved by mask) BASE=420 echo -e "threshold\tN\trollback_ms_median\ttrials\tvalid" for thr in $THRS; do for n in $NS; do vals=""; bad=0 for r in $(seq 1 $REPEATS); do out=$($PSQL 2>/dev/null <