ENV cleanup: Add RELEASE guards to DEBUG ENV variables (14 vars)
Added compile-time guards (#if HAKMEM_BUILD_RELEASE) to eliminate DEBUG ENV variable overhead in RELEASE builds. Variables guarded (14 total): - HAKMEM_TINY_TRACE_RING, HAKMEM_TINY_DUMP_RING_ATEXIT - HAKMEM_TINY_RF_TRACE, HAKMEM_TINY_MAILBOX_TRACE - HAKMEM_TINY_MAILBOX_TRACE_LIMIT, HAKMEM_TINY_MAILBOX_SLOWDISC - HAKMEM_TINY_MAILBOX_SLOWDISC_PERIOD - HAKMEM_SS_PREWARM_DEBUG, HAKMEM_SS_FREE_DEBUG - HAKMEM_TINY_FRONT_METRICS, HAKMEM_TINY_FRONT_DUMP - HAKMEM_TINY_COUNTERS_DUMP, HAKMEM_TINY_REFILL_DUMP - HAKMEM_PTR_TRACE_DUMP, HAKMEM_PTR_TRACE_VERBOSE Files modified (9 core files): - core/tiny_debug_ring.c (ring trace/dump) - core/box/mailbox_box.c (mailbox trace + slowdisc) - core/tiny_refill.h (refill trace) - core/hakmem_tiny_superslab.c (superslab debug) - core/box/ss_allocation_box.c (allocation debug) - core/tiny_superslab_free.inc.h (free debug) - core/box/front_metrics_box.c (frontend metrics) - core/hakmem_tiny_stats.c (stats dump) - core/ptr_trace.h (pointer trace) Bug fixes during implementation: 1. mailbox_box.c - Fixed variable scope (moved 'used' outside guard) 2. hakmem_tiny_stats.c - Fixed incomplete declarations (on1, on2) Impact: - Binary size: -85KB total - bench_random_mixed_hakmem: 319K → 305K (-14K, -4.4%) - larson_hakmem: 380K → 309K (-71K, -18.7%) - Performance: No regression (16.9-17.9M ops/s maintained) - Functional: All tests pass (Random Mixed + Larson) - Behavior: DEBUG ENV vars correctly ignored in RELEASE builds Testing: - Build: Clean compilation (warnings only, pre-existing) - 100K Random Mixed: 16.9-17.9M ops/s (PASS) - 10K Larson: 25.9M ops/s (PASS) - DEBUG ENV verification: Correctly ignored (PASS) Result: 14 DEBUG ENV variables now have zero overhead in RELEASE builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -191,6 +191,9 @@ static void tiny_debug_ring_sigusr(int signo, siginfo_t* info, void* uctx) {
|
||||
}
|
||||
|
||||
void tiny_debug_ring_init(void) {
|
||||
#if HAKMEM_BUILD_RELEASE
|
||||
return; // No env reads or hooks in release builds
|
||||
#endif
|
||||
if (g_tiny_ring_enabled) return;
|
||||
const char* env = getenv("HAKMEM_TINY_TRACE_RING");
|
||||
if (!(env && *env && env[0] != '0')) {
|
||||
@ -228,6 +231,9 @@ static void tiny_debug_ring_ctor(void) {
|
||||
|
||||
__attribute__((destructor))
|
||||
static void tiny_debug_ring_dtor(void) {
|
||||
#if HAKMEM_BUILD_RELEASE
|
||||
return; // Skip env access in release builds
|
||||
#endif
|
||||
const char* e = getenv("HAKMEM_TINY_DUMP_RING_ATEXIT");
|
||||
if (e && *e && e[0] != '0') {
|
||||
tiny_debug_ring_dump(STDERR_FILENO, 0);
|
||||
|
||||
Reference in New Issue
Block a user