Priority-2: ENV Cache - Warm Path (FastCache/SuperSlab) getenv() 置換
変更内容: - hakmem_env_cache.h: 2つの新ENV変数を追加 (TINY_FAST_STATS, TINY_UNIFIED_CACHE) - tiny_fastcache.c: 2箇所の getenv() を置換 (TINY_PROFILE, TINY_FAST_STATS) - tiny_fastcache.h: 1箇所の getenv() を置換 (TINY_PROFILE in inline function) - superslab_slab.c: 1箇所の getenv() を置換 (TINY_SLL_DIAG) - tiny_unified_cache.c: 1箇所の getenv() を置換 (TINY_UNIFIED_CACHE) 効果: Warm path層からも syscall を排除 (ENV変数数: 28→30) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include "hakmem_tiny.h"
|
||||
#include "hakmem_tiny_superslab.h"
|
||||
#include "box/tiny_next_ptr_box.h" // Phase E1-CORRECT: Box API
|
||||
#include "hakmem_env_cache.h" // Priority-2: ENV cache (eliminate syscalls)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -76,9 +77,9 @@ static __thread uint64_t g_refill_total_blocks = 0; // Total blocks actually al
|
||||
int g_profile_enabled = -1; // -1: uninitialized, 0: off, 1: on (extern in header)
|
||||
|
||||
static inline int profile_enabled(void) {
|
||||
// Priority-2: Use cached ENV (eliminate lazy-init syscall overhead)
|
||||
if (__builtin_expect(g_profile_enabled == -1, 0)) {
|
||||
const char* env = getenv("HAKMEM_TINY_PROFILE");
|
||||
g_profile_enabled = (env && *env && *env != '0') ? 1 : 0;
|
||||
g_profile_enabled = HAK_ENV_TINY_PROFILE();
|
||||
}
|
||||
return g_profile_enabled;
|
||||
}
|
||||
@ -204,15 +205,8 @@ void tiny_fast_drain(int class_idx) {
|
||||
// ========== Debug Stats ==========
|
||||
|
||||
void tiny_fast_print_stats(void) {
|
||||
static const char* env = NULL;
|
||||
static int checked = 0;
|
||||
|
||||
if (!checked) {
|
||||
env = getenv("HAKMEM_TINY_FAST_STATS");
|
||||
checked = 1;
|
||||
}
|
||||
|
||||
if (env && *env && *env != '0') {
|
||||
// Priority-2: Use cached ENV (eliminate static lazy-init overhead)
|
||||
if (HAK_ENV_TINY_FAST_STATS()) {
|
||||
fprintf(stderr, "[TINY_FAST] refills=%lu drains=%lu\n",
|
||||
(unsigned long)g_tiny_fast_refill_count,
|
||||
(unsigned long)g_tiny_fast_drain_count);
|
||||
|
||||
Reference in New Issue
Block a user