Step 2 & 3 Complete: - A/B test (Mixed 10-run): STATIC_ROUTE=0 (38.91M) → =1 (39.77M) = +2.20% avg - Median gain: +1.98% - Result: ✅ GO (exceeds +1.0% threshold) - Decision: ✅ ADOPT into MIXED_TINYV3_C7_SAFE preset - bench_profile.h line 77: HAKMEM_TINY_STATIC_ROUTE=1 default - Learner auto-disables static route when HAKMEM_SMALL_LEARNER_V7_ENABLED=1 Implementation Summary: - core/box/tiny_static_route_box.{h,c}: Research box (Step 1A) - core/front/malloc_tiny_fast.h: Route lookup integration (Step 1B, lines 249-256) - core/bench_profile.h: Bench sync + preset adoption Cumulative Phase 2-3 Gains: - B3 (Routing shape): +2.89% - B4 (Wrapper split): +1.47% - C3 (Static routing): +2.20% - Total: ~6.8% (35.2M → ~39.8M ops/s) Next: Phase 3 C1 (TLS Prefetch, expected +2-4%) 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
31 lines
1.2 KiB
C
31 lines
1.2 KiB
C
// wrapper_env_box.h - Environment variable cache for malloc/free wrappers
|
|
// Eliminates getenv() calls from malloc/free hot paths
|
|
#pragma once
|
|
|
|
#include <stdatomic.h>
|
|
|
|
typedef struct {
|
|
int inited;
|
|
int step_trace; // HAKMEM_STEP_TRACE (default: 0)
|
|
int ld_safe_mode; // HAKMEM_LD_SAFE (default: 1)
|
|
int free_wrap_trace; // HAKMEM_FREE_WRAP_TRACE (default: 0)
|
|
int wrap_diag; // HAKMEM_WRAP_DIAG (default: 0) - log first few libc fallbacks
|
|
int wrap_shape; // HAKMEM_WRAP_SHAPE (default: 0) - Phase 2 B4: malloc/free hot/cold split
|
|
} wrapper_env_cfg_t;
|
|
|
|
extern wrapper_env_cfg_t g_wrapper_env;
|
|
|
|
void wrapper_env_init_once(void);
|
|
// Bench helper: re-read ENV after bench_profile putenv defaults.
|
|
// This keeps wrapper hot paths getenv-free while still allowing HAKMEM_PROFILE presets.
|
|
void wrapper_env_refresh_from_env(void);
|
|
|
|
static inline const wrapper_env_cfg_t* wrapper_env_cfg(void) {
|
|
// Constructor ensures init at library load time
|
|
// This check prevents repeated initialization in multi-threaded context
|
|
if (__builtin_expect(!g_wrapper_env.inited, 0)) {
|
|
wrapper_env_init_once();
|
|
}
|
|
return &g_wrapper_env;
|
|
}
|