## Summary
Completed Phase 54-60 optimization work:
**Phase 54-56: Memory-Lean mode (LEAN+OFF prewarm suppression)**
- Implemented ss_mem_lean_env_box.h with ENV gates
- Balanced mode (LEAN+OFF) promoted as production default
- Result: +1.2% throughput, better stability, zero syscall overhead
- Added to bench_profile.h: MIXED_TINYV3_C7_BALANCED preset
**Phase 57: 60-min soak finalization**
- Balanced mode: 60-min soak, RSS drift 0%, CV 5.38%
- Speed-first mode: 60-min soak, RSS drift 0%, CV 1.58%
- Syscall budget: 1.25e-7/op (800× under target)
- Status: PRODUCTION-READY
**Phase 59: 50% recovery baseline rebase**
- hakmem FAST (Balanced): 59.184M ops/s, CV 1.31%
- mimalloc: 120.466M ops/s, CV 3.50%
- Ratio: 49.13% (M1 ACHIEVED within statistical noise)
- Superior stability: 2.68× better CV than mimalloc
**Phase 60: Alloc pass-down SSOT (NO-GO)**
- Implemented alloc_passdown_ssot_env_box.h
- Modified malloc_tiny_fast.h for SSOT pattern
- Result: -0.46% (NO-GO)
- Key lesson: SSOT not applicable where early-exit already optimized
## Key Metrics
- Performance: 49.13% of mimalloc (M1 effectively achieved)
- Stability: CV 1.31% (superior to mimalloc 3.50%)
- Syscall budget: 1.25e-7/op (excellent)
- RSS: 33MB stable, 0% drift over 60 minutes
## Files Added/Modified
New boxes:
- core/box/ss_mem_lean_env_box.h
- core/box/ss_release_policy_box.{h,c}
- core/box/alloc_passdown_ssot_env_box.h
Scripts:
- scripts/soak_mixed_single_process.sh
- scripts/analyze_epoch_tail_csv.py
- scripts/soak_mixed_rss.sh
- scripts/calculate_percentiles.py
- scripts/analyze_soak.py
Documentation: Phase 40-60 analysis documents
## Design Decisions
1. Profile separation (core/bench_profile.h):
- MIXED_TINYV3_C7_SAFE: Speed-first (no LEAN)
- MIXED_TINYV3_C7_BALANCED: Balanced mode (LEAN+OFF)
2. Box Theory compliance:
- All ENV gates reversible (HAKMEM_SS_MEM_LEAN, HAKMEM_ALLOC_PASSDOWN_SSOT)
- Single conversion points maintained
- No physical deletions (compile-out only)
3. Lessons learned:
- SSOT effective only where redundancy exists (Phase 60 showed limits)
- Branch prediction extremely effective (~0 cycles for well-predicted branches)
- Early-exit pattern valuable even when seemingly redundant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2.9 KiB
2.9 KiB
Phase 48: Rebase(mimalloc/system/jemalloc)+ Stability Suite
目的: Phase 39 以降で FAST baseline が大きく動いたため、docs/analysis/PERFORMANCE_TARGETS_SCORECARD.md の参照値(mimalloc/system/jemalloc/libc)を 同一条件で再計測して更新する。あわせて「速さ以外の勝ち筋」(syscall/RSS/長時間安定性)の 測定ルーチンを固定する。
方針(Box Theory):
- 測定は clean env を正とする:
scripts/run_mixed_10_cleanenv.sh - 比較は FAST build を正(Standard/OBSERVE は別目的)
- link-out / 物理削除はしない(layout tax で符号反転するため)。compile-out で運用する。
Step 0: 準備(ビルド)
make bench_random_mixed_hakmem_minimal
make bench_random_mixed_system
make bench_random_mixed_mi
(任意)jemalloc がある場合のみ:
ls -la /lib/x86_64-linux-gnu/libjemalloc.so.2
Step 1: Mixed 10-run rebase(同一スクリプトで回す)
1-A) hakmem FAST(正)
BENCH_BIN=./bench_random_mixed_hakmem_minimal scripts/run_mixed_10_cleanenv.sh
1-B) system malloc(別バイナリ reference)
BENCH_BIN=./bench_random_mixed_system scripts/run_mixed_10_cleanenv.sh
1-C) mimalloc(別バイナリ reference)
BENCH_BIN=./bench_random_mixed_mi scripts/run_mixed_10_cleanenv.sh
1-D) jemalloc(LD_PRELOAD reference、任意)
LD_PRELOAD=/lib/x86_64-linux-gnu/libjemalloc.so.2 \
BENCH_BIN=./bench_random_mixed_system scripts/run_mixed_10_cleanenv.sh
更新先(SSOT):
docs/analysis/PERFORMANCE_TARGETS_SCORECARD.mdのCurrent snapshotとReference allocators
Step 2: Syscall budget(steady-state OS churn)
目的: warmup 後に mmap/munmap/madvise が暴れていないことを確認する(mimallocに対する勝ち筋の1つ)。
内部カウンタ(推奨、短時間):
HAKMEM_SS_OS_STATS=1 BENCH_BIN=./bench_random_mixed_hakmem_minimal \
ITERS=200000000 WS=400 RUNS=1 scripts/run_mixed_10_cleanenv.sh
チェック:
[SS_OS_STATS] ... mmap_total=... madvise=... madvise_disabled=...- 目標: warmup 後に 増え続けない / “極端に多くない”
Step 3: RSS/長時間安定性(soak)
目的: 「速さ以外の勝ち筋」を数値化する(RSS drift / ops/s drift / CV)。
推奨(30–60分、FAST build):
- RSS drift: +5% 以内(目安)
- ops/s drift: -5% 以上落ちない
- CV: ~1–2% を維持
実施方法:
- まずは
docs/analysis/PERFORMANCE_TARGETS_SCORECARD.mdのMemory stability / Long-run stabilityを SSOT とし、測定テンプレを追記する(スクリプト化は別PhaseでOK)。
判定
- Phase 48 は「最適化」ではなく「基準の固定」が目的。
- GO/NO-GO は無し(測定結果をスコアカードへ反映して完了)。