Major Features: - Debug counter infrastructure for Refill Stage tracking - Free Pipeline counters (ss_local, ss_remote, tls_sll) - Diagnostic counters for early return analysis - Unified larson.sh benchmark runner with profiles - Phase 6-3 regression analysis documentation Bug Fixes: - Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB) - Fix profile variable naming consistency - Add .gitignore patterns for large files Performance: - Phase 6-3: 4.79 M ops/s (has OOM risk) - With SuperSlab: 3.13 M ops/s (+19% improvement) This is a clean repository without large log files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
96 lines
3.3 KiB
Bash
Executable File
96 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
|
||
# A/B sweep for Mid (2–32KiB): RING_CAP × PROBES × DRAIN_MAX × LOMAX (trigger fixed=2)
|
||
# - Rebuilds libhakmem.so per RING_CAP
|
||
# - Runs larson with the given params
|
||
# - Saves logs and summary/CSV under docs/benchmarks/<timestamp>_AB_RCAP_PROBE_DRAIN
|
||
|
||
RUNTIME=${RUNTIME:-2}
|
||
THREADS_CSV=${THREADS:-"1,4"}
|
||
RCAPS=${RCAPS:-"8,16"}
|
||
PROBES=${PROBES:-"2,3"}
|
||
DRAINS=${DRAINS:-"32,64"}
|
||
LOMAX=${LOMAX:-"256,512"}
|
||
TRIGGER=${TRIGGER:-2}
|
||
|
||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||
OUTDIR="$ROOT_DIR/docs/benchmarks/$(date +%Y%m%d_%H%M%S)_AB_RCAP_PROBE_DRAIN"
|
||
mkdir -p "$OUTDIR"
|
||
LARSON="$ROOT_DIR/mimalloc-bench/bench/larson/larson"
|
||
|
||
if [[ ! -x "$LARSON" ]]; then
|
||
echo "larson not found: $LARSON" >&2
|
||
exit 1
|
||
fi
|
||
|
||
echo "A/B (Mid 2–32KiB) RUNTIME=${RUNTIME}s THREADS=${THREADS_CSV}" | tee "$OUTDIR/summary.txt"
|
||
echo "RING_CAP={${RCAPS}} PROBES={${PROBES}} DRAIN_MAX={${DRAINS}} LOMAX={${LOMAX}} TRIGGER=${TRIGGER}" | tee -a "$OUTDIR/summary.txt"
|
||
echo "label,ring_cap,probes,drain_max,lomax,trigger,threads,throughput_ops_per_sec" > "$OUTDIR/summary.csv"
|
||
|
||
IFS=',' read -r -a TARR <<< "$THREADS_CSV"
|
||
IFS=',' read -r -a RARR <<< "$RCAPS"
|
||
IFS=',' read -r -a PARR <<< "$PROBES"
|
||
IFS=',' read -r -a DARR <<< "$DRAINS"
|
||
IFS=',' read -r -a LARR <<< "$LOMAX"
|
||
|
||
build_release() {
|
||
local cap="$1"
|
||
echo "[BUILD] make shared RING_CAP=${cap}"
|
||
( cd "$ROOT_DIR" && make -j4 clean >/dev/null && make -j4 shared RING_CAP="$cap" >/dev/null )
|
||
}
|
||
|
||
extract_tput() {
|
||
# Try to extract integer throughput from larson/hakmem outputs.
|
||
# Prefer lines like: "Throughput = 5998924 operations per second"
|
||
awk '
|
||
/Throughput/ && /operations per second/ {
|
||
for (i=1;i<=NF;i++) if ($i ~ /^[0-9]+$/) { print $i; exit }
|
||
}
|
||
' || true
|
||
}
|
||
|
||
for rc in "${RARR[@]}"; do
|
||
build_release "$rc"
|
||
LIB="$(readlink -f "$ROOT_DIR/libhakmem.so")"
|
||
for pr in "${PARR[@]}"; do
|
||
for dm in "${DARR[@]}"; do
|
||
for lm in "${LARR[@]}"; do
|
||
for t in "${TARR[@]}"; do
|
||
label="rc${rc}_pr${pr}_dm${dm}_lo${lm}_T${t}"
|
||
echo "== $label ==" | tee -a "$OUTDIR/summary.txt"
|
||
log="$OUTDIR/${label}.log"
|
||
# Run with Mid band (2–32KiB), burst pattern (10000×1)
|
||
if ! env HAKMEM_HDR_LIGHT=1 HAKMEM_POOL_TLS_RING=1 HAKMEM_SHARD_MIX=1 \
|
||
HAKMEM_TRYLOCK_PROBES="$pr" HAKMEM_RING_RETURN_DIV=3 \
|
||
HAKMEM_TC_ENABLE=1 HAKMEM_TC_DRAIN_MAX="$dm" HAKMEM_TC_DRAIN_TRIGGER="$TRIGGER" HAKMEM_TLS_LO_MAX="$lm" \
|
||
LD_PRELOAD="$LIB" "$LARSON" "$RUNTIME" 2048 32768 10000 1 12345 "$t" \
|
||
2>&1 | tee "$log" | tail -n 3 | tee -a "$OUTDIR/summary.txt" ; then
|
||
echo "[WARN] run failed: $label" | tee -a "$OUTDIR/summary.txt"
|
||
fi
|
||
# Extract throughput
|
||
tput="$(extract_tput < "$log")"
|
||
[[ -z "$tput" ]] && tput=0
|
||
echo "$label,$rc,$pr,$dm,$lm,$TRIGGER,$t,$tput" >> "$OUTDIR/summary.csv"
|
||
done
|
||
done
|
||
done
|
||
done
|
||
done
|
||
|
||
echo "Saved: $OUTDIR"
|
||
|
||
# Print top-5 by 4T if present, else 1T
|
||
if grep -q ',4,' "$OUTDIR/summary.csv"; then
|
||
echo "\nTop-5 (4T):"
|
||
sort -t, -k8,8nr "$OUTDIR/summary.csv" | awk -F, '$7==4' | head -n 5
|
||
fi
|
||
|
||
echo "\nTop-5 (1T):"
|
||
sort -t, -k8,8nr "$OUTDIR/summary.csv" | awk -F, '$7==1' | head -n 5
|
||
|
||
echo "\nBest 4T row (if present):"
|
||
best4=$(sort -t, -k8,8nr "$OUTDIR/summary.csv" | awk -F, '$7==4' | head -n 1 || true)
|
||
echo "$best4"
|
||
|