Changes: - scripts/box/pgo_fast_profile_config.sh: Expanded WS patterns (3→5) and seeds (1→3) for reduced overfitting and better production workload representativeness - PERFORMANCE_TARGETS_SCORECARD.md: Phase 68 baseline promoted (61.614M = 50.93%) - CURRENT_TASK.md: Phase 68 marked complete, Phase 67a (layout tax forensics) set Active Results: - 10-run verification: +1.19% vs Phase 66 baseline (GO, >+1.0% threshold) - M1 milestone: 50.93% of mimalloc (target 50%, exceeded by +0.93pp) - Stability: 10-run mean/median with <2.1% CV 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
128 lines
4.3 KiB
C
128 lines
4.3 KiB
C
// pool_config_box.h — Box: Pool Configuration & ENV Gates
|
|
//
|
|
// Purpose: Centralized ENV gate predicates for pool allocator
|
|
// Pattern: Lazy static int cache (matches tiny_heap_env_box.h style)
|
|
// All functions are static inline (zero-cost abstraction)
|
|
|
|
#ifndef POOL_CONFIG_BOX_H
|
|
#define POOL_CONFIG_BOX_H
|
|
|
|
#include "tiny_heap_env_box.h" // TinyHeap profile (C7_SAFE modes)
|
|
#include "../hakmem_build_flags.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
// ============================================================================
|
|
// Pool v2 Configuration
|
|
// ============================================================================
|
|
|
|
// Pool v2 is experimental. Default OFF (use legacy v1 path).
|
|
static inline int hak_pool_v2_enabled(void) {
|
|
#if HAKMEM_FAST_PROFILE_PRUNE_BACKENDS
|
|
// Phase 64: Backend pruning - disable POOL_V2 in Mixed workload
|
|
// Compile-time constant for DCE (unreachable code elimination)
|
|
return 0;
|
|
#else
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_POOL_V2_ENABLED");
|
|
g = (e && *e && *e != '0') ? 1 : 0;
|
|
}
|
|
return g;
|
|
#endif
|
|
}
|
|
|
|
// Fine-grained switches (only used when v2 is enabled).
|
|
static inline int hak_pool_v2_block_to_user_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_POOL_V2_BLOCK_TO_USER");
|
|
g = (e && *e && *e != '0') ? 1 : 0;
|
|
if (g == -1) g = 1;
|
|
}
|
|
return g;
|
|
}
|
|
|
|
static inline int hak_pool_v2_tls_fast_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_POOL_V2_TLS_FAST_PATH");
|
|
g = (e && *e && *e != '0') ? 1 : 0;
|
|
if (g == -1) g = 1;
|
|
}
|
|
return g;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Pool v1 Configuration
|
|
// ============================================================================
|
|
|
|
// Pool v1 flatten (hot path only) is experimental and opt-in.
|
|
static inline int hak_pool_v1_flatten_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
// C7_SAFE/C7_ULTRA_BENCH プロファイルでは、安全側で強制 OFF
|
|
int mode = tiny_heap_profile_mode();
|
|
if (mode == TINY_HEAP_PROFILE_C7_SAFE || mode == TINY_HEAP_PROFILE_C7_ULTRA_BENCH) {
|
|
g = 0;
|
|
return g;
|
|
}
|
|
const char* e = getenv("HAKMEM_POOL_V1_FLATTEN_ENABLED");
|
|
g = (e && *e && *e != '0') ? 1 : 0;
|
|
}
|
|
return g;
|
|
}
|
|
|
|
// Phase POOL-FREE-V1-OPT Step 2: Fast/Slow split for v1 free
|
|
// When enabled, same-thread TLS free skips mid_desc_lookup (1回→0回)
|
|
// Requires g_hdr_light_enabled == 0 for header-based owner_tid
|
|
// Default OFF for safety
|
|
static inline int hak_pool_v1_free_fastsplit_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_POOL_V1_FREE_FASTSPLIT");
|
|
g = (e && *e == '1') ? 1 : 0; // default OFF
|
|
}
|
|
return g;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Statistics & Monitoring Configuration
|
|
// ============================================================================
|
|
|
|
static inline int hak_pool_v1_flatten_stats_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_POOL_V1_FLATTEN_STATS");
|
|
g = (e && *e && *e != '0') ? 1 : 0;
|
|
}
|
|
return g;
|
|
}
|
|
|
|
// Phase POOL-FREE-V1-OPT Step 1: Reject reason stats
|
|
// Tracks why hak_pool_free_fast_v2_impl rejected (fell through to v1)
|
|
static inline int hak_pool_free_v1_reject_stats_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_POOL_FREE_V1_REJECT_STATS");
|
|
g = (e && *e == '1') ? 1 : 0; // default OFF
|
|
}
|
|
return g;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Caching Configuration
|
|
// ============================================================================
|
|
|
|
// Mid desc lookup TLS cache (mid bench opt-in; default OFF)
|
|
static inline int hak_mid_desc_cache_enabled(void) {
|
|
static int g = -1;
|
|
if (__builtin_expect(g == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_MID_DESC_CACHE_ENABLED");
|
|
g = (e && *e && *e != '0') ? 1 : 0;
|
|
}
|
|
return g;
|
|
}
|
|
|
|
#endif // POOL_CONFIG_BOX_H
|