Implement C6 ULTRA intrusive LIFO freelist with ENV gating: - Single-linked LIFO using next pointer at USER+1 offset - tiny_next_store/tiny_next_load for pointer access (single source of truth) - Segment learning via ss_fast_lookup (per-class seg_base/seg_end) - ENV gate: HAKMEM_TINY_C6_ULTRA_INTRUSIVE_FL (default OFF) - Counters: c6_ifl_push/pop/fallback in FREE_PATH_STATS Files: - core/box/tiny_ultra_tls_box.h: Added c6_head field for intrusive LIFO - core/box/tiny_ultra_tls_box.c: Pop/push with intrusive branching (case 6) - core/box/tiny_c6_ultra_intrusive_env_box.h: ENV gate (new) - core/box/tiny_c6_intrusive_freelist_box.h: L1 pure LIFO (new) - core/tiny_debug_ring.h: C6_IFL events - core/box/free_path_stats_box.h/c: c6_ifl_* counters A/B Test Results (1M iterations, ws=200, 257-512B): - ENV_OFF (array): 56.6 Mop/s avg - ENV_ON (intrusive): 57.6 Mop/s avg (+1.8%, within noise) - Counters verified: c6_ifl_push=265890, c6_ifl_pop=265815, fallback=0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
55 lines
2.3 KiB
C
55 lines
2.3 KiB
C
#include "free_path_stats_box.h"
|
|
#include <stdio.h>
|
|
|
|
FreePathStats g_free_path_stats = {0};
|
|
|
|
// Helper function for pool_api.inc.h (to avoid inline include issues)
|
|
void free_path_stat_inc_pool_v1_fast(void) {
|
|
if (__builtin_expect(free_path_stats_enabled(), 0)) {
|
|
g_free_path_stats.pool_v1_fast++;
|
|
}
|
|
}
|
|
|
|
__attribute__((destructor))
|
|
static void free_path_stats_dump(void) {
|
|
if (!free_path_stats_enabled()) {
|
|
return;
|
|
}
|
|
|
|
fprintf(stderr, "[FREE_PATH_STATS] total=%lu c7_ultra=%lu c6_ultra_free=%lu c6_ultra_alloc=%lu c5_ultra_free=%lu c5_ultra_alloc=%lu c4_ultra_free=%lu c4_ultra_alloc=%lu small_v3=%lu v6=%lu tiny_v1=%lu pool_v1=%lu remote=%lu super_lookup=%lu legacy_fb=%lu\n",
|
|
g_free_path_stats.total_calls,
|
|
g_free_path_stats.c7_ultra_fast,
|
|
g_free_path_stats.c6_ultra_free_fast, // Phase 4-2
|
|
g_free_path_stats.c6_ultra_alloc_hit, // Phase 4-4
|
|
g_free_path_stats.c5_ultra_free_fast, // Phase 5-1
|
|
g_free_path_stats.c5_ultra_alloc_hit, // Phase 5-2
|
|
g_free_path_stats.c4_ultra_free_fast, // Phase 6
|
|
g_free_path_stats.c4_ultra_alloc_hit, // Phase 6
|
|
g_free_path_stats.smallheap_v3_fast,
|
|
g_free_path_stats.smallheap_v6_fast,
|
|
g_free_path_stats.tiny_heap_v1_fast,
|
|
g_free_path_stats.pool_v1_fast,
|
|
g_free_path_stats.remote_free,
|
|
g_free_path_stats.super_lookup_called,
|
|
g_free_path_stats.legacy_fallback);
|
|
|
|
// Phase 4-1: Legacy per-class breakdown
|
|
fprintf(stderr, "[FREE_PATH_STATS_LEGACY_BY_CLASS] c0=%lu c1=%lu c2=%lu c3=%lu c4=%lu c5=%lu c6=%lu c7=%lu\n",
|
|
g_free_path_stats.legacy_by_class[0],
|
|
g_free_path_stats.legacy_by_class[1],
|
|
g_free_path_stats.legacy_by_class[2],
|
|
g_free_path_stats.legacy_by_class[3],
|
|
g_free_path_stats.legacy_by_class[4],
|
|
g_free_path_stats.legacy_by_class[5],
|
|
g_free_path_stats.legacy_by_class[6],
|
|
g_free_path_stats.legacy_by_class[7]);
|
|
|
|
// Phase TLS-UNIFY-3: C6 Intrusive Freelist stats
|
|
fprintf(stderr, "[FREE_PATH_STATS_C6_IFL] push=%lu pop=%lu fallback=%lu\n",
|
|
g_free_path_stats.c6_ifl_push,
|
|
g_free_path_stats.c6_ifl_pop,
|
|
g_free_path_stats.c6_ifl_fallback);
|
|
|
|
fflush(stderr);
|
|
}
|