diff --git a/bench/api.sh b/bench/api.sh index bc7a41a..0be36ec 100644 --- a/bench/api.sh +++ b/bench/api.sh @@ -2,22 +2,28 @@ # Engine-only latency: one container lifecycle (create, start, wait, delete) # and one exec, straight over the Docker API with curl, no docker CLI. # SOCK=/run/dockerd-bench.sock bench/api.sh docker-engine -set -u +set -euo pipefail label=$1; S=${SOCK:?}; OUT=${OUT:-$(dirname "$0")/results}; RUNS=${RUNS:-30} -c() { curl -s --unix-socket "$S" "$@"; } +mkdir -p "$OUT" +c() { curl -fsS --unix-socket "$S" "$@"; } +id="" +trap '[[ -n "$id" ]] && c -X DELETE "http://x/containers/$id?force=true" >/dev/null || true' EXIT c -X POST -H 'Content-Type: application/json' -d '{"Image":"alpine","Cmd":["true"]}' http://x/containers/create >/dev/null cat > /tmp/api-run.sh </dev/null; c -X POST http://x/containers/\$id/wait >/dev/null; c -X DELETE http://x/containers/\$id >/dev/null +c -X POST http://x/containers/\$id/start >/dev/null && c -X POST http://x/containers/\$id/wait >/dev/null && c -X DELETE http://x/containers/\$id >/dev/null R id=$(c -X POST -H 'Content-Type: application/json' -d '{"Image":"alpine","Cmd":["sleep","600"]}' http://x/containers/create | jq -r .Id); c -X POST "http://x/containers/$id/start" >/dev/null cat > /tmp/api-exec.sh </dev/null R -hyperfine --warmup 3 --runs "$RUNS" --export-json "$OUT/$label.api-run.json" 'bash /tmp/api-run.sh' >/dev/null 2>&1 -hyperfine --ignore-failure --warmup 3 --runs "$RUNS" --export-json "$OUT/$label.api-exec.json" 'bash /tmp/api-exec.sh' >/dev/null 2>&1 -c -X DELETE "http://x/containers/$id?force=true" >/dev/null -printf '%-14s API run %4s ms (min %4s) API exec %4s ms (min %4s)\n' "$label" $(jq -r '.results[0] | "\(.median*1000|round) \(.min*1000|round)"' "$OUT/$label.api-run.json") $(jq -r '.results[0] | "\(.median*1000|round) \(.min*1000|round)"' "$OUT/$label.api-exec.json") +out=$(hyperfine --warmup 3 --runs "$RUNS" --export-json "$OUT/$label.api-run.json" 'bash /tmp/api-run.sh' 2>&1) || { printf '%s\n' "$out" >&2; exit 1; } +out=$(hyperfine --warmup 3 --runs "$RUNS" --export-json "$OUT/$label.api-exec.json" 'bash /tmp/api-exec.sh' 2>&1) || { printf '%s\n' "$out" >&2; exit 1; } +ms() { jq -r ".results[0] | (.summary.time_wall_clock // .) | .$1 * 1000 | round" "$OUT/$label.$2.json"; } +r_med=$(ms median api-run); r_min=$(ms min api-run); e_med=$(ms median api-exec); e_min=$(ms min api-exec) +printf '%-14s API run %4s ms (min %4s) API exec %4s ms (min %4s)\n' "$label" "$r_med" "$r_min" "$e_med" "$e_min" diff --git a/docs/fix-registry.md b/docs/fix-registry.md index d8562b9..f0bfcde 100644 --- a/docs/fix-registry.md +++ b/docs/fix-registry.md @@ -13,6 +13,12 @@ A log of every merged bug fix in Kiri, newest first, together with any later bug ## Fixes +### #779 Bench: fail the API benchmark on curl errors instead of timing failed runs (unreleased) +- Fixes: #669 `bench/api.sh` passes `--ignore-failure` to `hyperfine` on `api-exec`, masking curl failures and recording time-to-failure as valid timings +- Caused: none known +- Caused by: - +- Check: none + ### #545 Linux: a memory limit gets as much swap again, and `--memory-swap` is applied, as on Docker (unreleased) - Fixes: #523 Linux: containers with `--memory` get `memory.swap.max = 0` and `--memory-swap` is ignored; #690 - Caused: none known