Onset: version control where nobody waits and nothing gets lost. The on command, its core and onset-server.
| 6 | # VCS_TOKEN=... tests/bench-live.sh [path/to/vcs] [agents] |
| 7 | # git uses this machine's credentials for the remote. |
| 8 | set -uo pipefail |
| 9 |
| 10 | VCS=${1:-$(cd "$(dirname "$0")/.." && pwd)/target/release/vcs} |
| 11 | N=${2:-16} |
| 12 | WORK=$(mktemp -d) |
| 13 | export VCS_SAVER=0 VCS_HOME=$WORK/home VCS_NAME=Bench VCS_EMAIL=bench@example.com |
| 14 | export GIT_AUTHOR_NAME=Bench GIT_AUTHOR_EMAIL=bench@example.com GIT_COMMITTER_NAME=Bench GIT_COMMITTER_EMAIL=bench@example.com |
| 15 | BRANCH="bench-$(date +%s)" |
| 16 | trap 'rm -rf "$WORK"' EXIT |
| 17 | cd "$WORK" |
| 18 | g() { git -c commit.gpgsign=false "$@"; } |
| 19 | now() { python3 -c 'import time; print(time.time())'; } |
| 20 | since() { python3 -c "import time; print(f'{time.time() - $1:.2f}')"; } |
| 21 | med() { printf '%s\n' "$@" | sort -n | sed -n "$(( ($# + 1) / 2 ))p"; } |
| 22 | row() { printf '%-52s %12s %12s\n' "$1" "$2" "$3"; } |
| 23 |
| 24 | "$VCS" login "${VCS_PROJECT%%/*}" --token "$VCS_TOKEN" >/dev/null |
| 25 | echo "live: git $GIT_REMOTE (branch $BRANCH) vs vcs $VCS_PROJECT" |
| 26 | echo |
| 27 | row "" "git" "vcs" |
| 28 |
| 29 | t=$(now); g clone -q "$GIT_REMOTE" g0; tg=$(since "$t") |
| 30 | t=$(now); "$VCS" get "$VCS_PROJECT" v0 >/dev/null; tv=$(since "$t") |
| 31 | row "first copy (s)" "$tg" "$tv" |
| 32 | (cd g0 && g checkout -q -b "$BRANCH" && g push -q origin "$BRANCH") |
| 33 |
| 34 | gl=() |
| 35 | vl=() |
| 36 | for i in $(seq 1 5); do |
| 37 | printf '%s %s\n' "$BRANCH" "$i" >> g0/$BRANCH.txt |
| 38 | t=$(now); (cd g0 && g add -A && g commit -qm "Bench $i" && g push -q origin "$BRANCH"); gl+=("$(since "$t")") |
| 39 | printf '%s %s\n' "$BRANCH" "$i" >> v0/$BRANCH.txt |
| 40 | t=$(now); "$VCS" -C v0 land -m "Bench $i" >/dev/null; vl+=("$(since "$t")") |
| 41 | done |
| 42 | row "one change: commit + push vs land, median (s)" "$(med "${gl[@]}")" "$(med "${vl[@]}")" |
| 43 |
| 44 | for i in $(seq 1 "$N"); do |
| 45 | g clone -q --branch "$BRANCH" "$GIT_REMOTE" "g$i" && printf '%s %s\n' "$BRANCH" "$i" > "g$i/$BRANCH-$i.txt" && (cd "g$i" && g add -A && g commit -qm "Agent $i") |
| 46 | "$VCS" get "$VCS_PROJECT" "v$i" >/dev/null && printf '%s %s\n' "$BRANCH" "$i" > "v$i/$BRANCH-$i.txt" |
| 47 | done |
| 48 | pids=() |
| 49 | t=$(now) |
| 50 | for i in $(seq 1 "$N"); do |
| 51 | (cd "g$i"; tries=0; until g push -q origin "$BRANCH" 2>/dev/null; do tries=$((tries + 1)); [ "$tries" -gt 200 ] && break; g pull -q --rebase origin "$BRANCH" 2>/dev/null; done; echo "$tries" > "../tries$i") & |
| 52 | pids+=($!) |
| 53 | done |
| 54 | wait "${pids[@]}" |
| 55 | tg=$(since "$t") |
| 56 | refused=$(cat tries* | python3 -c "import sys; print(sum(int(l) for l in sys.stdin))") |
| 57 | pids=() |
| 58 | t=$(now) |
| 59 | for i in $(seq 1 "$N"); do ("$VCS" -C "v$i" land -m "Agent $i" >/dev/null 2>&1; echo $? > "vcode$i") & pids+=($!); done |
| 60 | wait "${pids[@]}" |
| 61 | tv=$(since "$t") |
| 62 | landed=$(grep -l '^0$' vcode* | wc -l | tr -d ' ') |
| 63 | row "$N agents land one change each on one branch (s)" "$tg" "$tv" |
| 64 | row " refused pushes / changes that didn't land" "$refused" "$((N - landed))" |
| 65 | echo |
| 66 | echo "git scratch branch left on the remote: $BRANCH" |
| 67 |