Phase 4-2: - Add TinyC6UltraFreeTLS structure with 128-slot TLS freelist - Implement tiny_c6_ultra_free_fast/slow for C6 free hot path - Add c6_ultra_free_fast counter to FreePathStats - ENV gate: HAKMEM_TINY_C6_ULTRA_FREE_ENABLED (default: OFF) Phase 4-3: - Add segment learning on first C6 free via ss_fast_lookup() - Learn seg_base/seg_end from SuperSlab for range check - Increase cache capacity from 32 to 128 blocks Results: - Segment learning works: fast path captures blocks in segment - However, without alloc integration, cache fills up and overflows to legacy - Net effect: +1-3% (within noise range) - Drain strategy also tested: no benefit (equal overhead) Conclusion: - Free-only TLS cache is limited without alloc-side integration - Core v6 already has alloc/free integrated TLS (but -12% slower) - Keep as research box (ENV default OFF) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#ifndef HAKMEM_FREE_PATH_STATS_BOX_H
|
|
#define HAKMEM_FREE_PATH_STATS_BOX_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef struct FreePathStats {
|
|
uint64_t total_calls;
|
|
|
|
uint64_t c7_ultra_fast;
|
|
uint64_t c6_ultra_free_fast; // Phase 4-2: C6 ULTRA-free
|
|
uint64_t smallheap_v3_fast;
|
|
uint64_t smallheap_v6_fast;
|
|
uint64_t tiny_heap_v1_fast;
|
|
uint64_t pool_v1_fast;
|
|
uint64_t remote_free;
|
|
uint64_t super_lookup_called;
|
|
uint64_t legacy_fallback;
|
|
|
|
// Phase 4-1: Legacy per-class breakdown
|
|
uint64_t legacy_by_class[8]; // C0-C7 の Legacy fallback 内訳
|
|
} FreePathStats;
|
|
|
|
// ENV gate
|
|
static inline bool free_path_stats_enabled(void) {
|
|
static int g_enabled = -1;
|
|
if (__builtin_expect(g_enabled == -1, 0)) {
|
|
const char* e = getenv("HAKMEM_FREE_PATH_STATS");
|
|
g_enabled = (e && *e && *e != '0') ? 1 : 0;
|
|
}
|
|
return g_enabled;
|
|
}
|
|
|
|
// Global stats instance
|
|
extern FreePathStats g_free_path_stats;
|
|
|
|
// Increment macros (with unlikely guard)
|
|
#define FREE_PATH_STAT_INC(field) \
|
|
do { if (__builtin_expect(free_path_stats_enabled(), 0)) { \
|
|
g_free_path_stats.field++; \
|
|
} } while(0)
|
|
|
|
#endif // HAKMEM_FREE_PATH_STATS_BOX_H
|