57 lines
1.8 KiB
Bash
57 lines
1.8 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
# perf-stat triad (HAKMEM/System/mimalloc) for bench_tiny_hot at a single size/batch/cycles
|
||
|
|
# Collects cycles/instructions/branches/branch-misses/L1-dcache-load-misses (CSV via perf -x ,)
|
||
|
|
# Usage: scripts/run_perf_hot_triad.sh [size] [batch] [cycles] [reps]
|
||
|
|
# size : bytes (default 32)
|
||
|
|
# batch : batch size (default 100)
|
||
|
|
# cycles: loop cycles per op (default 50000)
|
||
|
|
# reps : perf repetitions (default 3)
|
||
|
|
|
||
|
|
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
|
||
|
|
cd "$ROOT_DIR"
|
||
|
|
|
||
|
|
size=${1:-32}
|
||
|
|
batch=${2:-100}
|
||
|
|
cycles=${3:-50000}
|
||
|
|
reps=${4:-3}
|
||
|
|
|
||
|
|
echo "[build] benches (fast + mi)"
|
||
|
|
make -s bench_fast bench_tiny_hot_mi >/dev/null
|
||
|
|
|
||
|
|
# Ensure LD_LIBRARY_PATH is defined (set -u safety)
|
||
|
|
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}"
|
||
|
|
MI_LIBDIR="$ROOT_DIR/mimalloc-bench/extern/mi/out/release"
|
||
|
|
|
||
|
|
TS=$(date +%Y%m%d_%H%M%S)
|
||
|
|
OUTDIR="bench_results/perf_hot_triad_${TS}"
|
||
|
|
mkdir -p "$OUTDIR"
|
||
|
|
|
||
|
|
echo "[info] size=$size batch=$batch cycles=$cycles reps=$reps"
|
||
|
|
echo "[info] results → $OUTDIR"
|
||
|
|
|
||
|
|
run_perf() {
|
||
|
|
local alloc="$1"; shift
|
||
|
|
local bin="$1"; shift
|
||
|
|
local tag="$alloc"_s${size}_b${batch}_c${cycles}
|
||
|
|
local log="$OUTDIR/${tag}.perf.csv"
|
||
|
|
echo "[perf] $tag"
|
||
|
|
if [[ "$alloc" == "mimalloc" ]]; then
|
||
|
|
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$MI_LIBDIR" \
|
||
|
|
perf stat -x , -r "$reps" -e cycles,instructions,branches,branch-misses,L1-dcache-load-misses \
|
||
|
|
"$bin" "$size" "$batch" "$cycles" 1>/dev/null 2>"$log" || true
|
||
|
|
else
|
||
|
|
perf stat -x , -r "$reps" -e cycles,instructions,branches,branch-misses,L1-dcache-load-misses \
|
||
|
|
"$bin" "$size" "$batch" "$cycles" 1>/dev/null 2>"$log" || true
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
run_perf hakmem ./bench_tiny_hot_hakmem
|
||
|
|
run_perf system ./bench_tiny_hot_system
|
||
|
|
run_perf mimalloc ./bench_tiny_hot_mi
|
||
|
|
|
||
|
|
echo "[done] perf CSVs under: $OUTDIR"
|
||
|
|
ls -1 "$OUTDIR" | sed -n '1,20p'
|
||
|
|
|