Debug Counters Implementation - Clean History
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>
This commit is contained in:
122
benchmarks/scripts/mid/compare_mid_mt_allocators.sh
Executable file
122
benchmarks/scripts/mid/compare_mid_mt_allocators.sh
Executable file
@ -0,0 +1,122 @@
|
||||
#!/bin/bash
|
||||
# Compare Mid Range MT performance across different allocators
|
||||
#
|
||||
# Runs bench_mid_large_mt with:
|
||||
# - System allocator (glibc)
|
||||
# - mimalloc
|
||||
# - HAKX (our implementation)
|
||||
#
|
||||
# Usage: ./compare_mid_mt_allocators.sh [threads] [cycles] [ws] [seed] [runs]
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
# Default parameters
|
||||
THREADS=${1:-4}
|
||||
CYCLES=${2:-60000}
|
||||
WORKING_SET=${3:-256}
|
||||
SEED=${4:-1}
|
||||
RUNS=${5:-3}
|
||||
|
||||
# CPU affinity
|
||||
TASKSET="taskset -c 0-3"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Mid Range MT Allocator Comparison"
|
||||
echo "=========================================="
|
||||
echo "Configuration:"
|
||||
echo " Threads: $THREADS"
|
||||
echo " Cycles: $CYCLES"
|
||||
echo " Working Set: $WORKING_SET"
|
||||
echo " Seed: $SEED"
|
||||
echo " Runs/each: $RUNS"
|
||||
echo ""
|
||||
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# Build all variants if needed
|
||||
for variant in system mi hakx; do
|
||||
TARGET="bench_mid_large_mt_${variant}"
|
||||
if [ ! -f "./$TARGET" ]; then
|
||||
echo "Building $TARGET..."
|
||||
make "$TARGET"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
|
||||
# Function to run benchmark and extract median throughput
|
||||
run_bench() {
|
||||
local variant=$1
|
||||
local results=()
|
||||
|
||||
echo ""
|
||||
echo "Testing: $variant"
|
||||
echo "----------------------------------------"
|
||||
|
||||
for i in $(seq 1 $RUNS); do
|
||||
local output=$($TASKSET ./bench_mid_large_mt_${variant} $THREADS $CYCLES $WORKING_SET $SEED 2>&1)
|
||||
local mops=$(echo "$output" | grep "Throughput:" | awk '{print $2}')
|
||||
results+=($mops)
|
||||
printf " Run %d: %s M ops/sec\n" $i "$mops"
|
||||
done
|
||||
|
||||
# Calculate median - simpler approach using awk
|
||||
local median=$(printf "%s\n" "${results[@]}" | sort -n | awk '{
|
||||
a[NR] = $1
|
||||
}
|
||||
END {
|
||||
if (NR % 2 == 1) {
|
||||
print a[int(NR/2) + 1]
|
||||
} else {
|
||||
median = (a[NR/2] + a[NR/2 + 1]) / 2
|
||||
printf "%.2f", median
|
||||
}
|
||||
}')
|
||||
|
||||
echo " Median: $median M ops/sec"
|
||||
echo "$median"
|
||||
}
|
||||
|
||||
# Run benchmarks
|
||||
echo "Running benchmarks..."
|
||||
|
||||
SYSTEM_RESULT=$(run_bench "system")
|
||||
MI_RESULT=$(run_bench "mi")
|
||||
HAKX_RESULT=$(run_bench "hakx")
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Summary"
|
||||
echo "=========================================="
|
||||
printf "%-20s %10s %15s\n" "Allocator" "Throughput" "vs System"
|
||||
echo "----------------------------------------"
|
||||
printf "%-20s %10.2f M %15s\n" "System (glibc)" "$SYSTEM_RESULT" "1.00x"
|
||||
|
||||
MI_RATIO=$(echo "scale=2; $MI_RESULT / $SYSTEM_RESULT" | bc)
|
||||
printf "%-20s %10.2f M %15s\n" "mimalloc" "$MI_RESULT" "${MI_RATIO}x"
|
||||
|
||||
HAKX_RATIO=$(echo "scale=2; $HAKX_RESULT / $SYSTEM_RESULT" | bc)
|
||||
printf "%-20s %10.2f M %15s\n" "HAKX (Mid MT)" "$HAKX_RESULT" "${HAKX_RATIO}x"
|
||||
|
||||
echo ""
|
||||
echo "HAKX vs mimalloc:"
|
||||
HAKX_VS_MI=$(echo "scale=2; $HAKX_RESULT / $MI_RESULT * 100" | bc)
|
||||
printf " %.1f%% of mimalloc performance\n" "$HAKX_VS_MI"
|
||||
|
||||
# Winner
|
||||
echo ""
|
||||
if (( $(echo "$HAKX_RESULT > $MI_RESULT" | bc -l) )); then
|
||||
echo "🏆 HAKX is FASTER than mimalloc!"
|
||||
elif (( $(echo "$HAKX_RESULT > $SYSTEM_RESULT * 1.5" | bc -l) )); then
|
||||
echo "✅ HAKX significantly faster than system allocator (>1.5x)"
|
||||
else
|
||||
echo "⚠️ HAKX needs optimization"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Comparison completed!"
|
||||
Reference in New Issue
Block a user