From b20f5da1754e17f782fe2581a77bc775f678e88e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 08:10:23 -0700 Subject: [PATCH] fix(bench): isolate baseline Cargo configuration Co-Authored-By: GPT-6.1 Sol --- bench/run.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bench/run.sh b/bench/run.sh index 07947cc95a7..3def484dc12 100755 --- a/bench/run.sh +++ b/bench/run.sh @@ -180,6 +180,7 @@ cleanup() { fi if [[ -n $WORKTREE ]]; then git -C "$ROOT" worktree remove --force "$WORKTREE" >/dev/null 2>&1 || true + rmdir "$WORKTREE" 2>/dev/null || true fi # Close both pipe writers before waiting for the owned log copiers. if [[ -n $STDOUT_PID ]]; then @@ -208,6 +209,13 @@ cp -R "$ROOT/bench" "$RUN/harness" export CRITERION_HOME=$RUN/criterion +checkout_base() { + # Cargo merges every ancestor's .cargo/config.toml. A nested worktree would + # inherit this checkout's settings instead of measuring the base in isolation. + WORKTREE=$(mktemp -d "${TMPDIR:-/tmp}/moq-bench-base.XXXXXX") + git worktree add --detach "$WORKTREE" "$1" >/dev/null +} + # Shorter than Criterion's defaults, but still enough samples for confidence # intervals and outlier detection. Comparisons run both revisions on one host. CRITERION_ARGS=( @@ -372,8 +380,7 @@ measure_criterion() { fi : >"$base" if [[ -n $BASE ]]; then - WORKTREE=$RUN/base - git worktree add --detach "$WORKTREE" "$BASE" >/dev/null + checkout_base "$BASE" mkdir -p "$RUN/base-context" (cd "$WORKTREE" && python3 "$ROOT/bench/metadata.py" "$RUN/base-context" "$BASE" comparison-base) printf 'Criterion paired with base %s\n' "$BASE" @@ -822,8 +829,7 @@ run_profiles() { generate_certificate if [[ -n $BASE ]]; then - WORKTREE=$RUN/base - git worktree add --detach "$WORKTREE" "$BASE" >/dev/null + checkout_base "$BASE" mkdir -p "$RUN/base-context" (cd "$WORKTREE" && python3 "$ROOT/bench/metadata.py" "$RUN/base-context" "$BASE" --profile) fi @@ -951,8 +957,7 @@ elif [[ $MODE == --shard ]]; then exit 0 elif [[ -n $BASE ]]; then BASE_COMMIT=$(git rev-parse --verify "$BASE^{commit}") - WORKTREE=$RUN/base - git worktree add --detach "$WORKTREE" "$BASE_COMMIT" >/dev/null + checkout_base "$BASE_COMMIT" mkdir -p "$RUN/base-context" ( cd "$WORKTREE"