Files
hakmem/scripts/phase75_3_matrix_test.sh

141 lines
3.9 KiB
Bash
Raw Normal View History

Phase 75-3: C5+C6 Interaction Matrix Test (4-Point A/B) - STRONG GO (+5.41%) Comprehensive interaction testing with single binary, ENV-only configuration: 4-Point Matrix Results (Mixed SSOT, WS=400): - Point A (C5=0, C6=0): 42.36 M ops/s [Baseline] - Point B (C5=1, C6=0): 43.54 M ops/s (+2.79% vs A) - Point C (C5=0, C6=1): 44.25 M ops/s (+4.46% vs A) - Point D (C5=1, C6=1): 44.65 M ops/s (+5.41% vs A) **[COMBINED TARGET]** Additivity Analysis: - Expected additive: 45.43 M ops/s (B+C-A) - Actual: 44.65 M ops/s (D) - Sub-additivity: 1.72% (near-perfect, minimal negative interaction) Perf Stat Validation (Point D vs A): - Instructions: -6.1% (function call elimination confirmed) - Branches: -6.1% (matches instructions reduction) - Cache-misses: -31.5% (improved locality, NO code explosion) - Throughput: +5.41% (net positive) Decision: ✅ STRONG GO (exceeds +3.0% GO threshold) - D vs A: +5.41% >> +3.0% - Sub-additivity: 1.72% << 20% acceptable - Phase 73 hypothesis validated: -6.1% instructions/branches → +5.41% throughput Promotion to Defaults: - core/bench_profile.h: C5+C6 added to bench_apply_mixed_tinyv3_c7_common() - scripts/run_mixed_10_cleanenv.sh: C5+C6 ENV defaults added - C5+C6 inline slots now PRESET DEFAULT for MIXED_TINYV3_C7_SAFE New Baseline: 44.65 M ops/s (36.75% of mimalloc, +5.41% from Phase 75-0) M2 Target: 55% of mimalloc ≈ 66.8 M ops/s (remaining gap: 22.15 M ops/s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-18 08:53:01 +09:00
#!/bin/bash
# Phase 75-3: C5+C6 Interaction Test (4-point matrix A/B)
echo "==========================================="
echo "Phase 75-3: C5+C6 Interaction Matrix Test"
echo "==========================================="
echo ""
# Single build (both C5 and C6 code present, enabled via ENV)
echo "Building single binary (C5 + C6 code included)..."
HAKMEM_TINY_C5_INLINE_SLOTS=1 HAKMEM_TINY_C6_INLINE_SLOTS=1 \
make clean && make -j bench_random_mixed_hakmem > /tmp/phase75_3_build.log 2>&1
if [ $? -ne 0 ]; then
echo "Build FAILED"
exit 1
fi
echo "Build: OK"
echo ""
# 4-point matrix test
declare -A results
for point in A B C D; do
case $point in
A) c5=0; c6=0; desc="Baseline (C5=0, C6=0)" ;;
B) c5=1; c6=0; desc="C5 Solo (C5=1, C6=0)" ;;
C) c5=0; c6=1; desc="C6 Solo (C5=0, C6=1)" ;;
D) c5=1; c6=1; desc="C5+C6 (C5=1, C6=1)" ;;
esac
echo "==========================================="
echo "Point $point: $desc"
echo "==========================================="
> /tmp/phase75_3_point_${point}.log
for i in {1..10}; do
HAKMEM_WARM_POOL_SIZE=16 \
HAKMEM_TINY_C5_INLINE_SLOTS=$c5 \
HAKMEM_TINY_C6_INLINE_SLOTS=$c6 \
./bench_random_mixed_hakmem 20000000 400 1 2>&1 | tee -a /tmp/phase75_3_point_${point}.log
done
# Extract average for this point
avg=$(grep "Throughput" /tmp/phase75_3_point_${point}.log | \
awk '{print $3}' | sed 's/ops\/s//' | \
awk '{s+=$1; n++} END {if(n>0) printf "%.2f", s/n/1000000}')
results[$point]=$avg
echo "Point $point average: $avg M ops/s"
echo ""
done
# Analysis
echo "==========================================="
echo "ANALYSIS: 4-Point Matrix Results"
echo "==========================================="
echo ""
A=${results[A]}
B=${results[B]}
C=${results[C]}
D=${results[D]}
echo "A (baseline, C5=0, C6=0): $A M ops/s"
echo "B (C5=1, C6=0): $B M ops/s"
echo "C (C5=0, C6=1): $C M ops/s"
echo "D (C5=1, C6=1): $D M ops/s"
echo ""
# Individual deltas
B_vs_A=$(awk "BEGIN {printf \"%.2f\", (($B - $A) / $A) * 100}")
C_vs_A=$(awk "BEGIN {printf \"%.2f\", (($C - $A) / $A) * 100}")
D_vs_A=$(awk "BEGIN {printf \"%.2f\", (($D - $A) / $A) * 100}")
echo "Individual deltas vs A:"
echo " B vs A: +${B_vs_A}%"
echo " C vs A: +${C_vs_A}%"
echo " D vs A: +${D_vs_A}% (MAIN TARGET)"
echo ""
# Expected additive vs actual
expected=$(awk "BEGIN {printf \"%.2f\", $B + $C - $A}")
actual=$D
additivity=$(awk "BEGIN {printf \"%.2f\", (($expected - $actual) / $expected) * 100}")
echo "Additivity analysis:"
echo " Expected (B+C-A): $expected M ops/s"
echo " Actual (D): $actual M ops/s"
echo " Sub-additivity: ${additivity}% (diminishing returns)"
echo ""
# Final decision
echo "==========================================="
echo "DECISION GATE (D vs A)"
echo "==========================================="
echo ""
if (( $(echo "$D_vs_A >= 3.0" | bc -l) )); then
decision="GO (昇格)"
action="Promote C5+C6 to core/bench_profile.h preset default"
elif (( $(echo "$D_vs_A >= 1.0" | bc -l) )); then
decision="NEUTRAL (freeze維持)"
action="Keep C5+C6 default OFF, evaluate in Phase 76"
else
decision="NO-GO (C5撤退)"
action="Revert C5 implementation, keep C6 only"
fi
echo "Result: $decision"
echo "D vs A: +${D_vs_A}%"
echo "Action: $action"
echo ""
# Save decision to artifact
cat > /tmp/phase75_3_decision.txt <<DECISION
Phase 75-3 Decision Artifact
Point A (baseline): $A M ops/s
Point B (C5 solo): $B M ops/s
Point C (C6 solo): $C M ops/s
Point D (C5+C6): $D M ops/s
D vs A: +${D_vs_A}%
Decision: $decision
Expected additive: $expected M ops/s
Actual D: $actual M ops/s
Sub-additivity: ${additivity}%
DECISION
echo "Decision saved to: /tmp/phase75_3_decision.txt"
echo ""
echo "Logs:"
echo " - Build: /tmp/phase75_3_build.log"
for point in A B C D; do
echo " - Point $point: /tmp/phase75_3_point_${point}.log"
done
echo "==========================================="