Phase 9-1: O(1) SuperSlab lookup optimization - Created ss_addr_map_box: Hash table (8192 buckets) for O(1) SuperSlab lookup - Created ss_tls_hint_box: TLS caching layer for SuperSlab hints - Integrated hash table into registry (init, insert, remove, lookup) - Modified hak_super_lookup() to use new hash table - Expected: 50-80 cycles → 10-20 cycles (not verified - SuperSlab disabled by default) Phase 9-2: EMPTY slab recycling implementation - Created slab_recycling_box: SLAB_TRY_RECYCLE() macro following Box pattern - Integrated into remote drain (superslab_slab.c) - Integrated into TLS SLL drain (tls_sll_drain_box.h) with touched slab tracking - Observable: Debug tracing via HAKMEM_SLAB_RECYCLE_TRACE - Updated Makefile: Added new box objects to 3 build targets Known Issues: - SuperSlab registry exhaustion still occurs (unregistration not working) - shared_pool_release_slab() may not be removing from g_super_reg[] - Needs investigation before Phase 9-2 can be completed Expected Impact (when fixed): - Stage 1 hit rate: 0% → 80% - shared_fail events: 4 → 0 - Kernel overhead: 55% → 15% - Throughput: 16.5M → 25-30M ops/s (+50-80%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
1.4 KiB
C
31 lines
1.4 KiB
C
// 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
|