Phase 83-1 + Allocator Comparison: Switch dispatch fixed (NO-GO +0.32%), PROFILE correction, SCORECARD update
Key changes: - Phase 83-1: Switch dispatch fixed mode (tiny_inline_slots_switch_dispatch_fixed_box) - NO-GO (marginal +0.32%, branch reduction negligible) Reason: lazy-init pattern already optimal, Phase 78-1 pattern shows diminishing returns - Allocator comparison baseline update (10-run SSOT, WS=400, ITERS=20M): tcmalloc: 115.26M (92.33% of mimalloc) jemalloc: 97.39M (77.96% of mimalloc) system: 85.20M (68.24% of mimalloc) mimalloc: 124.82M (baseline) - hakmem PROFILE correction: scripts/run_mixed_10_cleanenv.sh + run_allocator_quick_matrix.sh PROFILE explicitly set to MIXED_TINYV3_C7_SAFE for hakmem measurements Result: baseline stabilized to 55.53M (44.46% of mimalloc) Previous unstable measurement (35.57M) was due to profile leak - Documentation: * PERFORMANCE_TARGETS_SCORECARD.md: Reference allocators + M1/M2 milestone status * PHASE83_1_SWITCH_DISPATCH_FIXED_RESULTS.md: Phase 83-1 analysis (NO-GO) * ALLOCATOR_COMPARISON_QUICK_RUNBOOK.md: Quick comparison procedure * ALLOCATOR_COMPARISON_SSOT.md: Detailed SSOT methodology - M2 milestone status: 44.46% (target 55%, gap -10.54pp) - structural improvements needed 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
73
core/front/tiny_c3_inline_slots.h
Normal file
73
core/front/tiny_c3_inline_slots.h
Normal file
@ -0,0 +1,73 @@
|
||||
// tiny_c3_inline_slots.h - Phase 77-1: C3 Inline Slots Fast-Path API
|
||||
//
|
||||
// Goal: Zero-overhead always-inline push/pop for C3 FIFO ring buffer
|
||||
// Scope: C3 allocations (64-128B)
|
||||
// Design: Fail-fast to unified_cache on full/empty
|
||||
//
|
||||
// Fast-Path Strategy:
|
||||
// - Always-inline push/pop for zero-call-overhead
|
||||
// - Modulo arithmetic inlined (tail/head)
|
||||
// - Return NULL on empty, 0 on full (caller handles fallback)
|
||||
// - No bounds checking (ring size fixed at compile time)
|
||||
//
|
||||
// Integration Points:
|
||||
// - Alloc: Call c3_inline_pop() in tiny_front_hot_box BEFORE unified_cache
|
||||
// - Free: Call c3_inline_push() in tiny_legacy_fallback BEFORE unified_cache
|
||||
//
|
||||
// Rationale:
|
||||
// - Same pattern as C4/C5/C6 inline slots (proven +7.05% cumulative)
|
||||
// - Conservative cap (256) = 2KB/thread (Phase 77-0 recommendation)
|
||||
// - Fail-fast design = no performance cliff if full/empty
|
||||
|
||||
#ifndef HAK_FRONT_TINY_C3_INLINE_SLOTS_H
|
||||
#define HAK_FRONT_TINY_C3_INLINE_SLOTS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../box/tiny_c3_inline_slots_tls_box.h"
|
||||
#include "../box/tiny_c3_inline_slots_env_box.h"
|
||||
#include "../box/tiny_inline_slots_fixed_mode_box.h"
|
||||
|
||||
// ============================================================================
|
||||
// C3 Inline Slots: Fast-Path Push/Pop (Always-Inline)
|
||||
// ============================================================================
|
||||
|
||||
// Get TLS pointer for C3 inline slots
|
||||
// Inline for zero overhead
|
||||
static inline TinyC3InlineSlots* c3_inline_tls(void) {
|
||||
extern __thread TinyC3InlineSlots g_tiny_c3_inline_slots;
|
||||
return &g_tiny_c3_inline_slots;
|
||||
}
|
||||
|
||||
// Push pointer to C3 inline ring
|
||||
// Returns: 1 if success, 0 if full (caller must fallback to unified_cache)
|
||||
__attribute__((always_inline))
|
||||
static inline int c3_inline_push(TinyC3InlineSlots* slots, void* ptr) {
|
||||
// Check if ring is full
|
||||
if (__builtin_expect(c3_inline_full(slots), 0)) {
|
||||
return 0; // Full, caller must use unified_cache
|
||||
}
|
||||
|
||||
// Enqueue at tail
|
||||
slots->slots[slots->tail] = ptr;
|
||||
slots->tail = (slots->tail + 1) % TINY_C3_INLINE_CAPACITY;
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
|
||||
// Pop pointer from C3 inline ring
|
||||
// Returns: non-NULL if success, NULL if empty (caller must fallback to unified_cache)
|
||||
__attribute__((always_inline))
|
||||
static inline void* c3_inline_pop(TinyC3InlineSlots* slots) {
|
||||
// Check if ring is empty
|
||||
if (__builtin_expect(c3_inline_empty(slots), 0)) {
|
||||
return NULL; // Empty, caller must use unified_cache
|
||||
}
|
||||
|
||||
// Dequeue from head
|
||||
void* ptr = slots->slots[slots->head];
|
||||
slots->head = (slots->head + 1) % TINY_C3_INLINE_CAPACITY;
|
||||
|
||||
return ptr; // Success
|
||||
}
|
||||
|
||||
#endif // HAK_FRONT_TINY_C3_INLINE_SLOTS_H
|
||||
Reference in New Issue
Block a user