#!/usr/bin/env bash set -euo pipefail # Run VM-mixed (512KB–<2MB) bench across allocators and L25 A/B, save CSV. # Usage: benchmarks/scripts/run_vm_mixed_matrix.sh [cycles] [ws] [reps] ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)" cd "$ROOT_DIR" cycles=${1:-20000} ws=${2:-256} reps=${3:-5} outdir="bench_results/auto/vm_mixed_$(date +%Y%m%d_%H%M%S)" mkdir -p "$outdir" csv="$outdir/results.csv" echo "ts,scenario,allocator,env,cycles,ws,rep,throughput_ops_s" >"$csv" run_case() { local scenario="$1"; shift local alloc="$1"; shift local envstr="$1"; shift local bin="$1"; shift for ((i=1;i<=reps;i++)); do local ts=$(date +%H%M%S) local out out=$($envstr "$bin" "$cycles" "$ws" 4242 2>/dev/null || true) local tput=$(echo "$out" | awk '/Throughput =/{print $3; exit}') if [[ -n "${tput:-}" ]]; then echo "$ts,$scenario,$alloc,$(echo "$envstr" | sed 's/,/;/g'),$cycles,$ws,$i,$tput" >>"$csv" fi done } # Build benches if needed [[ -x ./bench_vm_mixed_system ]] || make -s bench_vm_mixed_system >/dev/null [[ -x ./bench_vm_mixed_hakmem ]] || make -s bench_vm_mixed_hakmem >/dev/null echo "[info] writing CSV to $csv" # system run_case "vm_mixed" "system" "env -i" ./bench_vm_mixed_system # HAKMEM L25 OFF/ON run_case "vm_mixed" "hakmem(l25=0)" "env -i HAKMEM_BIGCACHE_L25=0 HAKMEM_WRAP_TINY=1" ./bench_vm_mixed_hakmem run_case "vm_mixed" "hakmem(l25=1)" "env -i HAKMEM_BIGCACHE_L25=1 HAKMEM_WRAP_TINY=1" ./bench_vm_mixed_hakmem echo "[done] $csv"