Changes: - scripts/box/pgo_fast_profile_config.sh: Expanded WS patterns (3→5) and seeds (1→3) for reduced overfitting and better production workload representativeness - PERFORMANCE_TARGETS_SCORECARD.md: Phase 68 baseline promoted (61.614M = 50.93%) - CURRENT_TASK.md: Phase 68 marked complete, Phase 67a (layout tax forensics) set Active Results: - 10-run verification: +1.19% vs Phase 66 baseline (GO, >+1.0% threshold) - M1 milestone: 50.93% of mimalloc (target 50%, exceeded by +0.93pp) - Stability: 10-run mean/median with <2.1% CV 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
3.5 KiB
3.5 KiB
Phase 65: Hot Symbol Ordering — 技術的制約により中止
Status: ⚠️ BLOCKED (技術的制約)
Executive Summary
Phase 65 は linker の symbol ordering file を使用して hot function を連続配置し、layout tax を減らすアプローチを試みた。しかし、GCC + LTO 環境では技術的に実現不可能であることが判明した。
試行内容
-
perf profiling で hot function を特定:
- malloc (27.84%)
- free (24.75%)
- main (22.33%)
- free_tiny_fast_compute_route_and_heap (3.94%)
- tiny_region_id_write_header.lto_priv.0 (3.59%)
- tiny_c7_ultra_alloc.constprop.0 (3.47%)
- unified_cache_push (3.37%)
-
build/hot_syms.txtを作成(17 symbols) -
Makefile target
bench_random_mixed_hakmem_fast_orderedを追加:EXTRA_LDFLAGS='-fuse-ld=lld -Wl,--symbol-ordering-file=build/hot_syms.txt'
遭遇した技術的制約
問題 1: GNU ld は --symbol-ordering-file をサポートしない
/usr/bin/ld: 認識できないオプション '--symbol-ordering-file=build/hot_syms.txt' です
--symbol-ordering-file は LLVM lld linker 固有の機能。
問題 2: GCC LTO と lld は非互換
ld.lld: error: undefined symbol: main
>>> referenced by Scrt1.o:(_start)
GCC は独自の LTO format (GIMPLE IR) を使用するため、lld が理解できない。
問題 3: LTO が hot function をインライン化
nm の出力を見ると、バイナリにエクスポートされるシンボルは僅か 33 個:
- hot function の多くは internal (
t) であり、LTO によってインライン化/マージされる .lto_priv.0,.constprop.0などの suffix は LTO が生成した内部シンボル- これらは ordering file で参照しても効果がない
問題 4: LTO なしだと baseline と条件が違う
LTO を無効にして lld を使う場合:
- Symbol ordering は可能
- しかし LTO の性能向上(5-10%)を失う
- A/B 比較が unfair になる
結論
Phase 65 は技術的制約により中止。
Symbol ordering アプローチは GCC + LTO 環境では以下の理由で非実現的:
- Linker 非互換:
--symbol-ordering-fileは lld 専用 - LTO 非互換: GCC LTO format と lld は互換性がない
- Symbol 消失: LTO が hot function をインライン化し、ordering 対象が消える
- Trade-off: LTO を諦めると symbol ordering 以上の性能低下が発生
Alternative Strategies
Phase 65 の教訓を踏まえ、以下のアプローチを推奨:
Option A: PGO (Profile-Guided Optimization) - 推奨
GCC の -fprofile-generate + -fprofile-use を使用:
- Compiler が hot path を自動で最適配置
- LTO との組み合わせが可能
- Symbol ordering より強力
Option B: -fno-inline + Symbol Ordering (研究用)
特定の hot function に __attribute__((noinline)) を付与:
- LTO によるインライン化を防止
- Symbol として残るため ordering 可能
- 性能 trade-off の検証が必要
Option C: Clang/LLVM に移行 (大規模変更)
全ビルドを Clang に移行:
- lld と完全互換
- Symbol ordering + LTO が両立可能
- Migration cost が高い
次のステップ
- Phase 66 (PGO):
-fprofile-generate/-fprofile-useを試行 - Phase 67 (alternative): 他の layout tax 削減手法を調査
Artifacts:
build/hot_syms.txt: Hot symbol list (残存、将来の参照用)- Makefile target:
bench_random_mixed_hakmem_fast_ordered(USE_LTO=0 でのみ動作)