Phase 5-Step3: Mid/Large Config Box (future workload optimization)
Add compile-time configuration for Mid/Large allocation paths using Box pattern. Implementation: - Created core/box/mid_large_config_box.h - Dual-mode config: PGO (compile-time) vs Normal (runtime) - Replace HAK_ENABLED_* checks with MID_LARGE_* macros - Dead code elimination when HAKMEM_MID_LARGE_PGO=1 Target Checks Eliminated (PGO mode): - MID_LARGE_BIGCACHE_ENABLED (BigCache for 2MB+ allocations) - MID_LARGE_ELO_ENABLED (ELO learning/threshold) - MID_LARGE_ACE_ENABLED (ACE allocator gate) - MID_LARGE_EVOLUTION_ENABLED (Evolution sampling) Files: - core/box/mid_large_config_box.h (NEW) - Config Box pattern - core/hakmem_build_flags.h - Add HAKMEM_MID_LARGE_PGO flag - core/box/hak_alloc_api.inc.h - Replace 2 checks (ELO, BigCache) - core/box/hak_free_api.inc.h - Replace 2 checks (BigCache) Performance Impact: - Current workloads (16B-8KB): No effect (checks not in hot path) - Future workloads (2MB+): Expected +2-4% via dead code elimination Box Pattern: ✅ Single responsibility, clear contract, testable Note: Config Box infrastructure ready for future large allocation benchmarks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include "../pool_tls.h"
|
||||
#endif
|
||||
|
||||
#include "mid_large_config_box.h" // Phase 5-Step3: Compile-time config for Mid/Large
|
||||
|
||||
// Centralized OS mapping boundary to keep syscalls in one place
|
||||
static inline void* hak_os_map_boundary(size_t size, uintptr_t site_id) {
|
||||
#if HAKMEM_DEBUG_TIMING
|
||||
@ -140,15 +142,16 @@ inline void* hak_alloc_at(size_t size, hak_callsite_t site) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Phase 5-Step3: Use Mid/Large Config Box (compile-time constant in PGO mode)
|
||||
size_t threshold;
|
||||
if (HAK_ENABLED_LEARNING(HAKMEM_FEATURE_ELO)) {
|
||||
if (MID_LARGE_ELO_ENABLED) {
|
||||
int strategy_id = atomic_load(&g_cached_strategy_id);
|
||||
threshold = hak_elo_get_threshold(strategy_id);
|
||||
} else {
|
||||
threshold = 2097152;
|
||||
}
|
||||
|
||||
if (HAK_ENABLED_CACHE(HAKMEM_FEATURE_BIGCACHE) && size >= threshold) {
|
||||
if (MID_LARGE_BIGCACHE_ENABLED && size >= threshold) {
|
||||
void* cached_ptr = NULL;
|
||||
#if HAKMEM_DEBUG_TIMING
|
||||
HKM_TIME_START(t_bc);
|
||||
|
||||
Reference in New Issue
Block a user