Commit Graph

3 Commits

Author SHA1 Message Date
25d963a4aa Code Cleanup: Remove false positives, redundant validations, and reduce verbose logging
Following the C7 stride upgrade fix (commit 23c0d9541), this commit performs
comprehensive cleanup to improve code quality and reduce debug noise.

## Changes

### 1. Disable False Positive Checks (tiny_nextptr.h)
- **Disabled**: NXT_MISALIGN validation block with `#if 0`
- **Reason**: Produces false positives due to slab base offsets (2048, 65536)
  not being stride-aligned, causing all blocks to appear "misaligned"
- **TODO**: Reimplement to check stride DISTANCE between consecutive blocks
  instead of absolute alignment to stride boundaries

### 2. Remove Redundant Geometry Validations

**hakmem_tiny_refill_p0.inc.h (P0 batch refill)**
- Removed 25-line CARVE_GEOMETRY_FIX validation block
- Replaced with NOTE explaining redundancy
- **Reason**: Stride table is now correct in tiny_block_stride_for_class(),
  defense-in-depth validation adds overhead without benefit

**ss_legacy_backend_box.c (legacy backend)**
- Removed 18-line LEGACY_FIX_GEOMETRY validation block
- Replaced with NOTE explaining redundancy
- **Reason**: Shared_pool validates geometry at acquisition time

### 3. Reduce Verbose Logging

**hakmem_shared_pool.c (sp_fix_geometry_if_needed)**
- Made SP_FIX_GEOMETRY logging conditional on `!HAKMEM_BUILD_RELEASE`
- **Reason**: Geometry fixes are expected during stride upgrades,
  no need to log in release builds

### 4. Verification
- Build:  Successful (LTO warnings expected)
- Test:  10K iterations (1.87M ops/s, no crashes)
- NXT_MISALIGN false positives:  Eliminated

## Files Modified
- core/tiny_nextptr.h - Disabled false positive NXT_MISALIGN check
- core/hakmem_tiny_refill_p0.inc.h - Removed redundant CARVE validation
- core/box/ss_legacy_backend_box.c - Removed redundant LEGACY validation
- core/hakmem_shared_pool.c - Made SP_FIX_GEOMETRY logging debug-only

## Impact
- **Code clarity**: Removed 43 lines of redundant validation code
- **Debug noise**: Reduced false positive diagnostics
- **Performance**: Eliminated overhead from redundant geometry checks
- **Maintainability**: Single source of truth for geometry validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 23:00:24 +09:00
eb12044416 Phase 21-1-C: Ring cache Refill/Cascade + Metrics - SLL → Ring cascade
**実装内容**:
- Alloc miss → refill: ring_refill_from_sll() (32 blocks from TLS SLL)
- Free full → fallback: 既に Phase 21-1-B で実装済み(Ring full → TLS SLL)
- Metrics 追加: hit/miss/push/full/refill カウンタ(Phase 19-1 スタイル)
- Stats 出力: ring_cache_print_stats() を bench_random_mixed.c から呼び出し

**修正内容**:
- tiny_alloc_fast.inc.h: Ring miss 時に ring_refill_from_sll() 呼び出し、retry
- tiny_ring_cache.h: Metrics カウンタ追加(pop/push で更新)
- tiny_ring_cache.c: tls_sll_box.h をインクルード、refill カウンタ追加
- bench_random_mixed.c: ring_cache_print_stats() 呼び出し

**ENV 変数**:
- HAKMEM_TINY_HOT_RING_ENABLE=1: Ring 有効化
- HAKMEM_TINY_HOT_RING_CASCADE=1: Refill 有効化(SLL → Ring)
- HAKMEM_TINY_HOT_RING_C2=128: C2 サイズ(default: 128)
- HAKMEM_TINY_HOT_RING_C3=128: C3 サイズ(default: 128)

**動作確認**:
- Ring ON + CASCADE ON: 836K ops/s (10K iterations) 
- クラッシュなし、正常動作

**次のステップ**: Phase 21-1-D (A/B テスト)
2025-11-16 08:15:30 +09:00
fdbdcdcdb3 Phase 21-1-B: Ring cache Alloc/Free 統合 - C2/C3 hot path integration
**統合内容**:
- Alloc path (tiny_alloc_fast.inc.h): Ring pop → HeapV2/UltraHot/SLL fallback
- Free path (tiny_free_fast_v2.inc.h): Ring push → HeapV2/SLL fallback
- Lazy init: 最初の alloc/free 時に自動初期化(thread-safe)

**設計**:
- Lazy init パターン(ENV control と同様)
- ring_cache_pop/push 内で slots == NULL チェック → ring_cache_init() 呼び出し
- Include 構造: ファイルトップレベルに #include 追加(関数内 include 禁止)

**Makefile 修正**:
- TINY_BENCH_OBJS_BASE に core/front/tiny_ring_cache.o 追加
- Link エラー修正: 4箇所の object list に追加

**動作確認**:
- Ring OFF (default): 83K ops/s (1K iterations) 
- Ring ON (HAKMEM_TINY_HOT_RING_ENABLE=1): 78K ops/s 
- クラッシュなし、正常動作確認

**次のステップ**: Phase 21-1-C (Refill/Cascade 実装)
2025-11-16 07:51:37 +09:00