Files
hakmem/archive/old_logs/debug_free_stats.patch
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

70 lines
3.2 KiB
Diff

--- core/hakmem.c.orig
+++ core/hakmem.c
@@ -786,6 +786,13 @@
return;
}
+ // DEBUG: Free path statistics
+ static __thread uint64_t mid_mt_local_free = 0;
+ static __thread uint64_t mid_mt_registry_free = 0;
+ static __thread uint64_t tiny_slab_free = 0;
+ static __thread uint64_t other_free = 0;
+ static __thread uint64_t total_free = 0;
+
// OPTIMIZATION: Check Mid Range MT FIRST (for bench_mid_large_mt workload)
// This benchmark is 100% Mid MT allocations, so check Mid MT before Tiny
// to avoid the 1.1% overhead of hak_tiny_owner_slab() lookup
@@ -807,6 +814,15 @@
seg->free_list = ptr; // Update head
seg->used_count--;
+ // DEBUG stats
+ mid_mt_local_free++;
+ total_free++;
+ if (total_free % 100000 == 0) {
+ fprintf(stderr, "[FREE STATS] Total=%llu MidLocal=%llu (%.1f%%) MidRegistry=%llu (%.1f%%) Tiny=%llu (%.1f%%) Other=%llu (%.1f%%)\n",
+ total_free,
+ mid_mt_local_free, 100.0 * mid_mt_local_free / total_free,
+ mid_mt_registry_free, 100.0 * mid_mt_registry_free / total_free,
+ tiny_slab_free, 100.0 * tiny_slab_free / total_free,
+ other_free, 100.0 * other_free / total_free);
+ }
#if HAKMEM_DEBUG_TIMING
HKM_TIME_END(HKM_CAT_HAK_FREE, t0);
#endif
@@ -819,6 +835,15 @@
if (mid_registry_lookup(ptr, &mid_block_size, &mid_class_idx)) {
// Found in Mid MT registry - free it
mid_mt_free(ptr, mid_block_size);
+ // DEBUG stats
+ mid_mt_registry_free++;
+ total_free++;
+ if (total_free % 100000 == 0) {
+ fprintf(stderr, "[FREE STATS] Total=%llu MidLocal=%llu (%.1f%%) MidRegistry=%llu (%.1f%%) Tiny=%llu (%.1f%%) Other=%llu (%.1f%%)\n",
+ total_free,
+ mid_mt_local_free, 100.0 * mid_mt_local_free / total_free,
+ mid_mt_registry_free, 100.0 * mid_mt_registry_free / total_free,
+ tiny_slab_free, 100.0 * tiny_slab_free / total_free,
+ other_free, 100.0 * other_free / total_free);
+ }
#if HAKMEM_DEBUG_TIMING
HKM_TIME_END(HKM_CAT_HAK_FREE, t0);
#endif
@@ -838,6 +863,15 @@
TinySlab* tiny_slab = hak_tiny_owner_slab(ptr);
if (tiny_slab) {
hak_tiny_free(ptr);
+ // DEBUG stats
+ tiny_slab_free++;
+ total_free++;
+ if (total_free % 100000 == 0) {
+ fprintf(stderr, "[FREE STATS] Total=%llu MidLocal=%llu (%.1f%%) MidRegistry=%llu (%.1f%%) Tiny=%llu (%.1f%%) Other=%llu (%.1f%%)\n",
+ total_free,
+ mid_mt_local_free, 100.0 * mid_mt_local_free / total_free,
+ mid_mt_registry_free, 100.0 * mid_mt_registry_free / total_free,
+ tiny_slab_free, 100.0 * tiny_slab_free / total_free,
+ other_free, 100.0 * other_free / total_free);
+ }
#if HAKMEM_DEBUG_TIMING
HKM_TIME_END(HKM_CAT_HAK_FREE, t0);
#endif