Document performance improvements from 62M → 80M ops/s
Created comprehensive record of all optimization commits that led to 80M ops/s Random Mixed performance on master branch: - UNIFIED-HEADER (472b6a60b): +17% improvement - Bug fixes (d26519f67): +15-41% improvement - tiny_get_max_size inline (e81fe783d): +2M ops/s - Min-Keep policy (04a60c316): +1M ops/s - Unified Cache tuning (392d29018): +1M ops/s - Stage 1 lock-free (dcd89ee88): +0.3M ops/s - Shared Pool optimizations: +2-3M ops/s Also documents: - Step 2.5 bug (19c1abfe7) causing 100% Larson crash - Architecture differences (E1-CORRECT vs UNIFIED-HEADER) - Current state comparison between master and larson-master-rebuild - Three future options with trade-offs This documentation preserves knowledge of the 80M optimization path for future reference when larson-master-rebuild becomes new master. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
227
PERFORMANCE_HISTORY_62M_TO_80M.md
Normal file
227
PERFORMANCE_HISTORY_62M_TO_80M.md
Normal file
@ -0,0 +1,227 @@
|
||||
# Performance History: 62M → 80M ops/s (Random Mixed 256B)
|
||||
|
||||
**Date**: 2025-11-20 ~ 2025-11-24
|
||||
**Branch**: master (before Larson bug)
|
||||
**Baseline**: 62M ops/s (larson-fix @ 5c8567562)
|
||||
**Peak**: ~80M ops/s (master @ d26519f67)
|
||||
|
||||
---
|
||||
|
||||
## 主要な性能改善コミット
|
||||
|
||||
### 1. Phase UNIFIED-HEADER (+17%, 最大の改善)
|
||||
**Commit**: `472b6a60b` - Phase UNIFIED-HEADER: C7 header unification
|
||||
|
||||
**内容**:
|
||||
- C7 (1KB class) のヘッダーを他のクラス(C0-C6)と統一
|
||||
- Offset=1 に統一(C0/C7 は offset=0 から offset=1 へ変更)
|
||||
- Fast path の分岐を削減
|
||||
|
||||
**改善幅**: **+17%** (73% → 88% of System malloc)
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/box/ptr_conversion_box.h` - Pointer conversion unified
|
||||
- `core/tiny_nextptr.h` - Next pointer offset unified
|
||||
|
||||
---
|
||||
|
||||
### 2. UNIFIED-HEADER Bug Fixes (+15-41%)
|
||||
**Commit**: `d26519f67` - Fix Phase UNIFIED-HEADER critical bugs
|
||||
|
||||
**内容**:
|
||||
- UNIFIED-HEADER 実装のバグ修正
|
||||
- Header restoration の不具合修正
|
||||
- Alignment エラー解消
|
||||
|
||||
**改善幅**: **+15-41%** (ケースによる)
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/box/ptr_conversion_box.h` - Bug fixes
|
||||
- `core/tiny_region_id.h` - Header handling fixes
|
||||
|
||||
---
|
||||
|
||||
### 3. tiny_get_max_size Inline化 (+2M ops/s)
|
||||
**Commit**: `e81fe783d` - Optimize tiny_get_max_size inline
|
||||
|
||||
**内容**:
|
||||
- `tiny_get_max_size()` を header に移動して inline 化
|
||||
- Cached static variable で ENV lookup 削減
|
||||
|
||||
**改善幅**: **+2M ops/s**
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/hakmem_tiny.h` - Function moved to header
|
||||
- `core/hakmem_tiny_config_box.inc` - Simplified
|
||||
|
||||
---
|
||||
|
||||
### 4. Superslab Min-Keep Policy (+1M ops/s)
|
||||
**Commit**: `04a60c316` - Tune Superslab Min-Keep and Shared Pool Soft Caps
|
||||
|
||||
**内容**:
|
||||
- `tiny_min_keep` policy 導入(クラス別 Superslab reserve)
|
||||
- mmap/munmap churn 削減
|
||||
- Soft cap 緩和(C4-C6)
|
||||
|
||||
**改善幅**: **+1M ops/s**
|
||||
|
||||
**⚠️ 注意**: larson-master-rebuild では Larson クラッシュのため Revert 済み
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/hakmem_policy.c` - Min-Keep values
|
||||
- `core/hakmem_policy.h` - FrozenPolicy struct
|
||||
|
||||
---
|
||||
|
||||
### 5. Unified Cache Tuning (+1M ops/s)
|
||||
**Commit**: `392d29018` - Tune Unified Cache capacity/batch & Fix build deps
|
||||
|
||||
**内容**:
|
||||
- Unified Cache の容量調整
|
||||
- Batch size 最適化
|
||||
- Build dependency 修正
|
||||
|
||||
**改善幅**: **+1M ops/s**
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/front/tiny_unified_cache.h` - Capacity tuning
|
||||
- `core/front/tiny_unified_cache.c` - Batch size
|
||||
|
||||
---
|
||||
|
||||
### 6. Stage 1 Lock-Free (+0.3M ops/s)
|
||||
**Commit**: `dcd89ee88` - Stage 1 lock-free + Unified Cache stats
|
||||
|
||||
**内容**:
|
||||
- Stage 1 を lock-free 化
|
||||
- Unified Cache stats 追加
|
||||
- Stage 0.5 を default OFF
|
||||
|
||||
**改善幅**: **+0.3M ops/s**
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/hakmem_shared_pool.c` - Lock-free Stage 1
|
||||
|
||||
---
|
||||
|
||||
### 7. Shared Pool Optimizations
|
||||
**Commits**:
|
||||
- `d9c17ea77` - Preallocate Superslab outside alloc_lock
|
||||
- `590fe3e3f` - Enable L0 hot slot (ENV gated)
|
||||
- `5fe0b7762` - Cache slab per class
|
||||
|
||||
**内容**:
|
||||
- Shared Pool の Stage3 contention 削減
|
||||
- L0 hot slot キャッシュ
|
||||
- Per-class slab キャッシュ
|
||||
|
||||
**改善幅**: 累積で +2-3M ops/s (推定)
|
||||
|
||||
**関連ファイル**:
|
||||
- `core/hakmem_shared_pool.c` - Stage optimizations
|
||||
- `core/box/sp_*.inc` - Box refactoring
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ クリティカルバグ(Larson クラッシュ)
|
||||
|
||||
### Step 2.5 Bug
|
||||
**Commits**:
|
||||
- `19c1abfe7` - Fix Unified Cache TLS SLL bypass (⚠️ Larson クラッシュの原因)
|
||||
- `1a301c1a2` - Add header restoration for TLS SLL pop
|
||||
|
||||
**問題**:
|
||||
- Unified Cache refill 時に TLS SLL から pop する実装
|
||||
- Cross-thread TLS SLL corruption が発生
|
||||
- Larson benchmark で 100% クラッシュ
|
||||
|
||||
**影響**:
|
||||
- Random Mixed: 動作正常
|
||||
- Larson: `free(): invalid pointer` → Segmentation fault
|
||||
|
||||
**対処**:
|
||||
- larson-fix ブランチ (5c8567562) で Step 2.5 前の状態を保持
|
||||
- larson-master-rebuild で Step 2.5 を含まない stable 版を構築
|
||||
|
||||
**詳細**: `LEARNING_SYSTEM_BUGS_P0.md`
|
||||
|
||||
---
|
||||
|
||||
## 累積改善の内訳
|
||||
|
||||
| コミット | 内容 | 改善幅 | 累積 |
|
||||
|---------|------|--------|------|
|
||||
| Baseline | larson-fix | - | 62M ops/s |
|
||||
| 472b6a60b | UNIFIED-HEADER | **+17%** | ~72M ops/s |
|
||||
| d26519f67 | UH bug fixes | +15-41% | ~80M ops/s |
|
||||
| e81fe783d | Inline optimization | +2M | ~82M ops/s |
|
||||
| 04a60c316 | Min-Keep policy | +1M | ~83M ops/s |
|
||||
| 392d29018 | Cache tuning | +1M | ~84M ops/s |
|
||||
| dcd89ee88 | Lock-free | +0.3M | ~84.3M ops/s |
|
||||
| Shared Pool | Various | +2-3M | **~86M ops/s** (理論値) |
|
||||
|
||||
**⚠️ 注意**:
|
||||
- 80M ops/s 時点では Step 2.5 バグによりLarson クラッシュ
|
||||
- larson-master-rebuild (67M ops/s) は UNIFIED-HEADER を含まない安定版
|
||||
|
||||
---
|
||||
|
||||
## larson-master-rebuild の構成
|
||||
|
||||
**現在のブランチ**: `larson-master-rebuild` @ bea839add
|
||||
|
||||
**ポート済みコミット**:
|
||||
1. ✅ `e81fe783d` - tiny_get_max_size inline (+2M)
|
||||
2. ❌ `04a60c316` - Min-Keep policy (Revert済み、Larsonクラッシュ)
|
||||
3. ❌ `472b6a60b` - UNIFIED-HEADER (E1-CORRECTと互換性なし、未ポート)
|
||||
4. ❌ `d26519f67` - UH bug fixes (上記と同様)
|
||||
5. ❌ `392d29018` - Cache tuning (Conflict多数、未ポート)
|
||||
|
||||
**性能**:
|
||||
- Random Mixed: 66.82M ops/s (Baseline 62M比 +7.8%)
|
||||
- Larson: 51.95M ops/s (安定、0% クラッシュ)
|
||||
|
||||
**アーキテクチャ差異**:
|
||||
- master: UNIFIED-HEADER (C0-C7 offset=1)
|
||||
- larson-master-rebuild: E1-CORRECT (C0,C7 offset=0; C1-C6 offset=1)
|
||||
|
||||
---
|
||||
|
||||
## 次のステップ候補
|
||||
|
||||
### Option 1: larson-master-rebuild を新 master に(推奨)
|
||||
- ✅ 安定(Larson 動作)
|
||||
- ✅ 67M ops/s (Baseline比 +7.8%)
|
||||
- ❌ 80M には届かない
|
||||
|
||||
### Option 2: master で Step 2.5 を Revert(困難)
|
||||
- ✅ 80M ops/s 達成可能
|
||||
- ❌ Revert conflict が複雑(`unified_cache_refill()` 33行の変更)
|
||||
- ❌ 35+ 回の修正試行が失敗済み
|
||||
|
||||
### Option 3: UNIFIED-HEADER を larson にポート(時間かかる)
|
||||
- ✅ 80M ops/s 達成可能
|
||||
- ❌ E1-CORRECT との互換性問題
|
||||
- ❌ 大規模な書き換えが必要
|
||||
|
||||
---
|
||||
|
||||
## 関連ドキュメント
|
||||
|
||||
- `LEARNING_SYSTEM_BUGS_P0.md` - Step 2.5 バグ詳細
|
||||
- `CURRENT_TASK.md` - larson-master-rebuild 作業計画
|
||||
- `docs/status/CURRENT_TASK.md` - 最新タスク状況
|
||||
- `docs/specs/ENV_VARS.md` - 環境変数リファレンス
|
||||
|
||||
---
|
||||
|
||||
## まとめ
|
||||
|
||||
62M → 80M の改善は**UNIFIED-HEADER (+17%)** と **Bug fixes (+15-41%)** が主要因。
|
||||
|
||||
しかし、**Step 2.5 バグ**により Larson が 100% クラッシュするため、現時点では:
|
||||
- **Random Mixed のみ**: master (80M ops/s, Larson クラッシュ)
|
||||
- **Larson 含む**: larson-master-rebuild (67M ops/s, 安定)
|
||||
|
||||
の2つのブランチで運用するのが現実的。
|
||||
Reference in New Issue
Block a user