Files
hakmem/archive/tools/analyze_actual.c
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

87 lines
4.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdlib.h>
int main() {
// Actual benchmark results
double measured_hakmem_100k = 4.9; // MB
double measured_hakmem_1M = 39.6; // MB
double measured_mimalloc_100k = 5.1;
double measured_mimalloc_1M = 25.1;
// Theoretical data
double data_100k = 100000 * 16.0 / (1024*1024); // 1.53 MB
double data_1M = 1000000 * 16.0 / (1024*1024); // 15.26 MB
printf("=== SCALING ANALYSIS ===\n\n");
printf("100K allocations (%.2f MB data):\n", data_100k);
printf(" HAKMEM: %.2f MB (%.0f%% overhead)\n",
measured_hakmem_100k, (measured_hakmem_100k/data_100k - 1)*100);
printf(" mimalloc: %.2f MB (%.0f%% overhead)\n\n",
measured_mimalloc_100k, (measured_mimalloc_100k/data_100k - 1)*100);
printf("1M allocations (%.2f MB data):\n", data_1M);
printf(" HAKMEM: %.2f MB (%.0f%% overhead)\n",
measured_hakmem_1M, (measured_hakmem_1M/data_1M - 1)*100);
printf(" mimalloc: %.2f MB (%.0f%% overhead)\n\n",
measured_mimalloc_1M, (measured_mimalloc_1M/data_1M - 1)*100);
printf("=== THE PARADOX ===\n\n");
// Calculate per-allocation overhead
double hakmem_per_alloc_100k = (measured_hakmem_100k - data_100k) * 1024 * 1024 / 100000;
double hakmem_per_alloc_1M = (measured_hakmem_1M - data_1M) * 1024 * 1024 / 1000000;
double mimalloc_per_alloc_100k = (measured_mimalloc_100k - data_100k) * 1024 * 1024 / 100000;
double mimalloc_per_alloc_1M = (measured_mimalloc_1M - data_1M) * 1024 * 1024 / 1000000;
printf("Per-allocation overhead:\n");
printf(" HAKMEM 100K: %.1f bytes/alloc\n", hakmem_per_alloc_100k);
printf(" HAKMEM 1M: %.1f bytes/alloc\n", hakmem_per_alloc_1M);
printf(" mimalloc 100K: %.1f bytes/alloc\n", mimalloc_per_alloc_100k);
printf(" mimalloc 1M: %.1f bytes/alloc\n\n", mimalloc_per_alloc_1M);
// Calculate fixed overhead
// Formula: measured = data + fixed + (per_alloc * N)
// measured_100k = data_100k + fixed + per_alloc * 100k
// measured_1M = data_1M + fixed + per_alloc * 1M
// Solve for fixed and per_alloc
// Assume per_alloc is constant
double delta_measured_hakmem = measured_hakmem_1M - measured_hakmem_100k;
double delta_data = data_1M - data_100k;
double delta_allocs = 900000;
double hakmem_per_alloc = (delta_measured_hakmem - delta_data) * 1024 * 1024 / delta_allocs;
double hakmem_fixed = (measured_hakmem_100k - data_100k) * 1024 * 1024 - hakmem_per_alloc * 100000;
double delta_measured_mimalloc = measured_mimalloc_1M - measured_mimalloc_100k;
double mimalloc_per_alloc = (delta_measured_mimalloc - delta_data) * 1024 * 1024 / delta_allocs;
double mimalloc_fixed = (measured_mimalloc_100k - data_100k) * 1024 * 1024 - mimalloc_per_alloc * 100000;
printf("=== COST MODEL ===\n");
printf("Formula: Total = Data + Fixed + (PerAlloc × N)\n\n");
printf("HAKMEM:\n");
printf(" Fixed overhead: %.2f MB\n", hakmem_fixed / (1024*1024));
printf(" Per-alloc overhead: %.1f bytes\n", hakmem_per_alloc);
printf(" At 100K: %.2f = %.2f + %.2f + (%.1f × 100K)\n",
measured_hakmem_100k, data_100k, hakmem_fixed/(1024*1024), hakmem_per_alloc);
printf(" At 1M: %.2f = %.2f + %.2f + (%.1f × 1M)\n\n",
measured_hakmem_1M, data_1M, hakmem_fixed/(1024*1024), hakmem_per_alloc);
printf("mimalloc:\n");
printf(" Fixed overhead: %.2f MB\n", mimalloc_fixed / (1024*1024));
printf(" Per-alloc overhead: %.1f bytes\n", mimalloc_per_alloc);
printf(" At 100K: %.2f = %.2f + %.2f + (%.1f × 100K)\n",
measured_mimalloc_100k, data_100k, mimalloc_fixed/(1024*1024), mimalloc_per_alloc);
printf(" At 1M: %.2f = %.2f + %.2f + (%.1f × 1M)\n\n",
measured_mimalloc_1M, data_1M, mimalloc_fixed/(1024*1024), mimalloc_per_alloc);
printf("=== KEY INSIGHT ===\n");
printf("HAKMEM has %.1f× HIGHER per-allocation overhead (%.1f vs %.1f bytes)\n",
hakmem_per_alloc / mimalloc_per_alloc, hakmem_per_alloc, mimalloc_per_alloc);
printf("This means: Bitmap metadata is NOT 0.125 bytes/block as expected!\n");
return 0;
}