Files
hakmem/scripts/box/pgo_tiny_profile_box.sh
Moe Charm (CI) 84f5034e45 Phase 68: PGO training set diversification (seed/WS expansion)
Changes:
- scripts/box/pgo_fast_profile_config.sh: Expanded WS patterns (3→5) and seeds (1→3)
  for reduced overfitting and better production workload representativeness
- PERFORMANCE_TARGETS_SCORECARD.md: Phase 68 baseline promoted (61.614M = 50.93%)
- CURRENT_TASK.md: Phase 68 marked complete, Phase 67a (layout tax forensics) set Active

Results:
- 10-run verification: +1.19% vs Phase 66 baseline (GO, >+1.0% threshold)
- M1 milestone: 50.93% of mimalloc (target 50%, exceeded by +0.93pp)
- Stability: 10-run mean/median with <2.1% CV

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-17 21:08:17 +09:00

104 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# Box: PGO Profile Collection (Tiny Front)
# Contract: Execute representative Tiny workloads for PGO
# Usage: ./scripts/box/pgo_tiny_profile_box.sh
#
# Input: Built binaries with -fprofile-generate -flto
# Output: .gcda profile data files
# Guarantees: Deterministic execution, error detection, summary report
set -e # Fail fast on errors
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PGO_CONFIG_BASENAME="${PGO_CONFIG:-pgo_tiny_profile_config.sh}"
source "${SCRIPT_DIR}/${PGO_CONFIG_BASENAME}"
echo "========================================="
echo "Box: PGO Profile Collection (Tiny Front)"
echo "========================================="
echo "Date: $(date)"
echo "Workloads: $PGO_WORKLOAD_COUNT"
echo "Binaries: $PGO_BINARY_COUNT"
echo "Config: $PGO_CONFIG_BASENAME"
echo ""
# Validate binaries exist and are executable
echo "[PGO_BOX] Validating binaries..."
for bin in "${PGO_BINARIES[@]}"; do
if [[ ! -f "$bin" ]]; then
echo "ERROR: Binary not found: $bin"
exit 1
fi
if [[ ! -x "$bin" ]]; then
echo "ERROR: Binary not executable: $bin"
chmod +x "$bin" || exit 1
echo " Fixed: Made $bin executable"
fi
echo "$bin"
done
echo ""
# Clean old profile data
echo "[PGO_BOX] Cleaning old .gcda files..."
GCDA_OLD_COUNT=$(find . -name "*.gcda" 2>/dev/null | wc -l)
if [[ $GCDA_OLD_COUNT -gt 0 ]]; then
find . -name "*.gcda" -delete
echo " Removed $GCDA_OLD_COUNT old .gcda files"
else
echo " No old .gcda files found"
fi
echo ""
# Execute workloads
echo "[PGO_BOX] Executing representative workloads..."
echo "==========================================="
WORKLOAD_NUM=0
for workload in "${PGO_WORKLOADS[@]}"; do
WORKLOAD_NUM=$((WORKLOAD_NUM + 1))
echo ""
echo "[$WORKLOAD_NUM/$PGO_WORKLOAD_COUNT] Running: $workload"
echo "-------------------------------------------"
# Execute with timeout (30s per workload)
if timeout 30 bash -lc "$workload"; then
echo " ✓ Success"
else
EXIT_CODE=$?
if [[ $EXIT_CODE -eq 124 ]]; then
echo " ✗ TIMEOUT (30s exceeded)"
else
echo " ✗ FAILED (exit code: $EXIT_CODE)"
fi
echo "ERROR: Workload failed: $workload"
exit 1
fi
done
echo ""
echo "==========================================="
# Verify profile data generated
echo "[PGO_BOX] Verifying profile data..."
GCDA_COUNT=$(find . -name "*.gcda" 2>/dev/null | wc -l)
if [[ $GCDA_COUNT -eq 0 ]]; then
echo "ERROR: No .gcda files generated!"
echo " This usually means binaries were not built with -fprofile-generate"
exit 1
fi
echo " ✓ Generated $GCDA_COUNT .gcda files"
echo ""
# Summary
echo "========================================="
echo "PGO Profile Collection: SUCCESS"
echo "========================================="
echo "Profile files: $GCDA_COUNT .gcda files"
echo "Next step: make pgo-tiny-build"
echo ""
echo "Profile locations:"
find . -name "*.gcda" | head -5
if [[ $GCDA_COUNT -gt 5 ]]; then
echo " ... and $((GCDA_COUNT - 5)) more"
fi
echo "========================================="