// slab_recycling_box.c - Phase 9-2: Slab Recycling Implementation // Purpose: Statistics tracking for EMPTY slab recycling #include "slab_recycling_box.h" // ============================================================================ // Statistics (Debug builds only) // ============================================================================ #if !HAKMEM_BUILD_RELEASE // Per-thread recycling statistics __thread SlabRecyclingStats g_slab_recycle_stats = {0}; void slab_recycle_print_stats(void) { fprintf(stderr, "\n[SLAB_RECYCLE_STATS] Slab Recycling Statistics:\n"); fprintf(stderr, " Total attempts: %lu\n", g_slab_recycle_stats.recycle_attempts); fprintf(stderr, " Successful recycles: %lu\n", g_slab_recycle_stats.recycle_success); fprintf(stderr, " Skipped (not empty): %lu\n", g_slab_recycle_stats.recycle_skip_not_empty); fprintf(stderr, " Skipped (no capacity): %lu\n", g_slab_recycle_stats.recycle_skip_no_cap); fprintf(stderr, " Skipped (null ptr): %lu\n", g_slab_recycle_stats.recycle_skip_null); if (g_slab_recycle_stats.recycle_attempts > 0) { double success_rate = 100.0 * g_slab_recycle_stats.recycle_success / g_slab_recycle_stats.recycle_attempts; fprintf(stderr, " Success rate: %.1f%%\n", success_rate); } fprintf(stderr, "\n"); } #endif