Files
hakmem/docs/analysis/ENV_CLEANUP_SUMMARY.md

34 lines
2.3 KiB
Markdown
Raw Normal View History

# ENV Variable Cleanup Analysis - Executive Summary
## Scope
- **Initial sweep:** 221 unique ENV variables across the runtime (getenv()).
- **Current view:** Core features Ultra/BG/HeapV2 are active and must be preserved (A/B gated only).
- **Docs-only cleanup:** 21 documentation-only variables (zero getenv hits) are tracked separately in `SAFE_TO_DELETE_ENV_VARS.md`.
## Key Findings
- **Active, keep**: Ultra path (`core/ultra/*`), BG spill (`hakmem_batch.c`, `hakmem_tiny_bg_spill.o`), HeapV2/FrontV2 (`core/front/tiny_heap_v2.h`, `tiny_alloc_fast.inc.h`) are compiled in and runtime-gated. Removing their ENV toggles would break A/B rollback.
- **SFC is live**: `hakmem_tiny_sfc.o` is built; `HAKMEM_SFC_ENABLE/CAPACITY/REFILL_COUNT/DEBUG/STATS_DUMP/CASCADE_PCT` all drive behavior. Debug getenv duplication remains the top low-risk cleanup.
- **Doc-only set**: 21 proposal-only ENV names (adaptive presets, generic debug knobs, legacy build flags) have no getenv calls; safe to drop from docs with zero runtime impact.
- **Count drift**: Including `.inc` helpers raises the current getenv surface to ~279 names; initial 221 figure is kept as the baseline for this projects first pass.
## Quick Wins (low risk, Box-friendly)
- **SFC_DEBUG dedup**: Move the four `HAKMEM_SFC_DEBUG` getenv calls behind one init-time flag (`hakmem_tiny_sfc.c` as the boundary). Reduces hot-path getenvs by 3.
- **Doc hygiene**: Remove the 21 docs-only names from `docs/specs/ENV_VARS*.md` to keep the supported surface visible and reversible.
## Items to Keep as-is (cannot delete)
- **Ultra toggles**: `HAKMEM_TINY_ULTRA_*`, `HAKMEM_ULTRA_SLIM_STATS` — gated experiments but compiled; keep for rollback.
- **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.
## Next Steps
1) Implement `HAKMEM_SFC_DEBUG` consolidation (init boundary only).
2) Sweep docs to drop the 21 docs-only variables (no code changes).
3) Maintain A/B gates for Ultra/BG/HeapV2; any deprecation must be feature-flagged with rollback.
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).