Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/holger

scripts/bench-sandbox.sh

#!/usr/bin/env bash
# The scan-sandbox bench row (`holger.sandbox_scan`), with what it needs around it.
#
#   scripts/bench-sandbox.sh [cargo xtask bench --local flags, e.g. --update-baseline]
#
# The same setup as scripts/scan-sandbox-live.sh: on the host, a podman API
# service of our own (its own PID) on a socket under the target directory and
# clamd in its sandbox; then `cargo xtask bench --local --only holger.sandbox_scan`
# in the toolchain container with the repository's parent and the target
# directory mounted at their OWN paths, so a job directory is the same path for
# the bench and for the engine. Every container started here is stopped here.
# Mint the worker image first if it is missing: `cargo xtask scan-worker image`.
set -euo pipefail
REPO=$(cd "$(dirname "$0")/.." && pwd)
PARENT=$(dirname "$REPO")
TARGET="${CARGO_TARGET_DIR:-$REPO/target}"
IMAGE="${HOLGER_SCAN_WORKER_IMAGE:-localhost/holger-scan-worker:$(sed -n 's/^version = "\(.*\)"/\1/p' "$REPO/server/cli/Cargo.toml" | head -1)}"
TOOLCHAIN="${TOOLCHAIN_IMAGE:-localhost/nordisk-cargo-toolchain:live}"
REGISTRY="${CARGO_REGISTRY_DIR:-$HOME/.cargo/registry}"
W="$TARGET/bench-sandbox"
SOCK="$W/podman.sock"
CLAMD="holger-bench-clamd-$$"
mkdir -p "$W/jobs" "$W/tmp"
podman image exists "$IMAGE" || { echo "the worker image $IMAGE is not minted: cargo xtask scan-worker image" >&2; exit 1; }
rm -f "$SOCK"
podman system service --time=0 "unix://$SOCK" & SVC=$!
cleanup() { kill "$SVC" 2>/dev/null || true; wait "$SVC" 2>/dev/null || true; "$REPO/scripts/clamd-sandbox.sh" stop "$CLAMD"; rm -f "$SOCK"; }
trap cleanup EXIT
for _ in $(seq 1 100); do [ -S "$SOCK" ] && break; sleep 0.1; done
"$REPO/scripts/clamd-sandbox.sh" start "$CLAMD" "$W/clamd"
podman run --rm -v "$PARENT:$PARENT" -v "$TARGET:$TARGET" -v "$REGISTRY:/usr/local/cargo/registry" \
  ${BENCH_PODMAN_ARGS:-} \
  -e CARGO_TARGET_DIR="$TARGET" -e CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-24}" \
  -e NORNIR_MACHINE="${NORNIR_MACHINE:-$(hostname)}" -e HOLGER_BENCH_SCALE="${HOLGER_BENCH_SCALE:-quick}" \
  -e HOLGER_BENCH_FIXTURES="${HOLGER_BENCH_FIXTURES:-$TARGET/bench-fixtures}" \
  -e HOLGER_BENCH_SANDBOX_URL="unix://$SOCK" -e HOLGER_BENCH_SANDBOX_WORKDIR="$W/jobs" \
  -e HOLGER_SCAN_WORKER_IMAGE="$IMAGE" -e HOLGER_BENCH_CLAMD="$W/clamd/clamd.sock" \
  -e TMPDIR="$W/tmp" \
  -w "$REPO" "$TOOLCHAIN" bash -c "cargo xtask bench --local --only holger.sandbox_scan $*"