42 lines
1.4 KiB
C
42 lines
1.4 KiB
C
|
|
// warm_pool_stats_box.h - Warm Pool Statistics Box
|
||
|
|
// Purpose: Encapsulate warm pool statistics recording with inline APIs
|
||
|
|
// License: MIT
|
||
|
|
// Date: 2025-12-04
|
||
|
|
|
||
|
|
#ifndef HAK_WARM_POOL_STATS_BOX_H
|
||
|
|
#define HAK_WARM_POOL_STATS_BOX_H
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
#include "../hakmem_tiny_config.h"
|
||
|
|
#include "../front/tiny_warm_pool.h"
|
||
|
|
|
||
|
|
// ============================================================================
|
||
|
|
// External TLS Statistics (defined in core/front/tiny_unified_cache.c)
|
||
|
|
// ============================================================================
|
||
|
|
|
||
|
|
extern __thread TinyWarmPoolStats g_warm_pool_stats[TINY_NUM_CLASSES];
|
||
|
|
|
||
|
|
// ============================================================================
|
||
|
|
// Inline Statistics Recording API
|
||
|
|
// ============================================================================
|
||
|
|
|
||
|
|
// Record a warm pool hit
|
||
|
|
// Called when warm_pool_pop() succeeds and carve produces blocks
|
||
|
|
static inline void warm_pool_record_hit(int class_idx) {
|
||
|
|
g_warm_pool_stats[class_idx].hits++;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Record a warm pool miss
|
||
|
|
// Called when warm_pool_pop() returns NULL (pool empty)
|
||
|
|
static inline void warm_pool_record_miss(int class_idx) {
|
||
|
|
g_warm_pool_stats[class_idx].misses++;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Record a warm pool prefill event
|
||
|
|
// Called when pool is empty and we do secondary prefill
|
||
|
|
static inline void warm_pool_record_prefilled(int class_idx) {
|
||
|
|
g_warm_pool_stats[class_idx].prefilled++;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif // HAK_WARM_POOL_STATS_BOX_H
|