Files
hakmem/docs/archive/STABILITY_POLICY.md
Moe Charm (CI) 67fb15f35f Wrap debug fprintf in !HAKMEM_BUILD_RELEASE guards (Release build optimization)
## Changes

### 1. core/page_arena.c
- Removed init failure message (lines 25-27) - error is handled by returning early
- All other fprintf statements already wrapped in existing #if !HAKMEM_BUILD_RELEASE blocks

### 2. core/hakmem.c
- Wrapped SIGSEGV handler init message (line 72)
- CRITICAL: Kept SIGSEGV/SIGBUS/SIGABRT error messages (lines 62-64) - production needs crash logs

### 3. core/hakmem_shared_pool.c
- Wrapped all debug fprintf statements in #if !HAKMEM_BUILD_RELEASE:
  - Node pool exhaustion warning (line 252)
  - SP_META_CAPACITY_ERROR warning (line 421)
  - SP_FIX_GEOMETRY debug logging (line 745)
  - SP_ACQUIRE_STAGE0.5_EMPTY debug logging (line 865)
  - SP_ACQUIRE_STAGE0_L0 debug logging (line 803)
  - SP_ACQUIRE_STAGE1_LOCKFREE debug logging (line 922)
  - SP_ACQUIRE_STAGE2_LOCKFREE debug logging (line 996)
  - SP_ACQUIRE_STAGE3 debug logging (line 1116)
  - SP_SLOT_RELEASE debug logging (line 1245)
  - SP_SLOT_FREELIST_LOCKFREE debug logging (line 1305)
  - SP_SLOT_COMPLETELY_EMPTY debug logging (line 1316)
- Fixed lock_stats_init() for release builds (lines 60-65) - ensure g_lock_stats_enabled is initialized

## Performance Validation

Before: 51M ops/s (with debug fprintf overhead)
After:  49.1M ops/s (consistent performance, fprintf removed from hot paths)

## Build & Test

```bash
./build.sh larson_hakmem
./out/release/larson_hakmem 1 5 1 1000 100 10000 42
# Result: 49.1M ops/s
```

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 13:14:18 +09:00

33 lines
1.7 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.

# Stability Policy (SegfaultFree Invariant)
本リポジトリの本線は「セグフォしないSegfaultFree」を絶対条件とします。すべての変更は以下のチェックを通った場合のみ採用します。
## 1) Guard ランFailFast
- 実行: `./scripts/larson.sh guard 2 4`
- 条件: `remote_invalid` / `REMOTE_SENTINEL_TRAP` / `TINY_RING_EVENT_*` の一発ログが出ないこと
- 境界: drain→bind→owner_acquire は「採用境界」1箇所のみ。publish側で drain/owner を触らない
## 2) Sanitizer ラン
- ASan: `./scripts/larson.sh asan 2 4`
- UBSan: `./scripts/larson.sh ubsan 2 4`
- TSan: `./scripts/larson.sh tsan 2 4`
## 3) 本線の定義(デフォルトライン)
- Box Refactor: `HAKMEM_TINY_PHASE6_BOX_REFACTOR=1`(ビルド既定)
- SuperSlab 経路: 既定ON`g_use_superslab=1`。ENVで明示的に 0 を指定した場合のみOFF
- 互換切替: 旧経路/A/B は ENV/Make で明示(本線は変えない)
## 4) 変更の入れ方(箱理論)
- 新経路は必ず「箱」で追加し、ENV で切替可能にする
- 変換点drain/bind/ownerは 1 箇所集約(採用境界)
- 可視化はワンショットログ/リング/カウンタに限定
- FailFast: 整合性違反は即露出。隠さない
## 5) 既知の安全フック
- Registry 小窓: `HAKMEM_TINY_REG_SCAN_MAX`(探索窓を制限)
- Mid簡素化 refill: `HAKMEM_TINY_MID_REFILL_SIMPLE=1`class>=4 で多段探索スキップ)
- adopt OFF プロファイル: `scripts/profiles/tinyhot_tput_noadopt.env`
運用では上記 1)→2)→3) の順でチェックを通した後に性能検証を行ってください。