Commit Graph

4 Commits

Author SHA1 Message Date
224cc8d1ca Docs: Phase FREE-LEGACY-OPT-4-4 completion summary + design notes
Phase 4-4 で C6 ULTRA free+alloc 統合(寄生型 TLS キャッシュ)が完了。
- Mixed 16-1024B: 40.2M → 42.3M ops/s (+5.2%)
- C6 legacy 完全排除: 137,319 → 0 (-100%)
- Legacy 半減: 266,942 → 129,623 (-51.4%)
- 次ターゲット: C5 (残存 Legacy の 53.1%)

設計メモを FREE_LEGACY_PATH_ANALYSIS.md に追記:
- Free-only TLS が失敗する理由
- Free+alloc 統合で成功する理由
- 寄生型 TLS キャッシュの設計原理
- C5/C4 への一般化可能性

次フェーズ候補を CURRENT_TASK.md に追記:
- 選択肢 1: C5 ULTRA への展開
- 選択肢 2: Tiny Alloc Hotpath 最適化
- 判断ポイント: stats 確認後に決定

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-11 19:11:44 +09:00
6eb78fa26c Docs: Phase FREE-LEGACY-OPT-4-4 analysis and results 2025-12-11 18:47:44 +09:00
1b196b3ac0 Phase FREE-LEGACY-OPT-4-2/4-3: C6 ULTRA-free TLS cache + segment learning
Phase 4-2:
- Add TinyC6UltraFreeTLS structure with 128-slot TLS freelist
- Implement tiny_c6_ultra_free_fast/slow for C6 free hot path
- Add c6_ultra_free_fast counter to FreePathStats
- ENV gate: HAKMEM_TINY_C6_ULTRA_FREE_ENABLED (default: OFF)

Phase 4-3:
- Add segment learning on first C6 free via ss_fast_lookup()
- Learn seg_base/seg_end from SuperSlab for range check
- Increase cache capacity from 32 to 128 blocks

Results:
- Segment learning works: fast path captures blocks in segment
- However, without alloc integration, cache fills up and overflows to legacy
- Net effect: +1-3% (within noise range)
- Drain strategy also tested: no benefit (equal overhead)

Conclusion:
- Free-only TLS cache is limited without alloc-side integration
- Core v6 already has alloc/free integrated TLS (but -12% slower)
- Keep as research box (ENV default OFF)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 18:34:27 +09:00
210633117a Phase FREE-LEGACY-OPT-4-1: Legacy per-class breakdown analysis
## 目的
Legacy fallback 49.2% の内訳を per-class で分析し、最も Legacy を使用しているクラスを特定。

## 実装内容

1. FreePathStats 構造体の拡張
   - legacy_by_class[8] フィールドを追加(C0-C7 の Legacy fallback 内訳)

2. デストラクタ出力の更新
   - [FREE_PATH_STATS_LEGACY_BY_CLASS] 行を追加し、C0-C7 の内訳を出力

3. カウンタの散布
   - free_tiny_fast() の Legacy fallback 経路で legacy_by_class[class_idx] をインクリメント
   - class_idx の範囲チェック(0-7)を実施

## 測定結果(Mixed 16-1024B)

**測定安定性**: 完全に安定(3 回とも同一の値、決定的測定)

Legacy per-class 内訳:
- C0: 0 (0.0%)
- C1: 0 (0.0%)
- C2: 8,746 (3.3% of legacy)
- C3: 17,279 (6.5% of legacy)
- C4: 34,727 (13.0% of legacy)
- C5: 68,871 (25.8% of legacy)
- C6: 137,319 (51.4% of legacy) ← 最大シェア
- C7: 0 (0.0%)

合計: 266,942 (49.2% of total free calls)

## 分析結果

**最大シェアクラス**: C6 (513-1024B) が Legacy の 51.4% を占める

**理由**:
- Mixed 16-1024B では C6 サイズのアロケーションが多い
- C7 ULTRA は C7 専用で C6 は未対応
- v3/v4 も C6 をカバーしていない
- Route 設定で C6 は Legacy に直接落ちている

## 次のアクション

Phase FREE-LEGACY-OPT-4-2 で C6 クラスに ULTRA-Free lane を実装:
- Legacy fallback を 51% 削減(C6 分)
- Legacy: 49.2% → 24-27% に改善(半減)
- Mixed 16-1024B: 44.8M → 47-48M ops/s 程度(+5-8% 改善)

## 変更ファイル

- core/box/free_path_stats_box.h: FreePathStats 構造体に legacy_by_class[8] 追加
- core/box/free_path_stats_box.c: デストラクタに per-class 出力追加
- core/front/malloc_tiny_fast.h: Legacy fallback 経路に per-class カウンタ追加
- docs/analysis/FREE_LEGACY_PATH_ANALYSIS.md: Phase 4-1 分析結果を記録

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-11 18:04:14 +09:00