Files
hakmem/benchmarks/scripts/tiny/measure_rss_tiny.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

63 lines
1.8 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# Measure steady-state RSS for Tiny sizes by maintaining a live set
# and churning short-lived allocations. Reports peak and end RSS.
#
# Usage: scripts/measure_rss_tiny.sh <size> <live_count> <iters>
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
cd "$ROOT_DIR"
if [[ $# -lt 3 ]]; then
echo "usage: $0 <size> <live_count> <iters>" >&2
exit 1
fi
size=$1; live=$2; iters=$3
cat > "$ROOT_DIR/.tmp_rss_bench.c" <<'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
static size_t get_rss_kb(void) {
FILE* f = fopen("/proc/self/statm","r");
if (!f) return 0; unsigned long size, res; fscanf(f, "%lu %lu", &size, &res); fclose(f);
long ps = sysconf(_SC_PAGESIZE); return (size_t)((res * ps) / 1024);
}
int main(int argc, char** argv) {
size_t size = (size_t)strtoull(argv[1],NULL,10);
int live = atoi(argv[2]);
int iters = atoi(argv[3]);
void** L = (void**)malloc(sizeof(void*)*(size_t)live);
for (int i=0;i<live;i++) L[i] = malloc(size);
size_t peak=0;
for (int it=0; it<iters; it++) {
for (int i=0;i<live;i+=2) { free(L[i]); L[i]=malloc(size); }
size_t rss = get_rss_kb(); if (rss>peak) peak=rss;
}
size_t end_rss = get_rss_kb();
printf("peak_rss_kb=%zu end_rss_kb=%zu\n", peak, end_rss);
for (int i=0;i<live;i++) free(L[i]); free(L); return 0;
}
EOF
gcc -O3 -march=native -mtune=native .tmp_rss_bench.c -o .tmp_rss_bench
echo "[info] Building shared lib (for LD_PRELOAD HAKMEM case)"
make -s pgo-build-shared >/dev/null || true
echo "[case] HAKMEM (LD_PRELOAD)"
out_h=$(HAKMEM_LD_SAFE=1 LD_PRELOAD="$ROOT_DIR/libhakmem.so" ./.tmp_rss_bench "$size" "$live" "$iters")
echo "$out_h"
echo "[case] System"
out_s=$(./.tmp_rss_bench "$size" "$live" "$iters")
echo "$out_s"
rm -f .tmp_rss_bench .tmp_rss_bench.c