Cleanup: Wrap shared_pool debug fprintf in #if !HAKMEM_BUILD_RELEASE
- Lock stats (P0 instrumentation): ~10 fprintf wrapped - Stage stats (S1/S2/S3 breakdown): ~8 fprintf wrapped - Release build now has no-op stubs for stats init functions - Data collection APIs kept for learning layer compatibility
This commit is contained in:
@ -14,8 +14,9 @@
|
||||
#include <sys/mman.h> // For mmap/munmap (used in shared_pool_ensure_capacity_unlocked)
|
||||
|
||||
// ============================================================================
|
||||
// P0 Lock Contention Instrumentation
|
||||
// P0 Lock Contention Instrumentation (Debug build only)
|
||||
// ============================================================================
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
static _Atomic uint64_t g_lock_acquire_count = 0; // Total lock acquisitions
|
||||
static _Atomic uint64_t g_lock_release_count = 0; // Total lock releases
|
||||
static _Atomic uint64_t g_lock_acquire_slab_count = 0; // Locks from acquire_slab path
|
||||
@ -54,6 +55,10 @@ static void __attribute__((destructor)) lock_stats_report(void) {
|
||||
fprintf(stderr, "===================================\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
#else
|
||||
// Release build: No-op stubs
|
||||
static inline void lock_stats_init(void) {}
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// SP Acquire Stage Statistics (Stage1/2/3 breakdown)
|
||||
@ -63,6 +68,8 @@ static _Atomic uint64_t g_sp_stage2_hits[TINY_NUM_CLASSES_SS];
|
||||
static _Atomic uint64_t g_sp_stage3_hits[TINY_NUM_CLASSES_SS];
|
||||
// Data collection gate (0=off, 1=on). 学習層からも有効化される。
|
||||
static int g_sp_stage_stats_enabled = 0;
|
||||
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
// Logging gate for destructor(ENV: HAKMEM_SHARED_POOL_STAGE_STATS)
|
||||
static int g_sp_stage_stats_log_enabled = -1; // -1=uninitialized, 0=off, 1=on
|
||||
|
||||
@ -106,7 +113,11 @@ static void __attribute__((destructor)) sp_stage_stats_report(void) {
|
||||
}
|
||||
fprintf(stderr, "====================================\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Release build: No-op stubs
|
||||
static inline void sp_stage_stats_init(void) {}
|
||||
#endif
|
||||
|
||||
// Snapshot Tiny-related backend metrics for learner / observability.
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user