ENV cleanup: Add RELEASE guards to DEBUG ENV variables (14 vars)

Added compile-time guards (#if HAKMEM_BUILD_RELEASE) to eliminate
DEBUG ENV variable overhead in RELEASE builds.

Variables guarded (14 total):
- HAKMEM_TINY_TRACE_RING, HAKMEM_TINY_DUMP_RING_ATEXIT
- HAKMEM_TINY_RF_TRACE, HAKMEM_TINY_MAILBOX_TRACE
- HAKMEM_TINY_MAILBOX_TRACE_LIMIT, HAKMEM_TINY_MAILBOX_SLOWDISC
- HAKMEM_TINY_MAILBOX_SLOWDISC_PERIOD
- HAKMEM_SS_PREWARM_DEBUG, HAKMEM_SS_FREE_DEBUG
- HAKMEM_TINY_FRONT_METRICS, HAKMEM_TINY_FRONT_DUMP
- HAKMEM_TINY_COUNTERS_DUMP, HAKMEM_TINY_REFILL_DUMP
- HAKMEM_PTR_TRACE_DUMP, HAKMEM_PTR_TRACE_VERBOSE

Files modified (9 core files):
- core/tiny_debug_ring.c (ring trace/dump)
- core/box/mailbox_box.c (mailbox trace + slowdisc)
- core/tiny_refill.h (refill trace)
- core/hakmem_tiny_superslab.c (superslab debug)
- core/box/ss_allocation_box.c (allocation debug)
- core/tiny_superslab_free.inc.h (free debug)
- core/box/front_metrics_box.c (frontend metrics)
- core/hakmem_tiny_stats.c (stats dump)
- core/ptr_trace.h (pointer trace)

Bug fixes during implementation:
1. mailbox_box.c - Fixed variable scope (moved 'used' outside guard)
2. hakmem_tiny_stats.c - Fixed incomplete declarations (on1, on2)

Impact:
- Binary size: -85KB total
  - bench_random_mixed_hakmem: 319K → 305K (-14K, -4.4%)
  - larson_hakmem: 380K → 309K (-71K, -18.7%)
- Performance: No regression (16.9-17.9M ops/s maintained)
- Functional: All tests pass (Random Mixed + Larson)
- Behavior: DEBUG ENV vars correctly ignored in RELEASE builds

Testing:
- Build: Clean compilation (warnings only, pre-existing)
- 100K Random Mixed: 16.9-17.9M ops/s (PASS)
- 10K Larson: 25.9M ops/s (PASS)
- DEBUG ENV verification: Correctly ignored (PASS)

Result: 14 DEBUG ENV variables now have zero overhead in RELEASE builds.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-11-27 03:41:07 +09:00
parent 543abb0586
commit 43015725af
11 changed files with 98 additions and 7 deletions

View File

@ -36,8 +36,12 @@ extern unsigned long long g_front_sll_hit[TINY_NUM_CLASSES];
int front_metrics_enabled(void) { int front_metrics_enabled(void) {
static int g_enabled = -1; static int g_enabled = -1;
if (__builtin_expect(g_enabled == -1, 0)) { if (__builtin_expect(g_enabled == -1, 0)) {
#if HAKMEM_BUILD_RELEASE
g_enabled = 0;
#else
const char* env = getenv("HAKMEM_TINY_FRONT_METRICS"); const char* env = getenv("HAKMEM_TINY_FRONT_METRICS");
g_enabled = (env && *env && *env != '0') ? 1 : 0; g_enabled = (env && *env && *env != '0') ? 1 : 0;
#endif
} }
return g_enabled; return g_enabled;
} }
@ -51,10 +55,16 @@ void hak_tiny_front_metrics_dump(void) {
return; return;
} }
const char* dump_env = getenv("HAKMEM_TINY_FRONT_DUMP"); const char* dump_env =
#if HAKMEM_BUILD_RELEASE
NULL;
if (1) { return; }
#else
getenv("HAKMEM_TINY_FRONT_DUMP");
if (!(dump_env && *dump_env && *dump_env != '0')) { if (!(dump_env && *dump_env && *dump_env != '0')) {
return; return;
} }
#endif
fprintf(stderr, "\n========== Box FrontMetrics: Layer Hit Rates ==========\n"); fprintf(stderr, "\n========== Box FrontMetrics: Layer Hit Rates ==========\n");
fprintf(stderr, "Purpose: Identify which frontend layers are doing real work\n"); fprintf(stderr, "Purpose: Identify which frontend layers are doing real work\n");

