hak_init_wait_for_ready: タイムアウト削除 + デバッグ出力抑制
- hak_init_wait_for_ready(): タイムアウト(i > 1000000)を削除 - 他スレッドは初期化完了まで確実に待機するように変更 - init_waitによるlibcフォールバックを防止 - tls_sll_drain_box.h: デバッグ出力を#ifndef NDEBUGで囲む - releaseビルドでの不要なfprintf出力を抑制 - [TLS_SLL_DRAIN] メッセージがベンチマーク時に出なくなった 性能への影響: - sh8bench 8スレッド: 17秒(変更なし) - フォールバック: 8回(初期化時のみ、正常動作) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -43,10 +43,14 @@ static inline int tls_sll_drain_is_enabled(void) {
|
|||||||
const char* env = getenv("HAKMEM_TINY_SLL_DRAIN_ENABLE");
|
const char* env = getenv("HAKMEM_TINY_SLL_DRAIN_ENABLE");
|
||||||
if (env && *env == '0') {
|
if (env && *env == '0') {
|
||||||
g_drain_enable = 0;
|
g_drain_enable = 0;
|
||||||
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "[TLS_SLL_DRAIN] Drain DISABLED via ENV\n");
|
fprintf(stderr, "[TLS_SLL_DRAIN] Drain DISABLED via ENV\n");
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
g_drain_enable = 1;
|
g_drain_enable = 1;
|
||||||
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "[TLS_SLL_DRAIN] Drain ENABLED (default)\n");
|
fprintf(stderr, "[TLS_SLL_DRAIN] Drain ENABLED (default)\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return g_drain_enable;
|
return g_drain_enable;
|
||||||
@ -62,14 +66,20 @@ static inline uint32_t tls_sll_drain_get_interval(void) {
|
|||||||
int val = atoi(env);
|
int val = atoi(env);
|
||||||
if (val > 0 && val <= 65536) {
|
if (val > 0 && val <= 65536) {
|
||||||
g_drain_interval = (uint32_t)val;
|
g_drain_interval = (uint32_t)val;
|
||||||
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "[TLS_SLL_DRAIN] Interval=%u (from ENV)\n", g_drain_interval);
|
fprintf(stderr, "[TLS_SLL_DRAIN] Interval=%u (from ENV)\n", g_drain_interval);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
g_drain_interval = 2048;
|
g_drain_interval = 2048;
|
||||||
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "[TLS_SLL_DRAIN] Invalid ENV value, using default=2048\n");
|
fprintf(stderr, "[TLS_SLL_DRAIN] Invalid ENV value, using default=2048\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g_drain_interval = 2048;
|
g_drain_interval = 2048;
|
||||||
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "[TLS_SLL_DRAIN] Interval=%u (default)\n", g_drain_interval);
|
fprintf(stderr, "[TLS_SLL_DRAIN] Interval=%u (default)\n", g_drain_interval);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return g_drain_interval;
|
return g_drain_interval;
|
||||||
|
|||||||
@ -268,6 +268,7 @@ static inline int hak_init_wait_for_ready(void) {
|
|||||||
if (pthread_equal(self, g_init_thread)) {
|
if (pthread_equal(self, g_init_thread)) {
|
||||||
return 0; // We are the init thread; caller should take the existing fallback path
|
return 0; // We are the init thread; caller should take the existing fallback path
|
||||||
}
|
}
|
||||||
|
// No timeout: block until init completes to avoid libc fallback on other threads.
|
||||||
for (int i = 0; atomic_load_explicit(&g_initializing, memory_order_acquire); ++i) {
|
for (int i = 0; atomic_load_explicit(&g_initializing, memory_order_acquire); ++i) {
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
#if defined(__x86_64__) || defined(__i386__)
|
||||||
if (i < 1024) {
|
if (i < 1024) {
|
||||||
@ -277,9 +278,6 @@ static inline int hak_init_wait_for_ready(void) {
|
|||||||
{
|
{
|
||||||
sched_yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
if (i > 1000000) {
|
|
||||||
return -1; // Timed out waiting for init; allow libc fallback
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 1; // Init completed
|
return 1; // Init completed
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user