Phase 4b: Add master debug control (HAKMEM_DEBUG_ALL/LEVEL)
Add centralized debug control system that allows enabling all debug modules at once, while maintaining backwards compatibility with individual module ENVs. New file: core/hakmem_debug_master.h - HAKMEM_DEBUG_ALL=1: Enable all debug modules - HAKMEM_DEBUG_LEVEL=N: Set debug level (0=off, 1=critical, 2=normal, 3=verbose) - HAKMEM_QUIET=1: Suppress all debug (highest priority) - hak_debug_check(): Check if module should enable debug - hak_is_quiet(): Quick check for quiet mode Priority order: 1. HAKMEM_QUIET=1 → suppress all 2. Specific module ENV (e.g., HAKMEM_SFC_DEBUG=1) 3. HAKMEM_DEBUG_ALL=1 4. HAKMEM_DEBUG_LEVEL >= threshold Updated files: - core/hakmem_elo.c: Use hak_is_quiet() instead of local implementation - core/hakmem_shared_pool.c: Use hak_debug_check() for lock stats Performance: No regression (71.5M ops/s maintained) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include "hakmem_shared_pool.h"
|
||||
#include "hakmem_tiny_superslab.h"
|
||||
#include "hakmem_tiny_superslab_constants.h"
|
||||
#include "hakmem_debug_master.h" // Phase 4b: Master debug control
|
||||
#include "box/ss_slab_meta_box.h" // Phase 3d-A: SlabMeta Box boundary
|
||||
#include "box/ss_hot_cold_box.h" // Phase 12-1.1: EMPTY slab marking
|
||||
#include "box/pagefault_telemetry_box.h" // Box PageFaultTelemetry (PF_BUCKET_SS_META)
|
||||
@ -25,10 +26,10 @@ static int g_lock_stats_enabled = -1; // -1=uninitialized, 0=of
|
||||
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
// Initialize lock stats from environment variable
|
||||
// Phase 4b: Now uses hak_debug_check() for master debug control support
|
||||
static inline void lock_stats_init(void) {
|
||||
if (__builtin_expect(g_lock_stats_enabled == -1, 0)) {
|
||||
const char* env = getenv("HAKMEM_SHARED_POOL_LOCK_STATS");
|
||||
g_lock_stats_enabled = (env && *env && *env != '0') ? 1 : 0;
|
||||
g_lock_stats_enabled = hak_debug_check("HAKMEM_SHARED_POOL_LOCK_STATS");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user