47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
|
|
#ifndef HAKMEM_FREE_DISPATCH_STATS_BOX_H
|
||
|
|
#define HAKMEM_FREE_DISPATCH_STATS_BOX_H
|
||
|
|
|
||
|
|
#include <stdint.h>
|
||
|
|
#include <stdbool.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
|
||
|
|
typedef struct FreeDispatchStats {
|
||
|
|
uint64_t total_calls;
|
||
|
|
|
||
|
|
// Domain classification
|
||
|
|
uint64_t domain_tiny;
|
||
|
|
uint64_t domain_mid;
|
||
|
|
uint64_t domain_large;
|
||
|
|
|
||
|
|
// Route classification (tiny domain)
|
||
|
|
uint64_t route_ultra; // C4-C7 ULTRA 直行
|
||
|
|
uint64_t route_tiny_legacy; // Tiny legacy path
|
||
|
|
uint64_t route_pool_v1; // pool v1 経由
|
||
|
|
uint64_t route_core_v6; // core v6 (C6-only)
|
||
|
|
|
||
|
|
// Performance counters
|
||
|
|
uint64_t env_checks; // ENV 読み回数(概算)
|
||
|
|
uint64_t route_for_class_calls; // tiny_route_for_class() 呼び出し回数
|
||
|
|
} FreeDispatchStats;
|
||
|
|
|
||
|
|
// ENV gate
|
||
|
|
static inline bool free_dispatch_stats_enabled(void) {
|
||
|
|
static int g_enabled = -1;
|
||
|
|
if (__builtin_expect(g_enabled == -1, 0)) {
|
||
|
|
const char* e = getenv("HAKMEM_FREE_DISPATCH_STATS");
|
||
|
|
g_enabled = (e && *e && *e != '0') ? 1 : 0;
|
||
|
|
}
|
||
|
|
return g_enabled;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Global stats instance
|
||
|
|
extern FreeDispatchStats g_free_dispatch_stats;
|
||
|
|
|
||
|
|
// Increment macros (with unlikely guard)
|
||
|
|
#define FREE_DISPATCH_STAT_INC(field) \
|
||
|
|
do { if (__builtin_expect(free_dispatch_stats_enabled(), 0)) { \
|
||
|
|
g_free_dispatch_stats.field++; \
|
||
|
|
} } while(0)
|
||
|
|
|
||
|
|
#endif // HAKMEM_FREE_DISPATCH_STATS_BOX_H
|