diff --git a/core/tiny_alloc_fast.inc.h b/core/tiny_alloc_fast.inc.h index 75e6a653..2e7b17a6 100644 --- a/core/tiny_alloc_fast.inc.h +++ b/core/tiny_alloc_fast.inc.h @@ -198,6 +198,37 @@ static inline void* tiny_alloc_fast_pop(int class_idx) { } return NULL; #else + // ========== Phase 19-1: Quick Prune (Frontend SLIM mode) ========== + // ENV: HAKMEM_TINY_FRONT_SLIM=1 + // Goal: Skip FastCache + SFC layers, go straight to SLL (88-99% hit rate) + // Expected: 22M → 27-30M ops/s (+22-36%) + static __thread int g_front_slim_checked = 0; + static __thread int g_front_slim_enabled = 0; + + if (__builtin_expect(!g_front_slim_checked, 0)) { + const char* e = getenv("HAKMEM_TINY_FRONT_SLIM"); + g_front_slim_enabled = (e && *e && *e != '0') ? 1 : 0; + g_front_slim_checked = 1; + } + + // SLIM MODE: Skip FastCache + SFC, go straight to SLL + if (__builtin_expect(g_front_slim_enabled, 0)) { + // Box Boundary: TLS SLL freelist pop (only layer in SLIM mode) + extern int g_tls_sll_enable; + if (__builtin_expect(g_tls_sll_enable, 1)) { + void* base = NULL; + if (tls_sll_pop(class_idx, &base)) { + // Front Gate: SLL hit (SLIM fast path - 3 instructions) + extern unsigned long long g_front_sll_hit[]; + g_front_sll_hit[class_idx]++; + return base; + } + } + // SLIM mode miss → return NULL (caller refills) + return NULL; + } + // ========== End Phase 19-1: Quick Prune ========== + // Phase 7 Task 3: Profiling overhead removed in release builds // In release mode, compiler can completely eliminate profiling code #if !HAKMEM_BUILD_RELEASE