Major changes: - LLVM backend initial implementation (compiler.rs, llvm mode) - Semantics layer integration in interpreter (operators.rs) - Phase 12 plugin architecture revision (3-layer system) - Builtin box removal preparation - MIR instruction set documentation (26→Core-15 migration) - Cross-backend testing infrastructure - Await/nowait syntax support New features: - LLVM AOT compilation support (--backend llvm) - Semantics layer for interpreter→VM flow - Tri-backend smoke tests - Plugin-only registry mode Bug fixes: - Interpreter plugin box arithmetic operations - Branch test returns incorrect values Documentation: - Phase 12 README.md updated with new plugin architecture - Removed obsolete NYIR proposals - Added LLVM test programs documentation Co-Authored-By: Claude <noreply@anthropic.com>
76 lines
2.5 KiB
Markdown
76 lines
2.5 KiB
Markdown
# Nyashメモリ管理ベンチマーク設計書
|
||
|
||
## 概要
|
||
イベントディスパッチャと揮発性リスナーを使用して、Nyashの決定論的メモリ管理の特性を測定・可視化するベンチマーク。
|
||
|
||
## 選定理由
|
||
- **最小実装**: GUIや並行処理なしで実装可能
|
||
- **全特性網羅**: スコープ解放、fini、weak自動nil化、カスケード順序を一度に示せる
|
||
- **測定可能**: 明確な数値指標で他言語と比較可能
|
||
|
||
## アーキテクチャ
|
||
|
||
### コンポーネント
|
||
1. **Dispatcher**: イベント発行者
|
||
- リスナーをweak参照の配列で保持
|
||
- イベント発行時に死んだリスナーを自動スキップ
|
||
|
||
2. **Listener**: イベント受信者
|
||
- 子リソース(Box)を保持してツリー構造を形成
|
||
- finiで子→自身の順で解放(カスケード)
|
||
|
||
3. **Scope**: ライフタイム境界
|
||
- スコープ内でリスナー生成
|
||
- スコープ終了で一括解放
|
||
|
||
## 測定指標
|
||
|
||
### 主要メトリクス
|
||
1. **メモリピーク**: 最大メモリ使用量
|
||
2. **解放レイテンシ**: スコープ終了→解放完了の時間
|
||
3. **ディスパッチ効率**: イベント/秒
|
||
4. **カスケード順序確定性**: 解放順序の一致率(100%が理想)
|
||
5. **残留メモリ**: 解放後の残存メモリ(Nyashは0が理想)
|
||
6. **ジッタ**: 各時間の分散(低いほど決定論的)
|
||
|
||
### 他言語との比較ポイント
|
||
- **GC言語(Go/Java/JS)**: 解放タイミングの非決定性
|
||
- **RAII系(Rust/C++)**: weak掃除ロジックの複雑さ
|
||
- **手動管理(C)**: メモリリーク・二重解放リスク
|
||
|
||
## 実装計画
|
||
|
||
### CLI仕様
|
||
```bash
|
||
nyash-mem-bench dispatch --listeners N --events M --fanout F --depth D
|
||
```
|
||
|
||
### パラメータ
|
||
- `N`: リスナー数
|
||
- `M`: イベント数
|
||
- `F`: 各ノードの子数(分岐率)
|
||
- `D`: ツリーの深さ
|
||
|
||
### 出力形式
|
||
```
|
||
construct_ms: 123.45
|
||
dispatch_ns_p50: 789
|
||
dispatch_ns_p99: 1234
|
||
fini_ms_avg: 45.67
|
||
fini_ms_max: 89.01
|
||
mem_peak_mb: 256.78
|
||
mem_after_fini_kb: 0
|
||
order_ok: true
|
||
weak_prune_count: 5000
|
||
```
|
||
|
||
## 実装ステップ
|
||
1. **Phase 1**: 基本構造(Dispatcher、Listener、Scope)
|
||
2. **Phase 2**: 測定機能(時間、メモリ)
|
||
3. **Phase 3**: 解放順序ログ
|
||
4. **Phase 4**: 統計出力・可視化
|
||
|
||
## 期待される成果
|
||
- Nyashの決定論的メモリ管理の優位性を数値で証明
|
||
- 論文用の説得力のあるベンチマーク結果
|
||
- 他言語実装者にとってのリファレンス実装 |