Phase 36-37: TinyHotHeap v2 HotBox redesign and C7 current_page policy fixes
- Redefine TinyHotHeap v2 as per-thread Hot Box with clear boundaries - Add comprehensive OS statistics tracking for SS allocations - Implement route-based free handling for TinyHeap v2 - Add C6/C7 debugging and statistics improvements - Update documentation with implementation guidelines and analysis - Add new box headers for stats, routing, and front-end management
This commit is contained in:
42
core/box/tiny_front_stats_box.h
Normal file
42
core/box/tiny_front_stats_box.h
Normal file
@ -0,0 +1,42 @@
|
||||
// tiny_front_stats_box.h - Front class distribution counters (ENV gated)
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdatomic.h>
|
||||
#include "../hakmem_tiny_config.h"
|
||||
|
||||
extern _Atomic uint64_t g_tiny_front_alloc_class[TINY_NUM_CLASSES];
|
||||
extern _Atomic uint64_t g_tiny_front_free_class[TINY_NUM_CLASSES];
|
||||
|
||||
static inline int tiny_front_class_stats_enabled(void) {
|
||||
static int g = -1;
|
||||
if (__builtin_expect(g == -1, 0)) {
|
||||
const char* e = getenv("HAKMEM_TINY_FRONT_CLASS_STATS");
|
||||
g = (e && *e && *e != '0') ? 1 : 0;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
static inline int tiny_front_class_stats_dump_enabled(void) {
|
||||
static int g = -1;
|
||||
if (__builtin_expect(g == -1, 0)) {
|
||||
const char* e = getenv("HAKMEM_TINY_FRONT_CLASS_STATS_DUMP");
|
||||
const char* e2 = getenv("HAKMEM_TINY_FRONT_CLASS_STATS");
|
||||
g = ((e && *e && *e != '0') || (e2 && *e2 && *e2 != '0')) ? 1 : 0;
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
static inline void tiny_front_alloc_stat_inc(int class_idx) {
|
||||
if (__builtin_expect(tiny_front_class_stats_enabled(), 0)) {
|
||||
atomic_fetch_add_explicit(&g_tiny_front_alloc_class[class_idx], 1, memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tiny_front_free_stat_inc(int class_idx) {
|
||||
if (__builtin_expect(tiny_front_class_stats_enabled(), 0)) {
|
||||
atomic_fetch_add_explicit(&g_tiny_front_free_class[class_idx], 1, memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user