Priority-2 ENV Cache: hakmem_smallmid.c (1変数追加、1箇所置換)
【追加ENV変数】
- HAKMEM_SMALLMID_ENABLE (default: 0)
【置換ファイル】
- core/hakmem_smallmid.c (1箇所 → ENV Cache)
【変更詳細】
1. ENV Cache (hakmem_env_cache.h):
- 構造体に1変数追加 (46→47変数)
- hakmem_env_cache_init()に初期化追加
- アクセサマクロ追加
- カウント更新: 46→47
2. hakmem_smallmid.c:
- smallmid_is_enabled():
getenv("HAKMEM_SMALLMID_ENABLE") → HAK_ENV_SMALLMID_ENABLE()
- #include "hakmem_env_cache.h" 追加
【効果】
- SmallMid有効化チェックからgetenv()呼び出しを排除
- Warm path起動時のENV参照を1回に削減
【テスト】
✅ make shared → 成功
✅ /tmp/test_mixed3_final → PASSED
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -81,6 +81,9 @@ typedef struct {
|
||||
int tiny_tension_drain_enable; // HAKMEM_TINY_TENSION_DRAIN_ENABLE (default: 1)
|
||||
int tiny_tension_drain_threshold; // HAKMEM_TINY_TENSION_DRAIN_THRESHOLD (default: 1024)
|
||||
|
||||
// ===== Warm Path: SmallMid (1 variable) =====
|
||||
int smallmid_enable; // HAKMEM_SMALLMID_ENABLE (default: 0)
|
||||
|
||||
} HakEnvCache;
|
||||
|
||||
// Global cache instance (initialized once at startup)
|
||||
@ -258,10 +261,17 @@ static inline void hakmem_env_cache_init(void) {
|
||||
if (g_hak_env_cache.tiny_tension_drain_threshold > 65536) g_hak_env_cache.tiny_tension_drain_threshold = 65536;
|
||||
}
|
||||
|
||||
// ===== Warm Path: SmallMid =====
|
||||
{
|
||||
const char* e;
|
||||
e = getenv("HAKMEM_SMALLMID_ENABLE");
|
||||
g_hak_env_cache.smallmid_enable = (e && atoi(e) == 1) ? 1 : 0; // default: 0 (OFF)
|
||||
}
|
||||
|
||||
#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", 46);
|
||||
fprintf(stderr, "[ENV_CACHE_INIT] Parsed %d ENV variables at startup\n", 47);
|
||||
fprintf(stderr, "[ENV_CACHE_INIT] Hot path syscalls eliminated: ~2000/sec → 0/sec\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
@ -321,4 +331,7 @@ static inline void hakmem_env_cache_init(void) {
|
||||
#define HAK_ENV_TINY_TENSION_DRAIN_ENABLE() (g_hak_env_cache.tiny_tension_drain_enable)
|
||||
#define HAK_ENV_TINY_TENSION_DRAIN_THRESHOLD() (g_hak_env_cache.tiny_tension_drain_threshold)
|
||||
|
||||
// Warm path: SmallMid
|
||||
#define HAK_ENV_SMALLMID_ENABLE() (g_hak_env_cache.smallmid_enable)
|
||||
|
||||
#endif // HAKMEM_ENV_CACHE_H
|
||||
|
||||
Reference in New Issue
Block a user