Skip to content

Commit d8f4171

Browse files
author
eng-spfresh-worker
committed
eng-spfresh: include refresh-reference.sh helper on merge branch
1 parent 396d9af commit d8f4171

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
# refresh-reference.sh — re-run the merge-base reference perf at <scale>
3+
# and cache the result under
4+
# <workspace-repo>/tasks/distributed-index-scale-2k/results/_reference/<SCALE>/.
5+
#
6+
# This is a DELIBERATE HUMAN ACTION. Subagents must NOT run it on their
7+
# own — the protocol caches the reference once and refreshes only when
8+
# the merge-base advances by more than a trivial commit set. Running
9+
# this rotates the perf gate's reference for every fault case.
10+
#
11+
# Usage (on sdr):
12+
# evaluation/distributed/refresh-reference.sh --scale 1m|10m
13+
# [--workspace-repo PATH]
14+
# [--cluster-conf PATH]
15+
# [--mergebase-ref REF]
16+
# [--yes]
17+
#
18+
# Defaults:
19+
# --scale (required)
20+
# --workspace-repo $HOME/workspace/openclaw-tasks
21+
# --cluster-conf evaluation/distributed/configs/sdr_single.conf
22+
# (auto-generated by run_perf_validation.sh on first run)
23+
# --mergebase-ref users/zhangt/merge-distributed-to-tikv
24+
# --yes skip the interactive confirmation
25+
#
26+
# Hard guards (same as run_perf_validation.sh): no spfresh-dev-amd-005,
27+
# no scale != {1m, 10m}.
28+
29+
set -euo pipefail
30+
31+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
32+
SPTAG_REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
33+
34+
HOSTSHORT="$(hostname -s 2>/dev/null || hostname)"
35+
if [[ "$HOSTSHORT" == *"spfresh-dev-amd-005"* || "$HOSTSHORT" == *"msccl-dev-000005"* ]]; then
36+
echo "REFUSING: never run refresh-reference on spfresh-dev-amd-005" >&2
37+
exit 10
38+
fi
39+
40+
SCALE_LOW=""
41+
WS_REPO="${HOME}/workspace/openclaw-tasks"
42+
CLUSTER_CONF="${SCRIPT_DIR}/configs/sdr_single.conf"
43+
MERGEBASE_REF="users/zhangt/merge-distributed-to-tikv"
44+
ASSUME_YES=0
45+
46+
while [[ $# -gt 0 ]]; do
47+
case "$1" in
48+
--scale) SCALE_LOW="$2"; shift 2 ;;
49+
--workspace-repo) WS_REPO="$2"; shift 2 ;;
50+
--cluster-conf) CLUSTER_CONF="$2"; shift 2 ;;
51+
--mergebase-ref) MERGEBASE_REF="$2"; shift 2 ;;
52+
--yes|-y) ASSUME_YES=1; shift ;;
53+
*) echo "unknown arg: $1" >&2; exit 2 ;;
54+
esac
55+
done
56+
57+
[[ -n "$SCALE_LOW" ]] || { echo "Usage: $0 --scale 1m|10m [--yes]" >&2; exit 2; }
58+
case "$SCALE_LOW" in 1m|10m) ;; *) echo "REFUSING: scale '$SCALE_LOW'" >&2; exit 11 ;; esac
59+
SCALE_HI="${SCALE_LOW^^}"
60+
61+
REF_DIR="$WS_REPO/tasks/distributed-index-scale-2k/results/_reference/$SCALE_HI"
62+
mkdir -p "$REF_DIR"
63+
64+
# Choose a clean worktree at MERGEBASE_REF.
65+
REF_WT="$HOME/workspace/sptag-ft/wt/_reference"
66+
if [[ ! -d "$REF_WT" ]]; then
67+
git -C "$SPTAG_REPO_ROOT" worktree add "$REF_WT" "$MERGEBASE_REF"
68+
fi
69+
git -C "$REF_WT" fetch origin "$MERGEBASE_REF" --quiet || true
70+
git -C "$REF_WT" checkout "$MERGEBASE_REF" --quiet
71+
COMMIT="$(git -C "$REF_WT" rev-parse HEAD)"
72+
73+
if [[ "$ASSUME_YES" != "1" ]]; then
74+
cat <<EOF
75+
About to refresh perf reference at $SCALE_HI.
76+
branch: $MERGEBASE_REF @ $COMMIT
77+
worktree: $REF_WT
78+
output: $REF_DIR/{metrics.json,run.log,COMMIT}
79+
This rotates the gate for every fault case. Continue? [y/N]
80+
EOF
81+
read -r ans; [[ "$ans" =~ ^[Yy] ]] || { echo "aborted"; exit 0; }
82+
fi
83+
84+
[[ -x "$REF_WT/Release/SPTAGTest" ]] || { echo "Build SPTAGTest in $REF_WT first." >&2; exit 3; }
85+
86+
# Run via the existing single-node harness in the reference worktree.
87+
pushd "$REF_WT" >/dev/null
88+
"$REF_WT/evaluation/distributed/run_distributed.sh" run "$CLUSTER_CONF" "$SCALE_LOW" 1 \
89+
2>&1 | tee "$REF_DIR/run.log"
90+
popd >/dev/null
91+
92+
EMITTED="$REF_WT/output_${SCALE_LOW}_1node.json"
93+
[[ -f "$EMITTED" ]] || { echo "ERROR: $EMITTED missing"; exit 4; }
94+
cp "$EMITTED" "$REF_DIR/metrics.json"
95+
echo "$COMMIT" > "$REF_DIR/COMMIT"
96+
date -u +%Y%m%dT%H%M%SZ > "$REF_DIR/REFRESHED_AT"
97+
echo "[refresh-reference] cached reference at $REF_DIR (commit $COMMIT)"

0 commit comments

Comments
 (0)