Files
hakmem/docs/archive/PHASE_6.15_P1_BENCHMARK_RESULTS.md
Moe Charm (CI) 52386401b3 Debug Counters Implementation - Clean History
Major Features:
- Debug counter infrastructure for Refill Stage tracking
- Free Pipeline counters (ss_local, ss_remote, tls_sll)
- Diagnostic counters for early return analysis
- Unified larson.sh benchmark runner with profiles
- Phase 6-3 regression analysis documentation

Bug Fixes:
- Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB)
- Fix profile variable naming consistency
- Add .gitignore patterns for large files

Performance:
- Phase 6-3: 4.79 M ops/s (has OOM risk)
- With SuperSlab: 3.13 M ops/s (+19% improvement)

This is a clean repository without large log files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 12:31:14 +09:00

184 lines
5.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Phase 6.15 P1 ベンチマーク結果: シャードロック化
**Date**: 2025-10-22
**Status**: ✅ ベンチマーク完了
**Goal**: ChatGPT P1 実装(グローバルロック撤廃+シャードロック化)の性能評価
---
## 📊 **ベンチマーク結果サマリー**
### **Scenario 1: json (64KB, 中サイズ)**
| Allocator | 平均時間 | ops/sec | vs system | vs mimalloc | vs P0 |
|-----------|----------|---------|-----------|-------------|-------|
| **system** | 213ns | 4.68M | baseline | +24.6% | - |
| **mimalloc** | 266ns | 3.76M | -19.9% | baseline | - |
| **hakmem P0** | 291ns | 3.43M | -26.8% | -8.6% | baseline |
| **hakmem P1** | **279ns** | **3.58M** | **-23.6%** | **-4.7%** | **+4.1%** ✅ |
**P0 vs P1 改善**: **4.1%高速化** (291ns → 279ns) ✅
---
### **Scenario 2: string-builder (8-64B, 小サイズ)**
| Allocator | 平均時間 | ops/sec | vs system | vs mimalloc | vs P0 |
|-----------|----------|---------|-----------|-------------|-------|
| **system** | 15ns | 63.0M | baseline | -4.5% | - |
| **mimalloc** | 15ns | 66.0M | +4.7% | baseline | - |
| **hakmem P0** | ❌ | ❌ | ❌ | ❌ | baseline |
| **hakmem P1** | **❌ タイムアウト** | **❌** | **❌** | **❌** | **変化なし** ❌ |
**問題**: P0 と同様、string-builder で 30秒以上タイムアウト実行不可
**原因推測**:
- Tiny Pool (≤1KB) のクラスロックが細かすぎる or デッドロック
- レジストリ lookup のオーバーヘッド
- 小サイズ連続 allocation での競合
---
### **Scenario 3: mir (256KB, 大サイズ)**
| Allocator | 平均時間 | ops/sec | vs system | vs mimalloc | vs P0 |
|-----------|----------|---------|-----------|-------------|-------|
| **system** | 844ns | 1.18M | baseline | +14.1% | - |
| **mimalloc** | 963ns | 1.04M | -12.4% | baseline | - |
| **hakmem P0** | 888ns | 1.13M | -4.9% | +2.6% | baseline |
| **hakmem P1** | **880ns** | **1.14M** | **-4.1%** | **+9.4%** ✅ | **+0.9%** ✅ |
**P0 vs P1 改善**: **0.9%高速化** (888ns → 880ns) ✅
**mimalloc 比較**: **9.4%速い!** 🚀
---
## 🔍 **詳細分析**
### ✅ **P1 の改善点**
1. **json (64KB)**: **4.1%高速化**
- グローバルロック撤廃の効果が顕著
- L2.5 Pool のシャードロックが効いている
2. **mir (256KB)**: **0.9%高速化** + **mimalloc を 9.4% 上回る!**
- 大サイズで hakmem が最速達成 🚀
- BigCache のサイトロック化が有効
---
### ❌ **P1 の問題点**
1. **string-builder (8-64B)**: **依然として実行不可**
- P0 から改善なし30秒以上タイムアウト
- Tiny Pool の根本的な問題が残存
**原因候補**:
- クラスロック8クラスでの競合
- レジストリ lookup のオーバーヘッド
- スラブ管理の非効率性
- デッドロックの可能性
---
## 📈 **P0 vs P1 比較表**
| 項目 | P0 (グローバルロック) | P1 (シャードロック) | 改善率 |
|------|----------------------|---------------------|--------|
| **json (64KB)** | 291ns | **279ns** | **+4.1%** ✅ |
| **string-builder (8-64B)** | ❌ タイムアウト | ❌ タイムアウト | **変化なし** ❌ |
| **mir (256KB)** | 888ns | **880ns** | **+0.9%** ✅ |
---
## 🏆 **mimalloc 比較**
### **json (64KB)**
- mimalloc: 266ns (3.76M ops/sec)
- **hakmem P1**: 279ns (3.58M ops/sec)
- **差**: -4.7% (mimalloc が速い)
### **string-builder (8-64B)**
- mimalloc: 15ns (66.0M ops/sec)
- **hakmem P1**: ❌ 実行不可
- **差**: ❌ 測定不能
### **mir (256KB)**
- mimalloc: 963ns (1.04M ops/sec)
- **hakmem P1**: 880ns (1.14M ops/sec)
- **差**: **+9.4% (hakmem が速い!)** 🚀
---
## 🎯 **結論**
### ✅ **達成事項**
1. **大サイズ256KBで mimalloc を上回る!** 🎉
- mir シナリオで **9.4%速い**
- hakmem の強みを実証
2. **中サイズ64KBで P0 より改善**
- グローバルロック撤廃で **4.1%高速化**
- シャードロックの効果確認
---
### ❌ **未解決問題**
1. **小サイズ8-64Bが依然として実行不可**
- P0 と同じ問題が残存
- Tiny Pool の根本的な見直しが必要
---
## 🔧 **次のステップ**
### **Option A: string-builder 問題の調査** (推奨)
**目的**: 小サイズ allocations が実行不可な原因特定
**手順**:
1. 簡易テストケース作成8-64B 連続 allocation
2. gdb デバッグ(デッドロック確認)
3. Tiny Pool レジストリの無効化テスト
4. クラスロック → TLS への移行検討
---
### **Option B: TLS 実装へ進む** (スキップ推奨しない)
**理由**: 小サイズ問題を解決せずに TLS 実装しても、根本原因が残る可能性
---
### **Option C: ChatGPT に報告** (推奨)
**報告内容**:
- ✅ json/mir で改善確認(+4.1% / +0.9%
- ✅ mir で mimalloc を 9.4% 上回る達成 🚀
- ❌ string-builder で依然としてタイムアウト
- ❓ Tiny Pool の根本原因調査依頼
---
## 📝 **学んだこと**
1. **シャードロックは有効**
- json/mir で改善確認
- グローバルロックよりスケーラブル
2. **大サイズで競争力あり**
- mimalloc を上回る性能を達成
- hakmem の差別化ポイント
3. **小サイズに課題**
- Tiny Pool の設計に根本的な問題
- TLS 前に解決必要
---
**Status**: ✅ ベンチマーク完了、問題点特定
**Next**: string-builder 問題調査 or ChatGPT 報告