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:
@ -14,6 +14,8 @@
|
||||
#include "../pool_tls.h"
|
||||
#endif
|
||||
|
||||
#include "mid_large_config_box.h" // Phase 5-Step3: Compile-time config for Mid/Large
|
||||
|
||||
// Optional route trace: print first N classification lines when enabled by env
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
static inline int hak_free_route_trace_on(void) {
|
||||
@ -284,12 +286,13 @@ void hak_free_at(void* ptr, size_t size, hak_callsite_t site) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (HAK_ENABLED_CACHE(HAKMEM_FEATURE_BIGCACHE) && hdr->class_bytes >= 2097152) {
|
||||
// Phase 5-Step3: Use Mid/Large Config Box (compile-time constant in PGO mode)
|
||||
if (MID_LARGE_BIGCACHE_ENABLED && hdr->class_bytes >= 2097152) {
|
||||
if (hak_bigcache_put(ptr, hdr->size, hdr->alloc_site)) goto done;
|
||||
}
|
||||
{
|
||||
static int g_bc_l25_en_free = -1; if (g_bc_l25_en_free == -1) { const char* e = getenv("HAKMEM_BIGCACHE_L25"); g_bc_l25_en_free = (e && atoi(e) != 0) ? 1 : 0; }
|
||||
if (g_bc_l25_en_free && HAK_ENABLED_CACHE(HAKMEM_FEATURE_BIGCACHE) && hdr->size >= 524288 && hdr->size < 2097152) {
|
||||
if (g_bc_l25_en_free && MID_LARGE_BIGCACHE_ENABLED && hdr->size >= 524288 && hdr->size < 2097152) {
|
||||
if (hak_bigcache_put(ptr, hdr->size, hdr->alloc_site)) goto done;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user