From 582ebdfd4fed18b99ae2abb3dc63b209d3c738f9 Mon Sep 17 00:00:00 2001 From: "Moe Charm (CI)" Date: Wed, 5 Nov 2025 16:47:04 +0900 Subject: [PATCH] =?UTF-8?q?CURRENT=5FTASK:=20Registry=20=E7=B7=9A=E5=BD=A2?= =?UTF-8?q?=E3=82=B9=E3=82=AD=E3=83=A3=E3=83=B3=20=E3=83=9C=E3=83=88?= =?UTF-8?q?=E3=83=AB=E3=83=8D=E3=83=83=E3=82=AF=E7=89=B9=E5=AE=9A=20(2025-?= =?UTF-8?q?11-05)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - perf 分析で superslab_refill が 28.51% CPU を消費 - Root cause: 262,144 エントリの線形スキャン (97.65% の hot instructions) - 解決策: per-class registry (8×4096 = 32K entries) - 期待効果: +200-300% (2.59M → 7.8-10.4M ops/s) - Box Refactor は既に動いている (+463% ST, +131% MT) 次のアクション: Phase 1 実装 (per-class registry 変更) 詳細: PERF_ANALYSIS_2025_11_05.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CURRENT_TASK.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/CURRENT_TASK.md b/CURRENT_TASK.md index 809484c2..67e99c51 100644 --- a/CURRENT_TASK.md +++ b/CURRENT_TASK.md @@ -1,4 +1,80 @@ -# Current Task (2025-11-04) +# Current Task (2025-11-05) + +## 🔔 最新アップデート (2025-11-05 16:30) 🔥🔥🔥 + +### ✅ Registry 線形スキャン ボトルネック特定! + +**Perf 分析完了 → Root Cause 発見!** + +**測定結果 (Larson, threads=4):** +``` +HAKMEM: 3.62M ops/s (21.6% of system) +System: 16.76M ops/s (100%) +差: -78.4% 💀 +``` + +**Perf プロファイリング結果:** +``` +28.51% superslab_refill 💀💀💀 圧倒的ボトルネック + 2.58% exercise_heap (ベンチマーク本体) +``` + +**問題:** アロケータ (superslab_refill) がベンチマーク本体 (exercise_heap) より CPU time を消費! + +**Hot Instructions 分析 (perf annotate):** +``` +32.36% cmp $0x3ffff,%r11d ← 262,143 回ループ! +16.78% inc %r13d ← カウンタ++ +16.29% add $0x18,%rbx ← ポインタ進める +合計 97.65% の CPU time がループに集中 +``` + +**Root Cause (core/hakmem_tiny_free.inc:917):** +```c +for (int i = 0; i < SUPER_REG_SIZE && scanned < scan_max; i++) { + // ^^^^^^^^^^^ 262,144 エントリを線形スキャン! + SuperRegEntry* e = &g_super_reg[i]; + // ... class_idx 不一致でも全エントリをイテレート +} +``` + +**解決策: Per-class Registry** +```c +// Before: 全 class 混在 +SuperRegEntry g_super_reg[262144]; + +// After: class ごとに分離 +SuperRegEntry g_super_reg_by_class[TINY_NUM_CLASSES][4096]; +// 8 classes × 4096 entries = 32K total +``` + +**期待効果:** +- スキャン対象: 262,144 → 4,096 エントリ (-98.4%) +- **期待改善: +200-300%** (2.59M → 7.8-10.4M ops/s) +- **System malloc の 54-73% まで到達可能!** 🎯 + +**詳細レポート:** +- `PERF_ANALYSIS_2025_11_05.md` - 完全分析 + 実装プラン +- Commit: `859027e` "Perf Analysis: Registry 線形スキャンがボトルネック" +- Branch: `perf-analysis-2025-11-05` (pushed to private repo) + +**次のアクション:** +1. **Phase 1 実装** (1-2日): per-class registry に変更 + - `core/hakmem_super_registry.{h,c}` 構造変更 + - `core/hakmem_tiny_free.inc:917` スキャン簡素化 + - 目標: 2.59M → 7.8M ops/s (+3倍!) + +2. **Phase 2 実装** (追加 1日): 早期終了 + First-fit + - 最初の freelist 発見で即 return + - 目標: 7.8M → 11.7M ops/s (system の 82%!) + +**重要:** Box Refactor は既に動いている! +- Single-thread: 0.46M → 2.59M ops/s (+463%!) ✅ +- Multi-thread: 1.81M → 4.19M ops/s (+131%!) ✅ +- 外部AIの最適化も効いている (Option A: Inline TLS cache access) +- **ただし Registry スキャンがボトルネックで system には届かず** + +--- ## 🔔 最新アップデート (2025-11-06 23:xx)