Phase 1A3: tiny_region_id_write_header always_inline research box (NO-GO)

Add HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE build flag (default 0) to enable
always_inline on tiny_region_id_write_header().

A/B Results (HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE=0 vs 1):
- Mixed (10-run): 49.53M → 47.55M ops/s (-4.00% regression)
- C6-heavy (5-run): 23.49M → 24.93M ops/s (+6.00% improvement)

Decision: NO-GO - Mixed regression (-4%) exceeds threshold (-1%)
Status: Frozen as research box (default OFF)

Root Cause: I-cache pressure from forced inline expansion
- Mixed workload: higher code diversity → I-cache evictions
- C6-heavy workload: focused pattern → benefits from inlining

Patches:
1. core/hakmem_build_flags.h: Add HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE (default 0)
2. core/tiny_region_id.h: Add conditional __attribute__((always_inline)) gate

Build: make -j EXTRA_CFLAGS=-DHAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE=1 [target]

Recommendation: Keep compiler's natural inline heuristic (already optimal for Mixed)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-13 15:31:08 +09:00
parent 93b59ef414
commit df37baa505
2 changed files with 15 additions and 0 deletions

View File

@ -91,6 +91,15 @@
# define HAKMEM_TINY_INLINE_SLL 0 # define HAKMEM_TINY_INLINE_SLL 0
#endif #endif
// Phase 1A3: Always-inline tiny_region_id_write_header()
// Default: OFF (HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE=0) - enable after A/B validation
// Purpose: Force inline expansion of header write to reduce alloc path overhead
// Expected impact: +0.5-2% on Mixed workloads
// Build: make EXTRA_CFLAGS=-DHAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE=1 [target]
#ifndef HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE
# define HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE 0
#endif
// Phase 7 Task 3: Pre-warm TLS cache at init // Phase 7 Task 3: Pre-warm TLS cache at init
// Default: OFF (enable after implementation) // Default: OFF (enable after implementation)
// Build: make PREWARM_TLS=1 or make phase7 // Build: make PREWARM_TLS=1 or make phase7

View File

@ -212,6 +212,9 @@ static inline int tiny_header_mode(void)
// Write class_idx to header (called after allocation) // Write class_idx to header (called after allocation)
// Input: base (block start from SuperSlab) // Input: base (block start from SuperSlab)
// Returns: user pointer (base + 1, skipping header) // Returns: user pointer (base + 1, skipping header)
#if HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE
__attribute__((always_inline))
#endif
static inline void* tiny_region_id_write_header(void* base, int class_idx) { static inline void* tiny_region_id_write_header(void* base, int class_idx) {
if (!base) return base; if (!base) return base;
@ -439,6 +442,9 @@ static inline size_t tiny_region_id_user_size(size_t alloc_size) {
#else // !HAKMEM_TINY_HEADER_CLASSIDX #else // !HAKMEM_TINY_HEADER_CLASSIDX
// Disabled: No-op implementations // Disabled: No-op implementations
#if HAKMEM_TINY_HEADER_WRITE_ALWAYS_INLINE
__attribute__((always_inline))
#endif
static inline void* tiny_region_id_write_header(void* ptr, int class_idx) { static inline void* tiny_region_id_write_header(void* ptr, int class_idx) {
(void)class_idx; (void)class_idx;
return ptr; return ptr;