Files
hakmem/run_phase8_comprehensive_benchmark.sh
Moe Charm (CI) 4ef0171bc0 feat: Add ACE allocation failure tracing and debug hooks
This commit introduces a comprehensive tracing mechanism for allocation failures within the Adaptive Cache Engine (ACE) component. This feature allows for precise identification of the root cause for Out-Of-Memory (OOM) issues related to ACE allocations.

Key changes include:
- **ACE Tracing Implementation**:
  - Added  environment variable to enable/disable detailed logging of allocation failures.
  - Instrumented , , and  to distinguish between "Threshold" (size class mismatch), "Exhaustion" (pool depletion), and "MapFail" (OS memory allocation failure).
- **Build System Fixes**:
  - Corrected  to ensure  is properly linked into , resolving an  error.
- **LD_PRELOAD Wrapper Adjustments**:
  - Investigated and understood the  wrapper's behavior under , particularly its interaction with  and  checks.
  - Enabled debugging flags for  environment to prevent unintended fallbacks to 's  for non-tiny allocations, allowing comprehensive testing of the  allocator.
- **Debugging & Verification**:
  - Introduced temporary verbose logging to pinpoint execution flow issues within  interception and  routing. These temporary logs have been removed.
  - Created  to facilitate testing of the tracing features.

This feature will significantly aid in diagnosing and resolving allocation-related OOM issues in  by providing clear insights into the failure pathways.
2025-12-01 16:37:59 +09:00

130 lines
5.4 KiB
Bash
Executable File

#!/bin/bash
# Phase 8 Comprehensive Allocator Comparison
# Compares HAKMEM (Phase 8) vs System malloc vs mimalloc
set -e
WORKDIR="/mnt/workdisk/public_share/hakmem"
cd "$WORKDIR"
OUTPUT_FILE="phase8_comprehensive_benchmark_results.txt"
rm -f "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "Phase 8 Comprehensive Allocator Comparison" | tee -a "$OUTPUT_FILE"
echo "Date: $(date)" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "" | tee -a "$OUTPUT_FILE"
# Verify binaries exist
echo "Verifying binaries..." | tee -a "$OUTPUT_FILE"
for binary in bench_random_mixed_hakmem bench_random_mixed_system bench_random_mixed_mi; do
if [ ! -x "$binary" ]; then
echo "ERROR: $binary not found or not executable" | tee -a "$OUTPUT_FILE"
exit 1
fi
echo "$binary" | tee -a "$OUTPUT_FILE"
done
echo "" | tee -a "$OUTPUT_FILE"
# Benchmark configurations
ITERATIONS=10000000
WORKING_SETS=(256 8192)
NUM_RUNS=5
# Function to run benchmark
run_benchmark() {
local binary=$1
local allocator=$2
local working_set=$3
local run_num=$4
echo "[$allocator] Working Set $working_set - Run $run_num/5..." | tee -a "$OUTPUT_FILE"
# Run and capture output
result=$(./$binary $ITERATIONS $working_set 2>&1)
echo "$result" >> "$OUTPUT_FILE"
# Extract M ops/s
ops=$(echo "$result" | grep -oP '\d+\.\d+(?= M ops/s)' | head -1)
echo "$ops"
}
# Arrays to store results
declare -A results_hakmem_256
declare -A results_system_256
declare -A results_mi_256
declare -A results_hakmem_8192
declare -A results_system_8192
declare -A results_mi_8192
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "BENCHMARK 1: Working Set 256 (Hot cache, Phase 7 comparison)" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "" | tee -a "$OUTPUT_FILE"
# Working Set 256
echo "--- HAKMEM (Phase 8) - Working Set 256 ---" | tee -a "$OUTPUT_FILE"
for i in {1..5}; do
results_hakmem_256[$i]=$(run_benchmark "bench_random_mixed_hakmem" "HAKMEM" 256 $i)
done
echo "" | tee -a "$OUTPUT_FILE"
echo "--- System malloc (glibc) - Working Set 256 ---" | tee -a "$OUTPUT_FILE"
for i in {1..5}; do
results_system_256[$i]=$(run_benchmark "bench_random_mixed_system" "System" 256 $i)
done
echo "" | tee -a "$OUTPUT_FILE"
echo "--- mimalloc - Working Set 256 ---" | tee -a "$OUTPUT_FILE"
for i in {1..5}; do
results_mi_256[$i]=$(run_benchmark "bench_random_mixed_mi" "mimalloc" 256 $i)
done
echo "" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "BENCHMARK 2: Working Set 8192 (Realistic workload)" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "" | tee -a "$OUTPUT_FILE"
# Working Set 8192
echo "--- HAKMEM (Phase 8) - Working Set 8192 ---" | tee -a "$OUTPUT_FILE"
for i in {1..5}; do
results_hakmem_8192[$i]=$(run_benchmark "bench_random_mixed_hakmem" "HAKMEM" 8192 $i)
done
echo "" | tee -a "$OUTPUT_FILE"
echo "--- System malloc (glibc) - Working Set 8192 ---" | tee -a "$OUTPUT_FILE"
for i in {1..5}; do
results_system_8192[$i]=$(run_benchmark "bench_random_mixed_system" "System" 8192 $i)
done
echo "" | tee -a "$OUTPUT_FILE"
echo "--- mimalloc - Working Set 8192 ---" | tee -a "$OUTPUT_FILE"
for i in {1..5}; do
results_mi_8192[$i]=$(run_benchmark "bench_random_mixed_mi" "mimalloc" 8192 $i)
done
echo "" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "RAW DATA SUMMARY" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "" | tee -a "$OUTPUT_FILE"
echo "Working Set 256:" | tee -a "$OUTPUT_FILE"
echo " HAKMEM: ${results_hakmem_256[1]}, ${results_hakmem_256[2]}, ${results_hakmem_256[3]}, ${results_hakmem_256[4]}, ${results_hakmem_256[5]}" | tee -a "$OUTPUT_FILE"
echo " System: ${results_system_256[1]}, ${results_system_256[2]}, ${results_system_256[3]}, ${results_system_256[4]}, ${results_system_256[5]}" | tee -a "$OUTPUT_FILE"
echo " mimalloc: ${results_mi_256[1]}, ${results_mi_256[2]}, ${results_mi_256[3]}, ${results_mi_256[4]}, ${results_mi_256[5]}" | tee -a "$OUTPUT_FILE"
echo "" | tee -a "$OUTPUT_FILE"
echo "Working Set 8192:" | tee -a "$OUTPUT_FILE"
echo " HAKMEM: ${results_hakmem_8192[1]}, ${results_hakmem_8192[2]}, ${results_hakmem_8192[3]}, ${results_hakmem_8192[4]}, ${results_hakmem_8192[5]}" | tee -a "$OUTPUT_FILE"
echo " System: ${results_system_8192[1]}, ${results_system_8192[2]}, ${results_system_8192[3]}, ${results_system_8192[4]}, ${results_system_8192[5]}" | tee -a "$OUTPUT_FILE"
echo " mimalloc: ${results_mi_8192[1]}, ${results_mi_8192[2]}, ${results_mi_8192[3]}, ${results_mi_8192[4]}, ${results_mi_8192[5]}" | tee -a "$OUTPUT_FILE"
echo "" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"
echo "Benchmark completed! Results saved to: $OUTPUT_FILE" | tee -a "$OUTPUT_FILE"
echo "=====================================================================" | tee -a "$OUTPUT_FILE"