Files
hakmem/scripts/sweep_mem_perf.sh
Moe Charm (CI) 52386401b3 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>
2025-11-05 12:31:14 +09:00

90 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# sweep_mem_perf.sh - Sweep HAKMEM memory/performance knobs and measure results
# Usage: scripts/sweep_mem_perf.sh [tiny|mixed|both]
set -euo pipefail
MODE="${1:-both}"
bench_tiny() {
local REFILL_ONE=$1 SLLM=$2 TRIMMS=$3 FLUSH=$4 INT=$5
# Throughput run (short)
local out
out=$(HAKMEM_TINY_REFILL_ONE_ON_MISS=$REFILL_ONE \
HAKMEM_SLL_MULTIPLIER=$SLLM \
HAKMEM_TINY_IDLE_TRIM_MS=$TRIMMS \
HAKMEM_TINY_IDLE_FLUSH=$FLUSH \
HAKMEM_INT_ENGINE=$INT \
./bench_tiny_hot_hakmem 64 100 60000 2>/dev/null | tail -n 5)
local thr=$(echo "$out" | awk '/Throughput/{print $2}')
# Memory run (background)
HAKMEM_TINY_REFILL_ONE_ON_MISS=$REFILL_ONE \
HAKMEM_SLL_MULTIPLIER=$SLLM \
HAKMEM_TINY_IDLE_TRIM_MS=$TRIMMS \
HAKMEM_TINY_IDLE_FLUSH=$FLUSH \
HAKMEM_INT_ENGINE=$INT \
./bench_tiny_hot_hakmem 64 1000 400000000 >/dev/null 2>&1 &
local pid=$!
sleep 1
local rss_kb=0 vms_kb=0
if ps -p $pid >/dev/null 2>&1; then
rss_kb=$(awk '/VmRSS/{print $2}' /proc/$pid/status)
vms_kb=$(awk '/VmSize/{print $2}' /proc/$pid/status)
kill $pid 2>/dev/null || true
wait $pid 2>/dev/null || true
fi
echo "tiny,$REFILL_ONE,$SLLM,$TRIMMS,$FLUSH,$INT,$thr,$rss_kb,$vms_kb"
}
bench_mixed() {
local REFILL_ONE=$1 SLLM=$2 TRIMMS=$3 FLUSH=$4 INT=$5
# Throughput run (short)
local out
out=$(HAKMEM_TINY_REFILL_ONE_ON_MISS=$REFILL_ONE \
HAKMEM_SLL_MULTIPLIER=$SLLM \
HAKMEM_TINY_IDLE_TRIM_MS=$TRIMMS \
HAKMEM_TINY_IDLE_FLUSH=$FLUSH \
HAKMEM_INT_ENGINE=$INT \
./bench_random_mixed_hakmem 500000 400 42 2>/dev/null | tail -n 5)
local thr=$(echo "$out" | awk '/Throughput/{print $2}')
# Memory run (background)
HAKMEM_TINY_REFILL_ONE_ON_MISS=$REFILL_ONE \
HAKMEM_SLL_MULTIPLIER=$SLLM \
HAKMEM_TINY_IDLE_TRIM_MS=$TRIMMS \
HAKMEM_TINY_IDLE_FLUSH=$FLUSH \
HAKMEM_INT_ENGINE=$INT \
./bench_random_mixed_hakmem 5000000 400 42 >/dev/null 2>&1 &
local pid=$!
sleep 1
local rss_kb=0 vms_kb=0
if ps -p $pid >/dev/null 2>&1; then
rss_kb=$(awk '/VmRSS/{print $2}' /proc/$pid/status)
vms_kb=$(awk '/VmSize/{print $2}' /proc/$pid/status)
kill $pid 2>/dev/null || true
wait $pid 2>/dev/null || true
fi
echo "mixed,$REFILL_ONE,$SLLM,$TRIMMS,$FLUSH,$INT,$thr,$rss_kb,$vms_kb"
}
echo "bench,refill_one,sll_mult,trim_ms,flush,int_engine,throughput_Mops,rss_kb,vms_kb"
# Sweep a small set of meaningful combos
COMBOS=(
"0 2 0 0 0" # baseline perf-ish
"1 1 0 0 0" # SLL shrink only
"1 1 200 1 1" # memory-mode core
"1 2 0 0 0" # refill-one only
"0 1 200 1 1" # sll shrink + idle trim
"1 1 100 1 1" # aggressive trim
)
for c in "${COMBOS[@]}"; do
set -- $c
if [[ "$MODE" == "tiny" || "$MODE" == "both" ]]; then
bench_tiny "$@"
fi
if [[ "$MODE" == "mixed" || "$MODE" == "both" ]]; then
bench_mixed "$@"
fi
done