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 実装)
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "hakmem_tiny_integrity.h" // PRIORITY 1-4: Corruption detection
|
||||
#include "front/tiny_heap_v2.h" // Phase 13-B: TinyHeapV2 magazine supply
|
||||
#include "front/tiny_ultra_hot.h" // Phase 14: TinyUltraHot C1/C2 ultra-fast path
|
||||
#include "front/tiny_ring_cache.h" // Phase 21-1: Ring cache (C2/C3 array-based TLS cache)
|
||||
|
||||
// Phase 7: Header-based ultra-fast free
|
||||
#if HAKMEM_TINY_HEADER_CLASSIDX
|
||||
@ -136,6 +137,18 @@ static inline int hak_tiny_free_fast_v2(void* ptr) {
|
||||
// → 正史(TLS SLL)の在庫を正しく保つ
|
||||
// → UltraHot refill は alloc 側で TLS SLL から借りる
|
||||
|
||||
// Phase 21-1: Ring Cache (C2/C3 only) - Array-based TLS cache
|
||||
// ENV-gated: HAKMEM_TINY_HOT_RING_ENABLE=1
|
||||
// Target: +15-20% (54.4M → 62-65M ops/s) by eliminating pointer chasing
|
||||
// Design: Ring (L0) → SLL (L1) → SuperSlab (L2) cascade hierarchy
|
||||
if (class_idx == 2 || class_idx == 3) {
|
||||
if (ring_cache_push(class_idx, base)) {
|
||||
// Ring push success - done!
|
||||
return 1;
|
||||
}
|
||||
// Ring full - fall through to existing path (TLS SLL/HeapV2)
|
||||
}
|
||||
|
||||
// Phase 13-B: TinyHeapV2 magazine supply (C0-C3 only)
|
||||
// Two supply modes (controlled by HAKMEM_TINY_HEAP_V2_LEFTOVER_MODE):
|
||||
// Mode 0 (default): L0 gets blocks first ("stealing" design)
|
||||
|
||||
Reference in New Issue
Block a user