From 60b02adf54a0545721a53cb5195f88107b2c230b Mon Sep 17 00:00:00 2001 From: "Moe Charm (CI)" Date: Tue, 2 Dec 2025 23:29:07 +0900 Subject: [PATCH] =?UTF-8?q?hak=5Finit=5Fwait=5Ffor=5Fready:=20=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E3=83=A0=E3=82=A2=E3=82=A6=E3=83=88=E5=89=8A=E9=99=A4?= =?UTF-8?q?=20+=20=E3=83=87=E3=83=90=E3=83=83=E3=82=B0=E5=87=BA=E5=8A=9B?= =?UTF-8?q?=E6=8A=91=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- core/box/tls_sll_drain_box.h | 10 ++++++++++ core/hakmem.c | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/box/tls_sll_drain_box.h b/core/box/tls_sll_drain_box.h index 86517589..13bc1a6e 100644 --- a/core/box/tls_sll_drain_box.h +++ b/core/box/tls_sll_drain_box.h @@ -43,10 +43,14 @@ static inline int tls_sll_drain_is_enabled(void) { const char* env = getenv("HAKMEM_TINY_SLL_DRAIN_ENABLE"); if (env && *env == '0') { g_drain_enable = 0; +#ifndef NDEBUG fprintf(stderr, "[TLS_SLL_DRAIN] Drain DISABLED via ENV\n"); +#endif } else { g_drain_enable = 1; +#ifndef NDEBUG fprintf(stderr, "[TLS_SLL_DRAIN] Drain ENABLED (default)\n"); +#endif } } return g_drain_enable; @@ -62,14 +66,20 @@ static inline uint32_t tls_sll_drain_get_interval(void) { int val = atoi(env); if (val > 0 && val <= 65536) { g_drain_interval = (uint32_t)val; +#ifndef NDEBUG fprintf(stderr, "[TLS_SLL_DRAIN] Interval=%u (from ENV)\n", g_drain_interval); +#endif } else { g_drain_interval = 2048; +#ifndef NDEBUG fprintf(stderr, "[TLS_SLL_DRAIN] Invalid ENV value, using default=2048\n"); +#endif } } else { g_drain_interval = 2048; +#ifndef NDEBUG fprintf(stderr, "[TLS_SLL_DRAIN] Interval=%u (default)\n", g_drain_interval); +#endif } } return g_drain_interval; diff --git a/core/hakmem.c b/core/hakmem.c index 43deb6e3..29f1a843 100644 --- a/core/hakmem.c +++ b/core/hakmem.c @@ -268,6 +268,7 @@ static inline int hak_init_wait_for_ready(void) { if (pthread_equal(self, g_init_thread)) { 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) { #if defined(__x86_64__) || defined(__i386__) if (i < 1024) { @@ -277,9 +278,6 @@ static inline int hak_init_wait_for_ready(void) { { sched_yield(); } - if (i > 1000000) { - return -1; // Timed out waiting for init; allow libc fallback - } } return 1; // Init completed }