Document ENV Cleanup Phase 4a completion (20 variables total)

Phase 4a: Hot Path getenv Caching - COMPLETED
- All getenv() calls in hot paths verified as properly cached
- Key fix: hakmem_elo.c (10+ loop calls → cached is_quiet())
- Verified correct caching in 7 other critical files

Added ENV_VARIABLE_SURVEY.md:
- Comprehensive survey of 228 ENV variables
- Category breakdown and consolidation recommendations
- Target: ~80 variables (65% reduction)

Updated docs/specs/ENV_VARS.md:
- Added ENV Cleanup Progress section
- Documented Phase 4a findings
- Outlined Phase 4b+ future work (HAKMEM_DEBUG/TRACE/STATS unified vars)

🤖 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-28 15:29:16 +09:00
parent bf02ffca5a
commit eec33ca37d
2 changed files with 862 additions and 0 deletions

View File

@ -300,3 +300,43 @@ LD safety (for apps/LD_PRELOAD runs)
- HAKMEM_TINY_BENCH_MODE=1
- ベンチ専用の簡素化採用パスを有効化。per-class 単一点の公開スロットを使用し、superslab_refill のスキャンと多段リング走査を回避。
- OOMガードharvest/trimは保持。A/B用途に限定してください。
---
ENV Cleanup Progress (2025-11)
==============================
Phase 4a: Hot Path getenv Caching
---------------------------------
COMPLETED: All getenv() calls in hot paths are now properly cached.
Fixed files:
- `core/hakmem_elo.c` - Added `is_quiet()` helper with cached `g_quiet_mode` flag
- Was: 10+ getenv("HAKMEM_QUIET") calls inside loops
- Now: Single cached lookup at first call
Verified (already correct):
- `core/hakmem_tiny_superslab.c` - Uses `static int g_*` caching pattern
- `core/hakmem_shared_pool.c` - Uses `static int xxx = -1` caching
- `core/hakmem_learner.c` - getenv outside main loop (thread start only)
- `core/box/pool_init_api.inc.h` - Init function (called once via pthread_once)
- `core/box/hak_core_init.inc.h` - Init function (called once via pthread_once)
- `core/box/hak_wrappers.inc.h` - Uses `static int on=-1` caching
ENV Statistics (from ENV_VARIABLE_SURVEY.md):
- Total ENV variables: 228
- Target after cleanup: ~80 (65% reduction)
- Categories:
- Core/Toggle: 15 (7%)
- Learning/Adaptive: 25 (11%)
- Performance Tuning: 45 (20%)
- Debug/Diagnostic: 65 (28%) ← Consolidation target
- Superslab/Backend: 25 (11%)
- TLS SLL (P2/P3): 20 (9%)
- Free Path Optimization: 15 (7%)
- Other: 23 (10%)
Future Work (Phase 4b+):
- HAKMEM_DEBUG unified variable (consolidate 35 debug vars)
- HAKMEM_TRACE unified variable (consolidate 15 trace vars)
- HAKMEM_STATS unified variable (consolidate 15 dump vars)