Files
hakmem/docs/analysis/ALLOCATOR_COMPARISON_QUICK_RUNBOOK.md
Moe Charm (CI) 89a9212700 Phase 83-1 + Allocator Comparison: Switch dispatch fixed (NO-GO +0.32%), PROFILE correction, SCORECARD update
Key changes:
- Phase 83-1: Switch dispatch fixed mode (tiny_inline_slots_switch_dispatch_fixed_box) - NO-GO (marginal +0.32%, branch reduction negligible)
  Reason: lazy-init pattern already optimal, Phase 78-1 pattern shows diminishing returns

- Allocator comparison baseline update (10-run SSOT, WS=400, ITERS=20M):
  tcmalloc: 115.26M (92.33% of mimalloc)
  jemalloc: 97.39M (77.96% of mimalloc)
  system: 85.20M (68.24% of mimalloc)
  mimalloc: 124.82M (baseline)

- hakmem PROFILE correction: scripts/run_mixed_10_cleanenv.sh + run_allocator_quick_matrix.sh
  PROFILE explicitly set to MIXED_TINYV3_C7_SAFE for hakmem measurements
  Result: baseline stabilized to 55.53M (44.46% of mimalloc)
  Previous unstable measurement (35.57M) was due to profile leak

- Documentation:
  * PERFORMANCE_TARGETS_SCORECARD.md: Reference allocators + M1/M2 milestone status
  * PHASE83_1_SWITCH_DISPATCH_FIXED_RESULTS.md: Phase 83-1 analysis (NO-GO)
  * ALLOCATOR_COMPARISON_QUICK_RUNBOOK.md: Quick comparison procedure
  * ALLOCATOR_COMPARISON_SSOT.md: Detailed SSOT methodology

- M2 milestone status: 44.46% (target 55%, gap -10.54pp) - structural improvements needed

🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 18:50:00 +09:00

85 lines
3.0 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.

# Allocator Comparison Quick Runbook長時間 soak なし)
目的: 「まず全体像」を短時間で揃える。最適化判断の SSOT同一バイナリ A/Bとは別に、外部 allocator の reference を取る。
## 0) 注意SSOTとreferenceの混同禁止
- Mixed 161024B SSOT: `scripts/run_mixed_10_cleanenv.sh`hakmem の最適化判断の正)
- allocator比較jemalloc/tcmalloc/system/mimalloc**別バイナリ or LD_PRELOAD** で layout差を含むため **reference**
## 1) 事前準備1回だけ
### 1.1 ビルド(比較用バイナリ)
```bash
make bench_random_mixed_hakmem bench_random_mixed_system bench_random_mixed_mi
make bench
```
オプションFAST PGO も比較したい場合):
```bash
make pgo-fast-full
```
### 1.2 jemalloc / tcmalloc の .so パス
環境にある場合:
```bash
export JEMALLOC_SO=/path/to/libjemalloc.so.2
export TCMALLOC_SO=/path/to/libtcmalloc.so
```
tcmalloc が無ければgperftoolsからローカルビルド:
```bash
scripts/setup_tcmalloc_gperftools.sh
export TCMALLOC_SO="$PWD/deps/gperftools/install/lib/libtcmalloc.so"
```
## 2) Quick matrixRandom Mixed, 10-run
長時間 soak なしで「同じベンチ形」の比較を取るsystem/jemalloc/tcmalloc/mimalloc/hakmem
```bash
ITERS=20000000 WS=400 SEED=1 RUNS=10 scripts/run_allocator_quick_matrix.sh
```
出力:
- 各 allocator の `mean/median/CV/min/max`M ops/s
注記:
- hakmem は `HAKMEM_PROFILE` が未指定だと “別ルート” を踏み、数値が大きく壊れることがある。
`scripts/run_allocator_quick_matrix.sh` は SSOT と同じく `HAKMEM_PROFILE=MIXED_TINYV3_C7_SAFE` を明示する。
- 「同じマシンなのに数値が変わる」切り分け用に、SSOTベンチでは環境ログを出せる:
- `HAKMEM_BENCH_ENV_LOG=1 RUNS=10 scripts/run_mixed_10_cleanenv.sh`
### 同一バイナリでの比較(推奨)
layout tax を避けたい場合は、`bench_random_mixed_system` を固定して LD_PRELOAD を差す:
```bash
make bench_random_mixed_system shared
export MIMALLOC_SO=/path/to/libmimalloc.so.2 # optional
export JEMALLOC_SO=/path/to/libjemalloc.so.2 # optional
export TCMALLOC_SO=/path/to/libtcmalloc.so # optional
RUNS=10 scripts/run_allocator_preload_matrix.sh
```
## 3) Scenario benchbench_allocators_compare.sh
シナリオ別json/mir/vm/mixedを CSV で揃える。
```bash
scripts/bench_allocators_compare.sh --scenario mixed --iterations 50
scripts/bench_allocators_compare.sh --scenario json --iterations 50
scripts/bench_allocators_compare.sh --scenario mir --iterations 50
scripts/bench_allocators_compare.sh --scenario vm --iterations 50
```
出力1行CSV:
`allocator,scenario,iterations,avg_ns,soft_pf,hard_pf,rss_kb,ops_per_sec`
## 4) 結果の記録先SSOT
- 比較手順: `docs/analysis/ALLOCATOR_COMPARISON_SSOT.md`
- 参照値の記録: `docs/analysis/PERFORMANCE_TARGETS_SCORECARD.md`Allocator Comparison セクション)