Phase 35-A: BENCH_MINIMAL gate function elimination (GO +4.39%) - tiny_front_v3_enabled() → constant true - tiny_metadata_cache_enabled() → constant 0 - learner_v7_enabled() → constant false - small_learner_v2_enabled() → constant false Phase 36: Policy snapshot init-once (GO +0.71%) - small_policy_v7_snapshot() version check skip in BENCH_MINIMAL - TLS cache for policy snapshot Phase 37: Standard TLS cache (NO-GO -0.07%) - TLS cache for Standard build attempted - Runtime gate overhead negates benefit Phase 38: FAST/OBSERVE/Standard workflow established - make perf_fast, make perf_observe targets - Scorecard and documentation updates Phase 39: Hot path gate constantization (GO +1.98%) - front_gate_unified_enabled() → constant 1 - alloc_dualhot_enabled() → constant 0 - g_bench_fast_front, g_v3_enabled blocks → compile-out - free_dispatch_stats_enabled() → constant false Results: - FAST v3: 56.04M ops/s (47.4% of mimalloc) - Standard: 53.50M ops/s (45.3% of mimalloc) - M1 target (50%): 5.5% remaining 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
#ifndef HAKMEM_FREE_DISPATCH_STATS_BOX_H
|
|
#define HAKMEM_FREE_DISPATCH_STATS_BOX_H
|
|
|
|
#include "../hakmem_build_flags.h" // Phase 39: HAKMEM_BENCH_MINIMAL (GO +1.98%)
|
|
#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)
|
|
uint64_t route_core_v7; // core v7 stub (Phase v7-1)
|
|
|
|
// Performance counters
|
|
uint64_t env_checks; // ENV 読み回数(概算)
|
|
uint64_t route_for_class_calls; // tiny_route_for_class() 呼び出し回数
|
|
} FreeDispatchStats;
|
|
|
|
// ENV gate
|
|
// Phase 39: BENCH_MINIMAL → 固定 false (GO +1.98%)
|
|
static inline bool free_dispatch_stats_enabled(void) {
|
|
#if HAKMEM_BENCH_MINIMAL
|
|
return false; // FAST v3: 定数化 (stats OFF)
|
|
#else
|
|
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;
|
|
#endif
|
|
}
|
|
|
|
// 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
|