Restore C7 Warm/TLS carve for release and add policy scaffolding
This commit is contained in:
42
core/box/tiny_class_stats_box.h
Normal file
42
core/box/tiny_class_stats_box.h
Normal file
@ -0,0 +1,42 @@
|
||||
// tiny_class_stats_box.h - Lightweight per-thread class stats (OBSERVE layer)
|
||||
//
|
||||
// Purpose:
|
||||
// - Provide per-class counters without atomics for cheap observation.
|
||||
// - Hot paths call small inline helpers; aggregation/printing can be added later.
|
||||
|
||||
#ifndef TINY_CLASS_STATS_BOX_H
|
||||
#define TINY_CLASS_STATS_BOX_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../hakmem_tiny_config.h"
|
||||
|
||||
typedef struct TinyClassStatsThread {
|
||||
uint64_t uc_miss[TINY_NUM_CLASSES]; // unified_cache_refill() hits
|
||||
uint64_t warm_hit[TINY_NUM_CLASSES]; // warm pool successes
|
||||
uint64_t shared_lock[TINY_NUM_CLASSES]; // shared pool lock acquisitions (hook as needed)
|
||||
} TinyClassStatsThread;
|
||||
|
||||
extern __thread TinyClassStatsThread g_tiny_class_stats;
|
||||
|
||||
static inline void tiny_class_stats_on_uc_miss(int ci) {
|
||||
if (ci >= 0 && ci < TINY_NUM_CLASSES) {
|
||||
g_tiny_class_stats.uc_miss[ci]++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tiny_class_stats_on_warm_hit(int ci) {
|
||||
if (ci >= 0 && ci < TINY_NUM_CLASSES) {
|
||||
g_tiny_class_stats.warm_hit[ci]++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tiny_class_stats_on_shared_lock(int ci) {
|
||||
if (ci >= 0 && ci < TINY_NUM_CLASSES) {
|
||||
g_tiny_class_stats.shared_lock[ci]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: reset per-thread counters (cold path only).
|
||||
void tiny_class_stats_reset_thread(void);
|
||||
|
||||
#endif // TINY_CLASS_STATS_BOX_H
|
||||
Reference in New Issue
Block a user