Files
hakmem/core/hakmem_tiny_unified_stats.h

38 lines
1.6 KiB
C
Raw Normal View History

// hakmem_tiny_unified_stats.h - Tiny Unified Cache stats (Box TinyUnifiedStats)
// 目的:
// - Tiny Unified Cache (Phase 23/26) のヒット/ミスをクラス別に集計する“観察用の箱”。
// - Learner から参照しやすいグローバル統計を提供するTLS ではなく Atomic 集計)。
// - ホットパス側のオーバーヘッドはサンプリングと env で制御する。
//
// 利用例:
// - ランタイムで:
// HAKMEM_TINY_UNIFIED_SAMPLE=6 # 2^6=64 回に 1 回サンプル
// HAKMEM_LEARN=1 HAKMEM_TINY_LEARN=1 ...
// - Learner 側から:
// uint64_t hits[8], misses[8];
// hak_tiny_unified_stats_snapshot(hits, misses, 1);
#ifndef HAKMEM_TINY_UNIFIED_STATS_H
#define HAKMEM_TINY_UNIFIED_STATS_H
#include <stdint.h>
#include "hakmem_tiny_config.h" // TINY_NUM_CLASSES
// サンプリング設定を初期化する。
// ENV: HAKMEM_TINY_UNIFIED_SAMPLE = n → 2^n 回に 1 回サンプル (0: OFF)
void hak_tiny_unified_stats_init(void);
// Alloc パスの 1 回の試行を記録する。
// class_idx: Tiny クラス (0..7)
// is_hit : 1=Unified hit, 0=Unified miss (refill 側へ)
void hak_tiny_unified_stat_alloc(int class_idx, int is_hit);
// 累積ヒット/ミス統計をスナップショットする。
// reset!=0 の場合、読み取り後に 0 にリセットする。
void hak_tiny_unified_stats_snapshot(uint64_t hits[TINY_NUM_CLASSES],
uint64_t misses[TINY_NUM_CLASSES],
int reset);
#endif // HAKMEM_TINY_UNIFIED_STATS_H