Explicitly guard SuperSlab validation with #if !HAKMEM_BUILD_RELEASE
to document that this code is debug-only.
Changes:
- core/tiny_region_id.h: Add #if !HAKMEM_BUILD_RELEASE guard around
hak_super_lookup() validation code (lines 199-239)
- Improves code readability: Makes debug-only intent explicit
- Self-documenting: No need to check Makefile to understand behavior
- Defensive: Works correctly even if LTO is disabled
Performance Impact:
- Measured: +1.67% (bench_random_mixed), +1.33% (bench_mid_mt_gap)
- Expected: +12-15% (based on initial perf interpretation)
- Actual: NO measurable improvement (within noise margin ±3.6%)
Root Cause (Investigation):
- Compiler (LTO) already eliminated hak_super_lookup() automatically
- The function never existed in compiled binary (verified via nm/objdump)
- Default Makefile has -DHAKMEM_BUILD_RELEASE=1 + -flto
- perf's "15.84% CPU" was misattributed (was free(), not hak_super_lookup)
Conclusion:
This change provides NO performance benefit, but IMPROVES code clarity
by making the debug-only nature explicit rather than relying on
implicit compiler optimization.
Files:
- core/tiny_region_id.h - Add explicit debug guard
- PHASE6A_DISCREPANCY_INVESTIGATION.md - Full investigation report
Lessons Learned:
1. Always verify assembly output before claiming optimizations
2. perf attribution can be misleading - cross-reference with symbols
3. LTO is extremely aggressive at dead code elimination
4. Small improvements (<2× stdev) need statistical validation
See PHASE6A_DISCREPANCY_INVESTIGATION.md for complete analysis.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>