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:
@ -9,6 +9,7 @@
|
||||
#include "hakmem_stats_master.h" // Phase 4d: Master stats control
|
||||
#include "tiny_tls.h"
|
||||
#include "box/tls_sll_box.h" // static inline tls_sll_pop/push API (Box TLS-SLL)
|
||||
#include "hakmem_env_cache.h" // Priority-2: ENV cache (eliminate syscalls)
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -49,37 +50,24 @@ static int g_sfc_refill_override[TINY_NUM_CLASSES] = {0};
|
||||
// ============================================================================
|
||||
|
||||
void sfc_init(void) {
|
||||
// Cache debug flag once (hot paths reuse g_sfc_debug)
|
||||
const char* env_debug = getenv("HAKMEM_SFC_DEBUG");
|
||||
g_sfc_debug = (env_debug && *env_debug && *env_debug != '0') ? 1 : 0;
|
||||
|
||||
// Parse ENV: HAKMEM_SFC_ENABLE
|
||||
const char* env_enable = getenv("HAKMEM_SFC_ENABLE");
|
||||
if (env_enable && *env_enable && *env_enable != '0') {
|
||||
g_sfc_enabled = 1;
|
||||
}
|
||||
// Priority-2: Use cached ENV (eliminate init syscall overhead)
|
||||
g_sfc_debug = HAK_ENV_SFC_DEBUG();
|
||||
g_sfc_enabled = HAK_ENV_SFC_ENABLE();
|
||||
|
||||
if (!g_sfc_enabled) {
|
||||
// SFC disabled, skip initialization
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse ENV: HAKMEM_SFC_CAPACITY (default capacity for all classes)
|
||||
const char* env_cap = getenv("HAKMEM_SFC_CAPACITY");
|
||||
if (env_cap && *env_cap) {
|
||||
int cap = atoi(env_cap);
|
||||
if (cap >= SFC_MIN_CAPACITY && cap <= SFC_MAX_CAPACITY) {
|
||||
g_sfc_default_capacity = cap;
|
||||
}
|
||||
// Priority-2: Use cached ENV (eliminate config syscall overhead)
|
||||
int cap = HAK_ENV_SFC_CAPACITY();
|
||||
if (cap >= SFC_MIN_CAPACITY && cap <= SFC_MAX_CAPACITY) {
|
||||
g_sfc_default_capacity = cap;
|
||||
}
|
||||
|
||||
// Parse ENV: HAKMEM_SFC_REFILL_COUNT (default refill for all classes)
|
||||
const char* env_refill = getenv("HAKMEM_SFC_REFILL_COUNT");
|
||||
if (env_refill && *env_refill) {
|
||||
int refill = atoi(env_refill);
|
||||
if (refill >= 8 && refill <= 256) {
|
||||
g_sfc_default_refill = refill;
|
||||
}
|
||||
int refill = HAK_ENV_SFC_REFILL_COUNT();
|
||||
if (refill >= 8 && refill <= 256) {
|
||||
g_sfc_default_refill = refill;
|
||||
}
|
||||
|
||||
// Parse ENV: HAKMEM_SFC_CAPACITY_CLASS{0..7} (per-class capacity override)
|
||||
|
||||
Reference in New Issue
Block a user