Phase 1 完了:環境変数整理 + fprintf デバッグガード ENV変数削除(BG/HotMag系): - core/hakmem_tiny_init.inc: HotMag ENV 削除 (~131 lines) - core/hakmem_tiny_bg_spill.c: BG spill ENV 削除 - core/tiny_refill.h: BG remote 固定値化 - core/hakmem_tiny_slow.inc: BG refs 削除 fprintf Debug Guards (#if !HAKMEM_BUILD_RELEASE): - core/hakmem_shared_pool.c: Lock stats (~18 fprintf) - core/page_arena.c: Init/Shutdown/Stats (~27 fprintf) - core/hakmem.c: SIGSEGV init message ドキュメント整理: - 328 markdown files 削除(旧レポート・重複docs) 性能確認: - Larson: 52.35M ops/s (前回52.8M、安定動作✅) - ENV整理による機能影響なし - Debug出力は一部残存(次phase で対応) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
2.9 KiB
Phase 6-3 Fast Path: Quick Fix Summary
Root Cause (TL;DR)
Fast Path implementation creates a double-layered allocation path that ALWAYS fails due to SuperSlab OOM:
Fast Path → tiny_fast_refill() → hak_tiny_alloc_slow() → OOM (NULL)
↓
Fallback → Box Refactor path → ALSO OOM → crash
Result: -20% regression (4.19M → 3.35M ops/s) + 45 GB memory leak
3 Fix Options (Ranked)
⭐⭐⭐⭐⭐ Fix #1: Disable Fast Path (IMMEDIATE)
Time: 1 minute Confidence: 100% Target: 4.19M ops/s (restore baseline)
make clean
make BOX_REFACTOR_DEFAULT=1 TINY_FAST_PATH_DEFAULT=0 larson_hakmem
./larson_hakmem 10 8 128 1024 1 12345 4
Why this works: Reverts to proven Box Refactor path (Phase 6-2.2)
⭐⭐⭐⭐ Fix #2: Integrate Fast Path with Box Refactor (2-4 hours)
Confidence: 80% Target: 5.0-6.0M ops/s (20-40% improvement)
Change 1: Make tiny_fast_refill() use Box Refactor backend
// File: core/tiny_fastcache.c:tiny_fast_refill()
void* tiny_fast_refill(int class_idx) {
// OLD: void* ptr = hak_tiny_alloc_slow(size, class_idx); // OOM!
// NEW: Use proven Box Refactor path
void* ptr = hak_tiny_alloc(size); // ← This works!
// Rest of refill logic stays the same...
}
Change 2: Remove Fast Path from hak_alloc_at() (avoid double-layer)
// File: core/hakmem.c:hak_alloc_at()
// Comment out lines 682-697 (Fast Path check)
// Keep ONLY in malloc() wrapper (lines 1294-1309)
Why this works:
- Box Refactor path is proven (4.19M ops/s)
- Fast Path gets actual cache refills
- Subsequent allocations hit 3-4 instruction fast path
- No OOM because Box Refactor handles allocation correctly
⭐⭐ Fix #3: Fix SuperSlab OOM (1-2 weeks)
Confidence: 60% Effort: High (deep architectural change)
Only needed if Fix #2 still has OOM issues. See full analysis for details.
Recommended Sequence
- Now: Run Fix #1 (restore baseline)
- Today: Implement Fix #2 (integrate with Box Refactor)
- Test: A/B compare Fix #1 vs Fix #2
- Decision:
- If Fix #2 > 4.5M ops/s → Ship it! ✅
- If Fix #2 still has OOM → Need Fix #3 (long-term)
Expected Outcomes
| Fix | Time | Score | Status |
|---|---|---|---|
| #1 (Disable) | 1 min | 4.19M ops/s | ✅ Safe baseline |
| #2 (Integrate) | 2-4 hrs | 5.0-6.0M ops/s | 🎯 Target |
| #3 (Root cause) | 1-2 weeks | Unknown | ⚠️ High risk |
Why Statistics Don't Show
HAKMEM_TINY_FAST_STATS=1 produces no output because:
- No shutdown hook -
tiny_fast_print_stats()never called - Thread-local counters - Lost when threads exit
- Early crash - OOM kills benchmark before stats printed
Fix: Add to hak_flush_tiny_exit() in hakmem.c:
// Line ~206
extern void tiny_fast_print_stats(void);
tiny_fast_print_stats();
Full analysis: PHASE6_3_REGRESSION_ULTRATHINK.md