Merge separate g_tls_sll_head[] and g_tls_sll_count[] arrays into unified TinyTLSSLL struct to improve L1D cache locality. Expected performance gain: +12-18% from reducing cache line splits (2 loads → 1 load per operation). Changes: - core/hakmem_tiny.h: Add TinyTLSSLL type (16B aligned, head+count+pad) - core/hakmem_tiny.c: Replace separate arrays with g_tls_sll[8] - core/box/tls_sll_box.h: Update Box API (13 sites) for unified access - Updated 32+ files: All g_tls_sll_head[i] → g_tls_sll[i].head - Updated 32+ files: All g_tls_sll_count[i] → g_tls_sll[i].count - core/hakmem_tiny_integrity.h: Unified canary guards - core/box/integrity_box.c: Simplified canary validation - Makefile: Added core/box/tiny_sizeclass_hist_box.o to link Build: ✅ PASS (10K ops sanity test) Warnings: Only pre-existing LTO type mismatches (unrelated) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
1.6 KiB
C
38 lines
1.6 KiB
C
// 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
|
||
|