Priority-2: ENV Cache - SFC (Super Front Cache) getenv() 置換

変更内容:
- hakmem_env_cache.h: 4つの新ENV変数を追加
  (SFC_DEBUG, SFC_ENABLE, SFC_CAPACITY, SFC_REFILL_COUNT)
- hakmem_tiny_sfc.c: 4箇所の getenv() を置換
  (init時のdebug/enable/capacity/refill設定)
  ※Per-class動的変数(2箇所)は初期化時のみのため後回し

効果: SFC層からも syscall を排除 (ENV変数数: 37→41)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-02 20:32:22 +09:00
parent 38ce143ddf
commit b80b3d445e
2 changed files with 33 additions and 25 deletions

View File

@ -49,12 +49,16 @@ typedef struct {
// ===== Warm Path: Lazy Init (1 variable) =====
int ss_map_trace; // HAKMEM_SS_MAP_TRACE (default: 0)
// ===== Warm Path: FastCache (5 variables) =====
// ===== Warm Path: FastCache (9 variables) =====
int tiny_fast_debug; // HAKMEM_TINY_FAST_DEBUG (default: 0)
int tiny_fast_debug_max; // HAKMEM_TINY_FAST_DEBUG_MAX (default: 0)
int tiny_front_direct; // HAKMEM_TINY_FRONT_DIRECT (default: 0)
int tiny_fast_stats; // HAKMEM_TINY_FAST_STATS (default: 0)
int tiny_unified_cache; // HAKMEM_TINY_UNIFIED_CACHE (default: 1)
int sfc_debug; // HAKMEM_SFC_DEBUG (default: 0)
int sfc_enable; // HAKMEM_SFC_ENABLE (default: 1)
int sfc_capacity; // HAKMEM_SFC_CAPACITY (default: 128)
int sfc_refill_count; // HAKMEM_SFC_REFILL_COUNT (default: 16)
// ===== Cold Path: Headers/Debug (12 variables) =====
int tiny_restore_header; // HAKMEM_TINY_RESTORE_HEADER (default: 0)
@ -171,6 +175,18 @@ static inline void hakmem_env_cache_init(void) {
e = getenv("HAKMEM_TINY_UNIFIED_CACHE");
// Default: 1 (enabled), set HAKMEM_TINY_UNIFIED_CACHE=0 to disable
g_hak_env_cache.tiny_unified_cache = (e && *e && *e == '0') ? 0 : 1;
e = getenv("HAKMEM_SFC_DEBUG");
g_hak_env_cache.sfc_debug = (e && *e && *e != '0') ? 1 : 0;
e = getenv("HAKMEM_SFC_ENABLE");
g_hak_env_cache.sfc_enable = (e && *e && *e != '0') ? 1 : 0;
e = getenv("HAKMEM_SFC_CAPACITY");
g_hak_env_cache.sfc_capacity = (e && *e) ? atoi(e) : 128;
e = getenv("HAKMEM_SFC_REFILL_COUNT");
g_hak_env_cache.sfc_refill_count = (e && *e) ? atoi(e) : 16;
}
// ===== Cold Path: Headers/Debug =====
@ -217,7 +233,7 @@ static inline void hakmem_env_cache_init(void) {
#if !HAKMEM_BUILD_RELEASE
// Debug: Print cache summary (stderr only)
if (!g_hak_env_cache.quiet) {
fprintf(stderr, "[ENV_CACHE_INIT] Parsed %d ENV variables at startup\n", 37);
fprintf(stderr, "[ENV_CACHE_INIT] Parsed %d ENV variables at startup\n", 41);
fprintf(stderr, "[ENV_CACHE_INIT] Hot path syscalls eliminated: ~2000/sec → 0/sec\n");
fflush(stderr);
}
@ -251,6 +267,10 @@ static inline void hakmem_env_cache_init(void) {
#define HAK_ENV_TINY_FRONT_DIRECT() (g_hak_env_cache.tiny_front_direct)
#define HAK_ENV_TINY_FAST_STATS() (g_hak_env_cache.tiny_fast_stats)
#define HAK_ENV_TINY_UNIFIED_CACHE() (g_hak_env_cache.tiny_unified_cache)
#define HAK_ENV_SFC_DEBUG() (g_hak_env_cache.sfc_debug)
#define HAK_ENV_SFC_ENABLE() (g_hak_env_cache.sfc_enable)
#define HAK_ENV_SFC_CAPACITY() (g_hak_env_cache.sfc_capacity)
#define HAK_ENV_SFC_REFILL_COUNT() (g_hak_env_cache.sfc_refill_count)
// Cold path accessors
#define HAK_ENV_TINY_RESTORE_HEADER() (g_hak_env_cache.tiny_restore_header)