Files
hakmem/docs/analysis/SAFE_TO_DELETE_ENV_VARS.md
Moe Charm (CI) 543abb0586 ENV cleanup: Consolidate SFC_DEBUG getenv() calls (86% reduction)
Optimized HAKMEM_SFC_DEBUG environment variable handling by caching
the value at initialization instead of repeated getenv() calls in
hot paths.

Changes:
1. Added g_sfc_debug global variable (core/hakmem_tiny_sfc.c)
   - Initialized once in sfc_init() by reading HAKMEM_SFC_DEBUG
   - Single source of truth for SFC debug state

2. Declared g_sfc_debug as extern (core/hakmem_tiny_config.h)
   - Available to all modules that need SFC debug checks

3. Replaced getenv() with g_sfc_debug in hot paths:
   - core/tiny_alloc_fast_sfc.inc.h (allocation path)
   - core/tiny_free_fast.inc.h (free path)
   - core/box/hak_wrappers.inc.h (wrapper layer)

Impact:
- getenv() calls: 7 → 1 (86% reduction)
- Hot-path calls eliminated: 6 (all moved to init-time)
- Performance: 15.10M ops/s (stable, 0% CV)
- Build: Clean compilation, no new warnings

Testing:
- 10 runs of 100K iterations: consistent performance
- Symbol verification: g_sfc_debug present in hakmem_tiny_sfc.o
- No regression detected

Note: 3 additional getenv("HAKMEM_SFC_DEBUG") calls exist in
hakmem_tiny_ultra_simple.inc but are dead code (file not compiled
in current build configuration).

Files modified: 5 core files
Status: Production-ready, all tests passed

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 03:18:33 +09:00

1.8 KiB

ENV Variables Safe to Delete (Docs-Only, Already Off the Code Path)

Summary

  • 21 ENV variables live only in documentation; 0 getenv() hits across core/, include/, src/, and tools/.
  • These toggles were proposal placeholders; none of them ever crossed the runtime boundary.
  • Status: treated as removed from the supported surface; only lingering mentions remain in docs archives and can be dropped when touched.

Docs-Only Variables (21)

  • HAKMEM_ALLOC_LEARN
  • HAKMEM_ALLOC_LEARN_RATE
  • HAKMEM_ALLOC_LEARN_WINDOW
  • HAKMEM_BUILD_3LAYER
  • HAKMEM_BUILD_ROUTE
  • HAKMEM_DEBUG
  • HAKMEM_DEBUG_LEVEL
  • HAKMEM_DEBUG_TINY
  • HAKMEM_EXPERIMENTAL_ADAPTIVE_DRAIN
  • HAKMEM_EXPERIMENTAL_CACHE_TUNING
  • HAKMEM_FORCE_LIBC
  • HAKMEM_INTEGRITY_CHECKS
  • HAKMEM_LEARN_ADVANCED
  • HAKMEM_LEARN_DECAY
  • HAKMEM_MEM_LEARN
  • HAKMEM_MEM_LEARN_THRESHOLD
  • HAKMEM_MEM_LEARN_WINDOW
  • HAKMEM_PROFILE_SYSCALLS
  • HAKMEM_STATS_ENABLE
  • HAKMEM_STATS_INTERVAL_SEC
  • HAKMEM_STATS_VERBOSE

How We Verified

  1. rg 'getenv\\(\"HAKMEM_' core include src tools -n --sort path0 matches for all 21 names.
  2. comm -23 docs_env code_env diff to isolate documentation-only names.
  3. Spot-checked docs/specs/ENV_VARS*.md and related papers to ensure these are proposal artifacts, not active flags.
  • Remove these names from docs/specs/ENV_VARS.md, docs/specs/ENV_VARS_COMPLETE.md, and any status reports when you next touch them (no code changes needed).
  • Keep a single sentence in change logs noting that these toggles never existed in runtime code (A/B rollback not needed).

Notes

  • These were planning placeholders (adaptive tuning knobs, generic debug toggles, and early build-time experiments) that never materialized.
  • Keeping them in docs increases cognitive load; deleting them is a zero-risk, reversible documentation-only change.