Files

33 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# Interleaved A/B of the host-side request path on the instant engine, repeats alternating base and new so a shared
# machine hurts both arms alike. Builds only; the model, the GPU and Python are not involved except for the summary table.
#
# run-ab.sh BASE_TREE NEW_TREE TOKENIZER_DIR SESSION.json OUT_DIR [REPS] [cp_replay args...]
#
# BASE_TREE / NEW_TREE: source trees (e.g. `git archive dbf487b` and a checkout of the new head), each already carrying
# control-plane/examples/cp_replay/main.rs and desktop-core/examples/cp_replay_grpc.rs (the baseline needs `encode_reference` and
# `decodes_to` shims on its Tokenizer for --verify only, not for timing). CARGO_TARGET_DIR_BASE / _NEW choose the target dirs.
# Writes OUT_DIR/{base,new}-{proc,grpc}-N.{json,txt}; `python3 scripts/cp/summarize.py OUT_DIR` prints the tables.
set -euo pipefail
BASE=$1 NEW=$2 TOK=$3 SESSION=$4 OUT=$5; REPS=${6:-3}; shift 6 2>/dev/null || shift $#
mkdir -p "$OUT"
build() { # tree target
( cd "$1" && CARGO_TARGET_DIR="$2" cargo build --locked --release -p leleka-control-plane --example cp_replay \
&& CARGO_TARGET_DIR="$2" cargo build --locked --release -p leleka-engine-host --example cp_replay_grpc ) >&2
}
TB=${CARGO_TARGET_DIR_BASE:-$BASE/target-ab}
TN=${CARGO_TARGET_DIR_NEW:-$NEW/target-ab}
build "$BASE" "$TB"
build "$NEW" "$TN"
for r in $(seq 1 "$REPS"); do
for cfg in base new; do
T=$TN; [ $cfg = base ] && T=$TB
for mode in proc grpc; do
EX=cp_replay; [ $mode = grpc ] && EX=cp_replay_grpc
"$T/release/examples/$EX" "$TOK" "$SESSION" --label "$cfg-$mode-$r" --out "$OUT/$cfg-$mode-$r.json" "$@" \
>"$OUT/$cfg-$mode-$r.txt" 2>/dev/null
echo "done $cfg-$mode-$r"
done
done
done