Phase 83-1 + Allocator Comparison: Switch dispatch fixed (NO-GO +0.32%), PROFILE correction, SCORECARD update
Key changes: - Phase 83-1: Switch dispatch fixed mode (tiny_inline_slots_switch_dispatch_fixed_box) - NO-GO (marginal +0.32%, branch reduction negligible) Reason: lazy-init pattern already optimal, Phase 78-1 pattern shows diminishing returns - Allocator comparison baseline update (10-run SSOT, WS=400, ITERS=20M): tcmalloc: 115.26M (92.33% of mimalloc) jemalloc: 97.39M (77.96% of mimalloc) system: 85.20M (68.24% of mimalloc) mimalloc: 124.82M (baseline) - hakmem PROFILE correction: scripts/run_mixed_10_cleanenv.sh + run_allocator_quick_matrix.sh PROFILE explicitly set to MIXED_TINYV3_C7_SAFE for hakmem measurements Result: baseline stabilized to 55.53M (44.46% of mimalloc) Previous unstable measurement (35.57M) was due to profile leak - Documentation: * PERFORMANCE_TARGETS_SCORECARD.md: Reference allocators + M1/M2 milestone status * PHASE83_1_SWITCH_DISPATCH_FIXED_RESULTS.md: Phase 83-1 analysis (NO-GO) * ALLOCATOR_COMPARISON_QUICK_RUNBOOK.md: Quick comparison procedure * ALLOCATOR_COMPARISON_SSOT.md: Detailed SSOT methodology - M2 milestone status: 44.46% (target 55%, gap -10.54pp) - structural improvements needed 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
112
scripts/run_allocator_quick_matrix.sh
Executable file
112
scripts/run_allocator_quick_matrix.sh
Executable file
@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Quick allocator matrix for the Random Mixed benchmark family (no long soaks).
|
||||
#
|
||||
# Runs N times and prints mean/median/CV for:
|
||||
# - hakmem (Standard)
|
||||
# - hakmem (FAST PGO) if present
|
||||
# - system
|
||||
# - mimalloc (direct-link) if present
|
||||
# - jemalloc (LD_PRELOAD) if JEMALLOC_SO is set
|
||||
# - tcmalloc (LD_PRELOAD) if TCMALLOC_SO is set
|
||||
#
|
||||
# Usage:
|
||||
# make bench_random_mixed_system bench_random_mixed_hakmem bench_random_mixed_mi
|
||||
# make pgo-fast-full # optional (builds bench_random_mixed_hakmem_minimal_pgo)
|
||||
# export JEMALLOC_SO=/path/to/libjemalloc.so.2
|
||||
# export TCMALLOC_SO=/path/to/libtcmalloc.so
|
||||
# scripts/run_allocator_quick_matrix.sh
|
||||
#
|
||||
# Tunables:
|
||||
# ITERS=20000000 WS=400 SEED=1 RUNS=10
|
||||
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "${root_dir}"
|
||||
|
||||
profile="${HAKMEM_PROFILE:-MIXED_TINYV3_C7_SAFE}"
|
||||
iters="${ITERS:-20000000}"
|
||||
ws="${WS:-400}"
|
||||
seed="${SEED:-1}"
|
||||
runs="${RUNS:-10}"
|
||||
|
||||
require_bin() {
|
||||
local b="$1"
|
||||
if [[ ! -x "${b}" ]]; then
|
||||
echo "[matrix] Missing binary: ${b}" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
extract_throughput() {
|
||||
# Reads "Throughput = 54845687 ops/s ..." and prints the integer.
|
||||
rg -o "Throughput = +[0-9]+ ops/s" | rg -o "[0-9]+"
|
||||
}
|
||||
|
||||
stats_py='
|
||||
import math,statistics,sys
|
||||
xs=[int(x) for x in sys.stdin.read().strip().split() if x.strip()]
|
||||
if not xs:
|
||||
sys.exit(1)
|
||||
xs_sorted=sorted(xs)
|
||||
mean=sum(xs)/len(xs)
|
||||
median=statistics.median(xs_sorted)
|
||||
stdev=statistics.pstdev(xs) if len(xs)>1 else 0.0
|
||||
cv=(stdev/mean*100.0) if mean>0 else 0.0
|
||||
print(f"runs={len(xs)} mean={mean/1e6:.2f}M median={median/1e6:.2f}M cv={cv:.2f}% min={min(xs)/1e6:.2f}M max={max(xs)/1e6:.2f}M")
|
||||
'
|
||||
|
||||
run_n() {
|
||||
local label="$1"; shift
|
||||
local cmd=( "$@" )
|
||||
echo ""
|
||||
echo "== ${label} =="
|
||||
for i in $(seq 1 "${runs}"); do
|
||||
"${cmd[@]}" 2>&1 | extract_throughput || true
|
||||
done | python3 -c "${stats_py}"
|
||||
}
|
||||
|
||||
require_bin ./bench_random_mixed_system
|
||||
require_bin ./bench_random_mixed_hakmem
|
||||
|
||||
if [[ -x ./scripts/run_mixed_10_cleanenv.sh ]]; then
|
||||
# IMPORTANT: hakmem must run under the same profile+cleanenv SSOT as Phase runs.
|
||||
# Otherwise it will silently use a different route configuration and appear "much slower".
|
||||
run_n "hakmem (Standard, SSOT profile=${profile})" \
|
||||
env HAKMEM_PROFILE="${profile}" BENCH_BIN=./bench_random_mixed_hakmem ITERS="${iters}" WS="${ws}" RUNS=1 \
|
||||
./scripts/run_mixed_10_cleanenv.sh
|
||||
else
|
||||
run_n "hakmem (Standard, raw)" ./bench_random_mixed_hakmem "${iters}" "${ws}" "${seed}"
|
||||
fi
|
||||
|
||||
if [[ -x ./bench_random_mixed_hakmem_minimal_pgo ]]; then
|
||||
if [[ -x ./scripts/run_mixed_10_cleanenv.sh ]]; then
|
||||
run_n "hakmem (FAST PGO, SSOT profile=${profile})" \
|
||||
env HAKMEM_PROFILE="${profile}" BENCH_BIN=./bench_random_mixed_hakmem_minimal_pgo ITERS="${iters}" WS="${ws}" RUNS=1 \
|
||||
./scripts/run_mixed_10_cleanenv.sh
|
||||
else
|
||||
run_n "hakmem (FAST PGO, raw)" ./bench_random_mixed_hakmem_minimal_pgo "${iters}" "${ws}" "${seed}"
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
echo "== hakmem (FAST PGO) =="
|
||||
echo "skipped (missing ./bench_random_mixed_hakmem_minimal_pgo; build via: make pgo-fast-full)"
|
||||
fi
|
||||
|
||||
run_n "system" ./bench_random_mixed_system "${iters}" "${ws}" "${seed}"
|
||||
|
||||
if [[ -x ./bench_random_mixed_mi ]]; then
|
||||
run_n "mimalloc (direct link)" ./bench_random_mixed_mi "${iters}" "${ws}" "${seed}"
|
||||
else
|
||||
echo ""
|
||||
echo "== mimalloc (direct link) =="
|
||||
echo "skipped (missing ./bench_random_mixed_mi; build via: make bench_random_mixed_mi)"
|
||||
fi
|
||||
|
||||
if [[ -n "${JEMALLOC_SO:-}" && -e "${JEMALLOC_SO}" ]]; then
|
||||
run_n "jemalloc (LD_PRELOAD)" env LD_PRELOAD="$(realpath "${JEMALLOC_SO}")" ./bench_random_mixed_system "${iters}" "${ws}" "${seed}"
|
||||
fi
|
||||
|
||||
if [[ -n "${TCMALLOC_SO:-}" && -e "${TCMALLOC_SO}" ]]; then
|
||||
run_n "tcmalloc (LD_PRELOAD)" env LD_PRELOAD="$(realpath "${TCMALLOC_SO}")" ./bench_random_mixed_system "${iters}" "${ws}" "${seed}"
|
||||
fi
|
||||
Reference in New Issue
Block a user