Files
hakmem/docs/analysis/PHASE50_OPERATIONAL_EDGE_STABILITY_SUITE_INSTRUCTIONS.md

97 lines
3.0 KiB
Markdown
Raw Normal View History

Phase 54-60: Memory-Lean mode, Balanced mode stabilization, M1 (50%) achievement ## 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>
2025-12-17 06:24:01 +09:00
# Phase 50: Operational Edgesyscall / RSS / long-run / tail
目的: mimalloc と「速度だけ」で殴り合わず、**運用の勝ち筋**OS churn / RSS drift / long-run stability / tail latencyを SSOT 化する。
Phase 48 で rebase 済みなので、Phase 50 は **“測り方を固定”**して今後の最適化判断の土台にする。
前提(運用):
- 速度比較の正: FAST build`make perf_fast` / `bench_random_mixed_hakmem_minimal`
- 計測の正: `scripts/run_mixed_10_cleanenv.sh`ENV leak を防ぐ)
- 変更は compile-out / ENV で戻せるlink-out/物理削除はしない)
---
## A) Syscall budgetsteady-state OS churn
狙い:
- warmup 後に `mmap/munmap/madvise`**増え続けない**= churn しない)
- 指標は “回数/ops” で扱う
手順FAST, 200M ops, 1-run:
```bash
make bench_random_mixed_hakmem_minimal
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=...`
- `mmap_total/ITERS`, `madvise/ITERS`per-op
判定(目安):
- `mmap+munmap+madvise` 合計が **1e8 ops あたり 1 回以下**= 1e-8/opを理想
- 現実の許容は workload 次第Phase 48 実測を SSOT として追跡)
---
## B) RSS / fragmentationメモリ安定性
狙い:
- RSS が **単調増加しない**
- soak で drift が **+5%以内**(目安)
手順3060分、FAST:
- `ITERS` を分割し、同一 `WS` で繰り返す(例: 20M×N
- ループごとに RSS を採取し、CSV へ記録
推奨スクリプト:
- `scripts/soak_mixed_rss.sh`Phase 50 で追加。実行方法はスクリプト内)
30分 soak, FAST:
```bash
make bench_random_mixed_hakmem_minimal
BENCH_BIN=./bench_random_mixed_hakmem_minimal \
DURATION_SEC=1800 STEP_ITERS=20000000 WS=400 \
scripts/soak_mixed_rss.sh > soak_fast.csv
```
記録(最低限):
- time, ops/s, RSS(MB)
- peak RSS, steady RSS, drift(%)
---
## C) Long-run throughput stability性能の一貫性
狙い:
- 3060分で ops/s が **-5% 以上落ちない**
- CV変動係数**~12%** を維持
方法:
- 上の soak と同時に “ops/s” をログ化
- “最初の 5 分” と “最後の 5 分” の平均を比較
---
## D) Tailp99/p999を将来測れる形にする
現状の bench は ops/s 指標が中心。次のどちらかを採用して SSOT 化するPhase 51 以降):
1. bench 側に histogram を追加observer build のみ)
2. 外部計測perf + timestamp samplingで近似
この Phase 50 では「どちらを採用するか」を決めて、スコアカードに TODO を書く。
---
## E) スコアカード更新SSOT
更新先:
- `docs/analysis/PERFORMANCE_TARGETS_SCORECARD.md`
追記する項目:
- Syscall budgetPhase 48 の値を SSOT 化)
- RSS drift / throughput drift のテンプレPhase 50 で確立)