Artifact 78f3c17238e556c2f42064949102b8305fd1d0a4ee6f782f9606b497828ef862:
- File
test/budget.sh
— part of check-in
[cbd57cce10]
at
2026-11-12 22:50:34
on branch trunk
— A store interrupted mid-update can be repaired, and symlinks are refused
An update now writes a journal before it changes anything and removes it only when the update, or the put-back after a failure, has finished. If the journal is still there, every store command refuses and names the fix. suit store repair restores each file to the version the store was leaving. Tested with a double failure and by killing suit in the middle of a slowed 100-file update: repair restored every byte.
libfossil's checkout writes symlinks as regular files, so suit refuses them outright: store open and update refuse a version that holds one, and commit refuses to check one in. Each names the path.
The fuzz corpus libFuzzer grew is minimized and checked in (300 inputs for the config parser, 83 for the stamp reader), so every push replays it under the sanitizers and Fil-C.
The budget test takes the best of three runs. It measured 0.43 to 0.59 ms quiet and 0.72 to 0.88 ms at a load average of 130 to 170.
243 unit checks, 220 shell cases, 146 store cases. 100% coverage in all ten source files. (user: dmestas, size: 2195) [annotate] [blame] [check-ins using]
#!/bin/sh # The speed test: suit-run, the program a timer starts every minute, may cost at # most 1 ms and 1 MiB more than an empty program built the same way (build/empty, # next to the binary). The bench runs once on a quiet machine and again under # CPU load from loadgen, whose workers carry their own deadline. # # Each of the two measurements is taken three times, all three are printed, and # it passes if the best of the three is within budget. A machine kept busy by # other work (a load average above about 100) adds noise to a 1 ms difference # that the test cannot tell from suit's own cost; the budget is not loosened. # SUIT names the binary (default build/suit); suit-run is beside it. SUIT=${SUIT:-build/suit} case $SUIT in /*) ;; *) SUIT=$PWD/$SUIT ;; esac LOADGEN=${LOADGEN:-$HOME/.claude/bin/loadgen} RUNS=3 ROUNDS=600 LOAD_WORKERS=8 # Three loaded runs of about 20 seconds each, with room to spare. LOAD_SECONDS=100 mkdir -p build/tmp T=$(mktemp -d "$PWD/build/tmp/budget.XXXXXX") || exit 1 trap 'rm -rf "$T"' EXIT INT TERM mkdir -p "$T/files" i=0 while [ $i -lt 100 ]; do echo "file $i" > "$T/files/f$i" i=$((i + 1)) done export SUIT_HOME="$T/home" "$SUIT" stamp "$T"/files/f* || exit 1 "$SUIT" run || { echo "budget: scratch stamp does not read back as unchanged"; exit 1; } # best_of LABEL: run the bench RUNS times, print every run, succeed if one passed. best_of() { ok=1 n=1 while [ $n -le $RUNS ]; do echo "-- $1, run $n of $RUNS" if "$SUIT" bench -n "$ROUNDS"; then ok=0; fi n=$((n + 1)) done return $ok } failed=0 echo "== quiet (load average: $(uptime | sed 's/.*load averages*: //'))" best_of quiet || { echo "budget: no quiet run was within budget"; failed=1; } [ -x "$LOADGEN" ] || { echo "budget: $LOADGEN not found"; exit 1; } echo "== under load: loadgen $LOAD_SECONDS $LOAD_WORKERS" "$LOADGEN" "$LOAD_SECONDS" "$LOAD_WORKERS" & load=$! sleep 2 echo "load average: $(uptime | sed 's/.*load averages*: //')" best_of loaded || { echo "budget: no loaded run was within budget"; failed=1; } wait "$load" if [ "$failed" -eq 0 ]; then echo "budget: pass"; else echo "budget: FAIL"; fi [ "$failed" -eq 0 ]