Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

bench: --skip-existing / SKIP_EXISTING=1 to resume a matrix set after an interruption

garrytan407c017623e2
diff --git a/scripts/bench/sync-freshness-matrix.sh b/scripts/bench/sync-freshness-matrix.sh
index c20627183f..7cbcdc6e39 100755
--- a/scripts/bench/sync-freshness-matrix.sh
+++ b/scripts/bench/sync-freshness-matrix.sh
@@ -1,13 +1,14 @@
#!/usr/bin/env bash
# GBRA-133 lane A: the cell sets behind docs of scripts/bench/sync-freshness.ts.
# scripts/bench/sync-freshness-matrix.sh <core|rtt|pollers|extras|embed|big|backlog|noop|pr4b|pr2b6|pr2b6-before> [work-dir] [checkout]
+# SKIP_EXISTING=1 resumes a set: cells whose result JSON exists are skipped.
# pr2b6 takes an engine in ENGINE=postgres|pglite (default both); pr2b6-before runs the comparison cells against [checkout]
# (the merge base before PR 2a) and then against this checkout, back to back on one machine.
# Cells run one at a time (they share the CPU). Each writes <work-dir>/results/<cell>.json;
# render the table with: bun scripts/bench/sync-freshness.ts --report <work-dir>/results
set -uo pipefail
SET=${1:?set}; W=${2:-$PWD/.context/bench/sync-freshness}; PR4B=${3:-}
-B="bun $(dirname "$0")/sync-freshness.ts --work-dir $W"
+B="bun $(dirname "$0")/sync-freshness.ts --work-dir $W ${SKIP_EXISTING:+--skip-existing}"
run() { echo "== $*" >&2; $B "$@" 2>&1 | grep -E '^\[freshness' | grep -E 'wrote|ERROR|never|cell ' >&2 || true; }
case "$SET" in
core)
diff --git a/scripts/bench/sync-freshness.ts b/scripts/bench/sync-freshness.ts
index 3797e81b0a..fb2bafd3c8 100644
--- a/scripts/bench/sync-freshness.ts
+++ b/scripts/bench/sync-freshness.ts
@@ -370,8 +370,14 @@ async function embedAudit(tokens: string[]): Promise<{ per_rep: Array<{ token: s
return ENGINE === 'postgres' ? admin(sql => run((s, p) => sql.unsafe(s, p as any[]) as any), dbName(MODE)) : withPglite(HOME, e => run((s, p) => e.executeRaw(s, p)));
}
+const cellId = [ENGINE, MODE, PAGES, SOURCES > 1 ? 's' + SOURCES : '', MULTI ? SCENARIO + '-' + RESIDENTS.join('+') : COMMIT, MULTI ? '' : TRIGGER, RTT ? 'rtt' + RTT : '',
+ !MULTI && SCENARIO !== 'plain' ? SCENARIO : '', DETECTION === 'poll' ? 'poll' : '', EMBED === 'stub' ? 'embed' + EMBED_LATENCY_MS : EMBED === 'keyless-stub' ? 'keylessstub' : '',
+ STUB_FAIL_MS ? 'fail' + STUB_FAIL_MS : '', LABEL.replace(/[^\w.-]/g, '_')].filter(Boolean).join('-');
+const outDir = join(WORK, 'results');
+
async function main(): Promise<void> {
mkdirSync(WORK, { recursive: true });
+ if (has('skip-existing') && existsSync(join(outDir, cellId + '.json'))) { log('cell ' + cellId + ': result exists, skipped (--skip-existing)'); return; }
if (ENGINE === 'postgres') harness = await startHarness({ pgPort: 55432, proxyPort: Number(flag('proxy-port', String(56000 + (process.pid % 1000)))), apiPort: 58474, keep: true });
const seen = new Map<string, { first: number; texts: Set<string> }>();
let failUntil = 0;
@@ -387,10 +393,6 @@ async function main(): Promise<void> {
writeConfig(HOME, MODE, brainUrl);
let measuredRtt: number | null = null;
if (ENGINE === 'postgres') { await harness!.setRtt(RTT); measuredRtt = await measureRtt(brainUrl!); }
- const cellId = [ENGINE, MODE, PAGES, SOURCES > 1 ? 's' + SOURCES : '', MULTI ? SCENARIO + '-' + RESIDENTS.join('+') : COMMIT, MULTI ? '' : TRIGGER, RTT ? 'rtt' + RTT : '',
- !MULTI && SCENARIO !== 'plain' ? SCENARIO : '', DETECTION === 'poll' ? 'poll' : '', EMBED === 'stub' ? 'embed' + EMBED_LATENCY_MS : EMBED === 'keyless-stub' ? 'keylessstub' : '',
- STUB_FAIL_MS ? 'fail' + STUB_FAIL_MS : '', LABEL.replace(/[^\w.-]/g, '_')].filter(Boolean).join('-');
- const outDir = join(WORK, 'results');
mkdirSync(join(outDir, 'logs'), { recursive: true });
const logFile = join(outDir, 'logs', cellId + '-' + Date.now() + '.log');
log('cell ' + cellId + ' (' + REPS + ' reps)');