Files
hakmem/docs/status/archive/P1_STABILITY_2025_10_23.md
Moe Charm (CI) 52386401b3 Debug Counters Implementation - Clean History
Major Features:
- Debug counter infrastructure for Refill Stage tracking
- Free Pipeline counters (ss_local, ss_remote, tls_sll)
- Diagnostic counters for early return analysis
- Unified larson.sh benchmark runner with profiles
- Phase 6-3 regression analysis documentation

Bug Fixes:
- Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB)
- Fix profile variable naming consistency
- Add .gitignore patterns for large files

Performance:
- Phase 6-3: 4.79 M ops/s (has OOM risk)
- With SuperSlab: 3.13 M ops/s (+19% improvement)

This is a clean repository without large log files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 12:31:14 +09:00

2.3 KiB
Raw Blame History

Phase P1: 学習の安定化(ヒステリシス/ドウェルCanary採用

目的: CAP/W_MAX/THP の自動調整に安定性を持たせ、短時間計測でも振動を抑えつつ安全に最適値へ収束させる。

実装点hakmem_learner.c

  • CAP 調整Mid/Large

    • 窓内ヒット率に基づく±stepを継続しつつ、クラス別ドウェルを導入。
    • 環境変数で秒指定((window_ms/1000)単位で加算)
      • HAKMEM_CAP_DWELL_SEC_MID既定3秒
      • HAKMEM_CAP_DWELL_SEC_LG既定5秒
    • 変更が起きたときのみ該当クラスのドウェルをリセット→過剰振動抑制。
  • W_MAX 学習UCB1

    • ドウェルに加えて Canary 試験導入(候補値を一時採用し、所定秒数のスコア比較で採否を決定)。
    • 環境変数:
      • HAKMEM_WMAX_LEARN=1(有効化)
      • HAKMEM_WMAX_CANARY=1Canary有効, 既定ON
      • HAKMEM_WMAX_TRIAL_SEC既定5
      • HAKMEM_WMAX_ADOPT_PCT既定0.01→+1%以上で採用)
      • HAKMEM_WMAX_DWELL_SEC(アーム切替ドウェル)
  • THP閾値 学習UCB1

    • 上記と同様の Canary 試験別ENV
    • 環境変数:
      • HAKMEM_THP_LEARN=1(有効化)
      • HAKMEM_THP_CANARY=1Canary有効, 既定ON
      • HAKMEM_THP_TRIAL_SEC既定6
      • HAKMEM_THP_ADOPT_PCT既定0.015→+1.5%以上で採用)
      • HAKMEM_THP_DWELL_SEC(アーム切替ドウェル)
  • スコア指標(簡易)

    • score = (mid_hit + large_hit) - (mid_miss + large_miss) - 2*l1_fallback
    • Canaryは切替直前のアーム平均スコアをベースラインとし、試験区間平均と比較して採否を決定。

使い方(短時間プリセット)

  • 学習ONMidバンド, 4T, 1秒
HAKMEM_LEARN=1 HAKMEM_WMAX_LEARN=1 HAKMEM_WMAX_CANARY=1 \
HAKMEM_THP_LEARN=1 HAKMEM_THP_CANARY=1 \
HAKMEM_POOL_MIN_BUNDLE=4 HAKMEM_L25_MIN_BUNDLE=2 \
LD_PRELOAD=$(readlink -f ./libhakmem.so) mimalloc-bench/bench/larson/larson 1 2048 32768 10000 1 12345 4
  • 計測を長くする場合210秒*_TRIAL_SEC*_DWELL_SEC を少し伸ばすと振動がさらに減少。

メモ

  • Learner起動: HAKMEM_LEARN=1既定OFF
  • 収束の可視化は docs/benchmarks/* のサマリとLearnerログを併読。