Phase 15: Box BenchMeta separation + ExternalGuard debug + investigation report
- Implement Box BenchMeta pattern in bench_random_mixed.c (BENCH_META_CALLOC/FREE) - Add enhanced debug logging to external_guard_box.h (caller tracking, FG classification) - Document investigation in PHASE15_BUG_ANALYSIS.md Issue: Page-aligned MIDCAND pointer not in SuperSlab registry → ExternalGuard → crash Hypothesis: May be pre-existing SuperSlab bug (not Phase 15-specific) Next: Test in Phase 14-C to verify
This commit is contained in:
@ -1767,6 +1767,10 @@ TinySlab* hak_tiny_owner_slab(void* ptr) {
|
||||
__thread TinyHeapV2Mag g_tiny_heap_v2_mag[TINY_NUM_CLASSES];
|
||||
__thread TinyHeapV2Stats g_tiny_heap_v2_stats[TINY_NUM_CLASSES];
|
||||
|
||||
// Phase 14: TinyUltraHot - Ultra-fast C1/C2 path (L1 dcache miss reduction)
|
||||
#include "front/tiny_ultra_hot.h"
|
||||
__thread TinyUltraHot g_ultra_hot;
|
||||
|
||||
// Box 6: Free Fast Path (Layer 2 - 2-3 instructions)
|
||||
#include "tiny_free_fast.inc.h"
|
||||
|
||||
@ -2090,3 +2094,62 @@ void tiny_heap_v2_print_stats(void) {
|
||||
fprintf(stderr, "==============================\n\n");
|
||||
}
|
||||
|
||||
// Phase 14 + Phase 14-B: UltraHot statistics (C2-C5)
|
||||
void ultra_hot_print_stats(void) {
|
||||
extern __thread TinyUltraHot g_ultra_hot;
|
||||
|
||||
static int g_stats_enable = -1;
|
||||
if (g_stats_enable == -1) {
|
||||
const char* e = getenv("HAKMEM_TINY_ULTRA_HOT_STATS");
|
||||
g_stats_enable = (e && *e && *e != '0') ? 1 : 0;
|
||||
}
|
||||
if (!g_stats_enable) return;
|
||||
|
||||
fprintf(stderr, "\n=== TinyUltraHot Statistics (Phase 14 + 14-B) ===\n");
|
||||
|
||||
// C1 (16B) stats - Phase 14
|
||||
uint64_t c1_total = g_ultra_hot.c1_alloc_calls;
|
||||
if (c1_total > 0) {
|
||||
double c1_hit_rate = 100.0 * g_ultra_hot.c1_hits / c1_total;
|
||||
fprintf(stderr, "[C2-16B] alloc=%lu hits=%lu (%.1f%%) misses=%lu\n",
|
||||
c1_total, g_ultra_hot.c1_hits, c1_hit_rate, g_ultra_hot.c1_misses);
|
||||
fprintf(stderr, " free=%lu free_hits=%lu\n",
|
||||
g_ultra_hot.c1_free_calls, g_ultra_hot.c1_free_hits);
|
||||
}
|
||||
|
||||
// C2 (32B) stats - Phase 14
|
||||
uint64_t c2_total = g_ultra_hot.c2_alloc_calls;
|
||||
if (c2_total > 0) {
|
||||
double c2_hit_rate = 100.0 * g_ultra_hot.c2_hits / c2_total;
|
||||
fprintf(stderr, "[C3-32B] alloc=%lu hits=%lu (%.1f%%) misses=%lu\n",
|
||||
c2_total, g_ultra_hot.c2_hits, c2_hit_rate, g_ultra_hot.c2_misses);
|
||||
fprintf(stderr, " free=%lu free_hits=%lu\n",
|
||||
g_ultra_hot.c2_free_calls, g_ultra_hot.c2_free_hits);
|
||||
}
|
||||
|
||||
// C4 (64B) stats - Phase 14-B NEW
|
||||
uint64_t c4_total = g_ultra_hot.c4_alloc_calls;
|
||||
if (c4_total > 0) {
|
||||
double c4_hit_rate = 100.0 * g_ultra_hot.c4_hits / c4_total;
|
||||
fprintf(stderr, "[C4-64B] alloc=%lu hits=%lu (%.1f%%) misses=%lu (NEW Phase 14-B)\n",
|
||||
c4_total, g_ultra_hot.c4_hits, c4_hit_rate, g_ultra_hot.c4_misses);
|
||||
fprintf(stderr, " free=%lu free_hits=%lu\n",
|
||||
g_ultra_hot.c4_free_calls, g_ultra_hot.c4_free_hits);
|
||||
}
|
||||
|
||||
// C5 (128B) stats - Phase 14-B NEW
|
||||
uint64_t c5_total = g_ultra_hot.c5_alloc_calls;
|
||||
if (c5_total > 0) {
|
||||
double c5_hit_rate = 100.0 * g_ultra_hot.c5_hits / c5_total;
|
||||
fprintf(stderr, "[C5-128B] alloc=%lu hits=%lu (%.1f%%) misses=%lu (NEW Phase 14-B)\n",
|
||||
c5_total, g_ultra_hot.c5_hits, c5_hit_rate, g_ultra_hot.c5_misses);
|
||||
fprintf(stderr, " free=%lu free_hits=%lu\n",
|
||||
g_ultra_hot.c5_free_calls, g_ultra_hot.c5_free_hits);
|
||||
}
|
||||
|
||||
if (c1_total == 0 && c2_total == 0 && c4_total == 0 && c5_total == 0) {
|
||||
fprintf(stderr, "(No UltraHot allocs recorded)\n");
|
||||
}
|
||||
fprintf(stderr, "==================================================\n\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user