View File

@ -56,11 +56,15 @@ void mailbox_box_register(int class_idx) {
if (g_tls_mailbox_registered[class_idx]) return; if (g_tls_mailbox_registered[class_idx]) return;
g_mailbox_register_calls[class_idx]++; g_mailbox_register_calls[class_idx]++;
// One-shot visibility trace (env: HAKMEM_TINY_RF_TRACE) // One-shot visibility trace (env: HAKMEM_TINY_RF_TRACE)
#if HAKMEM_BUILD_RELEASE
static const int trace_en = 0;
#else
static int trace_en = -1; static int trace_en = -1;
if (__builtin_expect(trace_en == -1, 0)) { if (__builtin_expect(trace_en == -1, 0)) {
const char* e = getenv("HAKMEM_TINY_RF_TRACE"); const char* e = getenv("HAKMEM_TINY_RF_TRACE");
trace_en = (e && atoi(e) != 0) ? 1 : 0; trace_en = (e && atoi(e) != 0) ? 1 : 0;
} }
#endif
pthread_once(&g_mailbox_tls_once, mailbox_tls_init); pthread_once(&g_mailbox_tls_once, mailbox_tls_init);
pthread_setspecific(g_mailbox_tls_key, (void*)1); pthread_setspecific(g_mailbox_tls_key, (void*)1);
@ -125,6 +129,10 @@ void mailbox_box_publish(int class_idx, SuperSlab* ss, int slab_idx) {
uintptr_t mailbox_box_peek_one(int class_idx) { uintptr_t mailbox_box_peek_one(int class_idx) {
// Optional slow-discovery (triage only) to expand used when >0 // Optional slow-discovery (triage only) to expand used when >0
int slow_en, period; int slow_en, period;
#if HAKMEM_BUILD_RELEASE
slow_en = 0;
period = 0;
#else
if (__builtin_expect(g_mailbox_slowdisc_en == -1, 0)) { if (__builtin_expect(g_mailbox_slowdisc_en == -1, 0)) {
const char* e = getenv("HAKMEM_TINY_MAILBOX_SLOWDISC"); const char* e = getenv("HAKMEM_TINY_MAILBOX_SLOWDISC");
g_mailbox_slowdisc_en = (!e || atoi(e) != 0) ? 1 : 0; // default ON g_mailbox_slowdisc_en = (!e || atoi(e) != 0) ? 1 : 0; // default ON
@ -147,6 +155,7 @@ uintptr_t mailbox_box_peek_one(int class_idx) {
} }
} }
} }
#endif
// Non-destructive peek of first non-zero entry // Non-destructive peek of first non-zero entry
uint32_t used = atomic_load_explicit(&g_pub_mailbox_used[class_idx], memory_order_acquire); uint32_t used = atomic_load_explicit(&g_pub_mailbox_used[class_idx], memory_order_acquire);
@ -158,6 +167,11 @@ uintptr_t mailbox_box_peek_one(int class_idx) {
} }
uintptr_t mailbox_box_fetch(int class_idx) { uintptr_t mailbox_box_fetch(int class_idx) {
#if HAKMEM_BUILD_RELEASE
if (__builtin_expect(g_mailbox_trace_en == -1, 0)) g_mailbox_trace_en = 0;
if (__builtin_expect(g_mailbox_slowdisc_en == -1, 0)) g_mailbox_slowdisc_en = 0;
if (__builtin_expect(g_mailbox_slowdisc_period == -1, 0)) g_mailbox_slowdisc_period = 256;
#else
if (__builtin_expect(g_mailbox_trace_en == -1, 0)) { if (__builtin_expect(g_mailbox_trace_en == -1, 0)) {
const char* e = getenv("HAKMEM_TINY_MAILBOX_TRACE"); const char* e = getenv("HAKMEM_TINY_MAILBOX_TRACE");
g_mailbox_trace_en = (e && atoi(e) != 0) ? 1 : 0; g_mailbox_trace_en = (e && atoi(e) != 0) ? 1 : 0;
@ -166,7 +180,6 @@ uintptr_t mailbox_box_fetch(int class_idx) {
if (v > 0) g_mailbox_trace_limit = v; if (v > 0) g_mailbox_trace_limit = v;
} }
uint32_t used = atomic_load_explicit(&g_pub_mailbox_used[class_idx], memory_order_acquire);
// Optional slow discovery // Optional slow discovery
if (__builtin_expect(g_mailbox_slowdisc_en == -1, 0)) { if (__builtin_expect(g_mailbox_slowdisc_en == -1, 0)) {
const char* e = getenv("HAKMEM_TINY_MAILBOX_SLOWDISC"); const char* e = getenv("HAKMEM_TINY_MAILBOX_SLOWDISC");
@ -176,6 +189,9 @@ uintptr_t mailbox_box_fetch(int class_idx) {
const char* p = getenv("HAKMEM_TINY_MAILBOX_SLOWDISC_PERIOD"); const char* p = getenv("HAKMEM_TINY_MAILBOX_SLOWDISC_PERIOD");
int v = p ? atoi(p) : 256; g_mailbox_slowdisc_period = v; int v = p ? atoi(p) : 256; g_mailbox_slowdisc_period = v;
} }
#endif
uint32_t used = atomic_load_explicit(&g_pub_mailbox_used[class_idx], memory_order_acquire);
if (g_mailbox_slowdisc_en && used < MAILBOX_SHARDS) { if (g_mailbox_slowdisc_en && used < MAILBOX_SHARDS) {
uint32_t t = ++g_mailbox_fetch_tick[class_idx]; uint32_t t = ++g_mailbox_fetch_tick[class_idx];
int period = g_mailbox_slowdisc_period; int period = g_mailbox_slowdisc_period;

View File

@ -177,10 +177,14 @@ SuperSlab* superslab_allocate(uint8_t size_class) {
// Debug logging flag (lazy init) // Debug logging flag (lazy init)
static __thread int dbg = -1; static __thread int dbg = -1;
#if HAKMEM_BUILD_RELEASE
dbg = 0;
#else
if (__builtin_expect(dbg == -1, 0)) { if (__builtin_expect(dbg == -1, 0)) {
const char* e = getenv("HAKMEM_SS_PREWARM_DEBUG"); const char* e = getenv("HAKMEM_SS_PREWARM_DEBUG");
dbg = (e && *e && *e != '0') ? 1 : 0; dbg = (e && *e && *e != '0') ? 1 : 0;
} }
#endif
// Phase 9: Try LRU cache first (lazy deallocation) // Phase 9: Try LRU cache first (lazy deallocation)
SuperSlab* cached_ss = hak_ss_lru_pop(size_class); SuperSlab* cached_ss = hak_ss_lru_pop(size_class);
@ -296,10 +300,14 @@ void superslab_free(SuperSlab* ss) {
// ADD DEBUG LOGGING // ADD DEBUG LOGGING
static __thread int dbg = -1; static __thread int dbg = -1;
#if HAKMEM_BUILD_RELEASE
dbg = 0;
#else
if (__builtin_expect(dbg == -1, 0)) { if (__builtin_expect(dbg == -1, 0)) {
const char* e = getenv("HAKMEM_SS_FREE_DEBUG"); const char* e = getenv("HAKMEM_SS_FREE_DEBUG");
dbg = (e && *e && *e != '0') ? 1 : 0; dbg = (e && *e && *e != '0') ? 1 : 0;
} }
#endif
if (dbg == 1) { if (dbg == 1) {
fprintf(stderr, "[SS_FREE] CALLED: ss=%p lg_size=%d active_slabs=%u\n", fprintf(stderr, "[SS_FREE] CALLED: ss=%p lg_size=%d active_slabs=%u\n",
(void*)ss, ss->lg_size, ss->active_slabs); (void*)ss, ss->lg_size, ss->active_slabs);

View File

@ -237,8 +237,14 @@ void hak_tiny_path_debug_dump(void) {
// Debug print for extended counters (slow/bin/bump/spec) // Debug print for extended counters (slow/bin/bump/spec)
void hak_tiny_debug_counters_dump(void) { void hak_tiny_debug_counters_dump(void) {
#if HAKMEM_DEBUG_COUNTERS #if HAKMEM_DEBUG_COUNTERS
const char* on = getenv("HAKMEM_TINY_COUNTERS_DUMP"); const char* on =
#if HAKMEM_BUILD_RELEASE
NULL;
if (1) return;
#else
getenv("HAKMEM_TINY_COUNTERS_DUMP");
if (!(on && atoi(on) != 0)) return; if (!(on && atoi(on) != 0)) return;
#endif
// NOTE: Extended counters (alloc_slow, bitmap_scans, etc.) are currently not tracked // NOTE: Extended counters (alloc_slow, bitmap_scans, etc.) are currently not tracked
// Uncomment when these variables are implemented // Uncomment when these variables are implemented
@ -561,9 +567,13 @@ void hak_tiny_debug_counters_dump(void) {
// Always-available: Refill stage counters dump (env: HAKMEM_TINY_REFILL_DUMP=1 or reuse HAKMEM_TINY_COUNTERS_DUMP) // Always-available: Refill stage counters dump (env: HAKMEM_TINY_REFILL_DUMP=1 or reuse HAKMEM_TINY_COUNTERS_DUMP)
static void hak_tiny_refill_counters_dump(void) { static void hak_tiny_refill_counters_dump(void) {
hak_tiny_stats_init_flags(); hak_tiny_stats_init_flags();
#if HAKMEM_BUILD_RELEASE
if (1) return;
#else
const char* on1 = getenv("HAKMEM_TINY_REFILL_DUMP"); const char* on1 = getenv("HAKMEM_TINY_REFILL_DUMP");
const char* on2 = getenv("HAKMEM_TINY_COUNTERS_DUMP"); const char* on2 = getenv("HAKMEM_TINY_COUNTERS_DUMP");
if (!((on1 && atoi(on1)!=0) || (on2 && atoi(on2)!=0))) return; if (!((on1 && atoi(on1)!=0) || (on2 && atoi(on2)!=0))) return;
#endif
extern unsigned long long g_rf_total_calls[]; extern unsigned long long g_rf_total_calls[];
extern unsigned long long g_rf_hit_bench[]; extern unsigned long long g_rf_hit_bench[];
extern unsigned long long g_rf_hit_hot[]; extern unsigned long long g_rf_hit_hot[];

View File

@ -797,10 +797,14 @@ SuperSlab* superslab_allocate(uint8_t size_class) {
// Debug logging flag (lazy init) // Debug logging flag (lazy init)
static __thread int dbg = -1; static __thread int dbg = -1;
#if HAKMEM_BUILD_RELEASE
dbg = 0;
#else
if (__builtin_expect(dbg == -1, 0)) { if (__builtin_expect(dbg == -1, 0)) {
const char* e = getenv("HAKMEM_SS_PREWARM_DEBUG"); const char* e = getenv("HAKMEM_SS_PREWARM_DEBUG");
dbg = (e && *e && *e != '0') ? 1 : 0; dbg = (e && *e && *e != '0') ? 1 : 0;
} }
#endif
// Phase 9: Try LRU cache first (lazy deallocation) // Phase 9: Try LRU cache first (lazy deallocation)
SuperSlab* cached_ss = hak_ss_lru_pop(size_class); SuperSlab* cached_ss = hak_ss_lru_pop(size_class);
@ -1089,10 +1093,14 @@ void superslab_free(SuperSlab* ss) {
// ADD DEBUG LOGGING // ADD DEBUG LOGGING
static __thread int dbg = -1; static __thread int dbg = -1;
#if HAKMEM_BUILD_RELEASE
dbg = 0;
#else
if (__builtin_expect(dbg == -1, 0)) { if (__builtin_expect(dbg == -1, 0)) {
const char* e = getenv("HAKMEM_SS_FREE_DEBUG"); const char* e = getenv("HAKMEM_SS_FREE_DEBUG");
dbg = (e && *e && *e != '0') ? 1 : 0; dbg = (e && *e && *e != '0') ? 1 : 0;
} }
#endif
if (dbg == 1) { if (dbg == 1) {
fprintf(stderr, "[SS_FREE] CALLED: ss=%p lg_size=%d active_slabs=%u\n", fprintf(stderr, "[SS_FREE] CALLED: ss=%p lg_size=%d active_slabs=%u\n",
(void*)ss, ss->lg_size, ss->active_slabs); (void*)ss, ss->lg_size, ss->active_slabs);

View File

@ -65,17 +65,25 @@ static inline void ptr_trace_dump(void) {
} }
static inline void ptr_trace_try_register_dump(void) { static inline void ptr_trace_try_register_dump(void) {
#if HAKMEM_BUILD_RELEASE
return;
#else
if (g_ptr_trace_dump_registered) return; if (g_ptr_trace_dump_registered) return;
g_ptr_trace_dump_registered = 1; g_ptr_trace_dump_registered = 1;
const char* env = getenv("HAKMEM_PTR_TRACE_DUMP"); const char* env = getenv("HAKMEM_PTR_TRACE_DUMP");
if (!(env && *env && *env != '0')) return; if (!(env && *env && *env != '0')) return;
atexit(ptr_trace_dump); atexit(ptr_trace_dump);
#endif
} }
// Immediate dump (Debug only) — static inline to avoid ODR/link conflicts under LTO // Immediate dump (Debug only) — static inline to avoid ODR/link conflicts under LTO
// Only dumps if HAKMEM_PTR_TRACE_VERBOSE=1 to avoid excessive output in debug builds // Only dumps if HAKMEM_PTR_TRACE_VERBOSE=1 to avoid excessive output in debug builds
#if HAKMEM_PTR_TRACE #if HAKMEM_PTR_TRACE
static inline void ptr_trace_dump_now(const char* reason) { static inline void ptr_trace_dump_now(const char* reason) {
#if HAKMEM_BUILD_RELEASE
(void)reason;
return;
#else
static int verbose_mode = -1; static int verbose_mode = -1;
if (verbose_mode == -1) { if (verbose_mode == -1) {
const char* env = getenv("HAKMEM_PTR_TRACE_VERBOSE"); const char* env = getenv("HAKMEM_PTR_TRACE_VERBOSE");
@ -91,6 +99,7 @@ static inline void ptr_trace_dump_now(const char* reason) {
fprintf(stderr, "[%3u] tag=%s cls=%d node=%p val=%p off=%zu\n", fprintf(stderr, "[%3u] tag=%s cls=%d node=%p val=%p off=%zu\n",
k, e->tag ? e->tag : "?", e->class_idx, e->node, e->val, e->off); k, e->tag ? e->tag : "?", e->class_idx, e->node, e->val, e->off);
} }
#endif
} }
#else #else
static inline void ptr_trace_dump_now(const char* reason) { (void)reason; } static inline void ptr_trace_dump_now(const char* reason) { (void)reason; }

View File

@ -191,6 +191,9 @@ static void tiny_debug_ring_sigusr(int signo, siginfo_t* info, void* uctx) {
} }
void tiny_debug_ring_init(void) { void tiny_debug_ring_init(void) {
#if HAKMEM_BUILD_RELEASE
return; // No env reads or hooks in release builds
#endif
if (g_tiny_ring_enabled) return; if (g_tiny_ring_enabled) return;
const char* env = getenv("HAKMEM_TINY_TRACE_RING"); const char* env = getenv("HAKMEM_TINY_TRACE_RING");
if (!(env && *env && env[0] != '0')) { if (!(env && *env && env[0] != '0')) {
@ -228,6 +231,9 @@ static void tiny_debug_ring_ctor(void) {
__attribute__((destructor)) __attribute__((destructor))
static void tiny_debug_ring_dtor(void) { static void tiny_debug_ring_dtor(void) {
#if HAKMEM_BUILD_RELEASE
return; // Skip env access in release builds
#endif
const char* e = getenv("HAKMEM_TINY_DUMP_RING_ATEXIT"); const char* e = getenv("HAKMEM_TINY_DUMP_RING_ATEXIT");
if (e && *e && e[0] != '0') { if (e && *e && e[0] != '0') {
tiny_debug_ring_dump(STDERR_FILENO, 0); tiny_debug_ring_dump(STDERR_FILENO, 0);

View File

@ -86,7 +86,8 @@ static inline SuperSlab* tiny_refill_try_fast(int class_idx, TinyTLSSlab* tls) {
} }
} }
} }
// One-shot entry trace (env: HAKMEM_TINY_RF_TRACE) // One-shot entry trace (env: HAKMEM_TINY_RF_TRACE), disabled in release builds
#if !HAKMEM_BUILD_RELEASE
do { do {
static int en = -1; static _Atomic int printed[8]; static int en = -1; static _Atomic int printed[8];
if (__builtin_expect(en == -1, 0)) { if (__builtin_expect(en == -1, 0)) {
@ -101,6 +102,7 @@ static inline SuperSlab* tiny_refill_try_fast(int class_idx, TinyTLSSlab* tls) {
} }
} }
} while (0); } while (0);
#endif
// For hot tiny classes (0..3), try mailbox first to avoid deeper scans // For hot tiny classes (0..3), try mailbox first to avoid deeper scans
if (class_idx <= 3) { if (class_idx <= 3) {
uint32_t self_tid = tiny_self_u32(); uint32_t self_tid = tiny_self_u32();

View File

@ -225,10 +225,14 @@ static inline void hak_tiny_free_superslab(void* ptr, SuperSlab* ss) {
#include "box/free_local_box.h" #include "box/free_local_box.h"
// DEBUG LOGGING - Track freelist operations // DEBUG LOGGING - Track freelist operations
static __thread int dbg = -1; static __thread int dbg = -1;
#if HAKMEM_BUILD_RELEASE
dbg = 0;
#else
if (__builtin_expect(dbg == -1, 0)) { if (__builtin_expect(dbg == -1, 0)) {
const char* e = getenv("HAKMEM_SS_FREE_DEBUG"); const char* e = getenv("HAKMEM_SS_FREE_DEBUG");
dbg = (e && *e && *e != '0') ? 1 : 0; dbg = (e && *e && *e != '0') ? 1 : 0;
} }
#endif
static __thread int free_count = 0; static __thread int free_count = 0;
if (dbg == 1 && (free_count++ % 1000) == 0) { if (dbg == 1 && (free_count++ % 1000) == 0) {
fprintf(stderr, "[FREE_LOCAL] cls=%u slab=%d meta->used=%u (before dec)\n", fprintf(stderr, "[FREE_LOCAL] cls=%u slab=%d meta->used=%u (before dec)\n",
@ -262,10 +266,14 @@ static inline void hak_tiny_free_superslab(void* ptr, SuperSlab* ss) {
if (meta->used == 0) { if (meta->used == 0) {
// DEBUG LOGGING // DEBUG LOGGING
static __thread int dbg = -1; static __thread int dbg = -1;
#if HAKMEM_BUILD_RELEASE
dbg = 0;
#else
if (__builtin_expect(dbg == -1, 0)) { if (__builtin_expect(dbg == -1, 0)) {
const char* e = getenv("HAKMEM_SS_FREE_DEBUG"); const char* e = getenv("HAKMEM_SS_FREE_DEBUG");
dbg = (e && *e && *e != '0') ? 1 : 0; dbg = (e && *e && *e != '0') ? 1 : 0;
} }
#endif
if (dbg == 1) { if (dbg == 1) {
fprintf(stderr, "[FREE_PATH] meta->used=0 detected: cls=%u ss=%p slab_idx=%d\n", fprintf(stderr, "[FREE_PATH] meta->used=0 detected: cls=%u ss=%p slab_idx=%d\n",
cls, (void*)ss, slab_idx); cls, (void*)ss, slab_idx);

View File

@ -49,6 +49,10 @@
- Doc-only list was confirmed with `rg` diff (`comm -23 docs_env code_env`); zero getenv hits. - Doc-only list was confirmed with `rg` diff (`comm -23 docs_env code_env`); zero getenv hits.
- Count drift (221 → ~279) comes from `.inc` helpers now included in the scan; keep 221 as the baseline metric but track the expanded map below. - Count drift (221 → ~279) comes from `.inc` helpers now included in the scan; keep 221 as the baseline metric but track the expanded map below.
## Completed in this session (release gating of debug env)
- Disabled getenv for debug/trace in release builds: `HAKMEM_TINY_TRACE_RING`, `HAKMEM_TINY_DUMP_RING_ATEXIT`, `HAKMEM_TINY_RF_TRACE`, `HAKMEM_TINY_MAILBOX_TRACE(_LIMIT/_SLOWDISC/_PERIOD)`, `HAKMEM_SS_PREWARM_DEBUG`, `HAKMEM_SS_FREE_DEBUG`, `HAKMEM_TINY_FRONT_METRICS`, `HAKMEM_TINY_FRONT_DUMP`, `HAKMEM_TINY_COUNTERS_DUMP`, `HAKMEM_TINY_REFILL_DUMP`, `HAKMEM_PTR_TRACE_DUMP`, `HAKMEM_PTR_TRACE_VERBOSE`.
- SFC_DEBUG getenv consolidated to init boundary (`g_sfc_debug`).
## Appendix: Complete getenv() map (sorted by path) ## Appendix: Complete getenv() map (sorted by path)
``` ```
core/box/ace_pool_connector.c:30: const char* ace_env = getenv("HAKMEM_ACE_ENABLED"); core/box/ace_pool_connector.c:30: const char* ace_env = getenv("HAKMEM_ACE_ENABLED");

View File

@ -24,10 +24,20 @@
- **BG system**: `HAKMEM_BATCH_BG`, `HAKMEM_L25_BG_DRAIN`, `HAKMEM_L25_BG_MS` — enabled by default; removal would change behavior. - **BG system**: `HAKMEM_BATCH_BG`, `HAKMEM_L25_BG_DRAIN`, `HAKMEM_L25_BG_MS` — enabled by default; removal would change behavior.
- **HeapV2/FrontV2**: `HAKMEM_TINY_HEAP_V2_*`, `HAKMEM_TINY_FRONT_V2/SLIM/DIRECT/METRICS/DUMP` — active path for tiny frontend; keep. - **HeapV2/FrontV2**: `HAKMEM_TINY_HEAP_V2_*`, `HAKMEM_TINY_FRONT_V2/SLIM/DIRECT/METRICS/DUMP` — active path for tiny frontend; keep.
## 最新アクション(このセッション)
- `HAKMEM_SFC_DEBUG` を init 1回読みへ集約ホットパス getenv を排除)。
- リリースビルドで以下の DEBUG/TRACE/STATS 系 ENV を無効化getenv しない):
- `HAKMEM_TINY_TRACE_RING`, `HAKMEM_TINY_DUMP_RING_ATEXIT`
- `HAKMEM_TINY_RF_TRACE`, `HAKMEM_TINY_MAILBOX_TRACE`, `HAKMEM_TINY_MAILBOX_TRACE_LIMIT`, `HAKMEM_TINY_MAILBOX_SLOWDISC(_PERIOD)`
- `HAKMEM_SS_PREWARM_DEBUG`, `HAKMEM_SS_FREE_DEBUG`
- `HAKMEM_TINY_FRONT_METRICS`, `HAKMEM_TINY_FRONT_DUMP`
- `HAKMEM_TINY_COUNTERS_DUMP`, `HAKMEM_TINY_REFILL_DUMP`
- `HAKMEM_PTR_TRACE_DUMP`, `HAKMEM_PTR_TRACE_VERBOSE`
## Next Steps ## Next Steps
1) Implement `HAKMEM_SFC_DEBUG` consolidation (init boundary only). 1) 残る DEBUG/TRACE/STATS 系 ENV を同様にリリースビルドで無効化 or init 1回読みへ移動。
2) Sweep docs to drop the 21 docs-only variables (no code changes). 2) 21個のドキュメント専用変数を `docs/specs/ENV_VARS*.md` から削除。
3) Maintain A/B gates for Ultra/BG/HeapV2; any deprecation must be feature-flagged with rollback. 3) Ultra/BG/HeapV2 は現役のため A/B ゲートを維持したまま、削除は別フェーズで判断。
See `ENV_CLEANUP_PLAN.md` for the full getenv map (file+line) and `ENV_CONSOLIDATION_PLAN.md` for the long-term policy reduction (149 → ~30). See `ENV_CLEANUP_PLAN.md` for the full getenv map (file+line) and `ENV_CONSOLIDATION_PLAN.md` for the long-term policy reduction (149 → ~30).