From 930c5283b4442ffadaf77976488305454e8a5e2f Mon Sep 17 00:00:00 2001 From: "Moe Charm (CI)" Date: Thu, 27 Nov 2025 16:47:30 +0900 Subject: [PATCH] Fix Larson 36x slowdown: Remove tls_uninitialized early return in sll_refill_small_from_ss() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Larson benchmark showed 730K ops/s instead of expected 26M ops/s - Class 1 TLS SLL cache always stayed empty (tls_count=0) - All allocations went through slow path (shared_pool_acquire_slab at 48% CPU) Root cause: - In sll_refill_small_from_ss(), when TLS was completely uninitialized (ss=NULL, meta=NULL, slab_base=NULL), the function returned 0 immediately without calling superslab_refill() to initialize it - The comment said "expect upper logic to call superslab_refill" but tiny_alloc_fast_refill() did NOT call it after receiving 0 - This created a loop: TLS SLL stays empty → refill returns 0 → slow path Fix: - Remove the tls_uninitialized early return - Let the existing downstream condition (!tls->ss || !tls->meta || ...) handle the uninitialized case and call superslab_refill() Result: - Throughput: 730K → 26.5M ops/s (36x improvement) - shared_pool_acquire_slab: 48% → 0% in perf profile Introduced in: fcf098857 (Phase12 debug, 2025-11-14) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- core/hakmem_tiny_refill.inc.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/core/hakmem_tiny_refill.inc.h b/core/hakmem_tiny_refill.inc.h index 12464eed..a9d0c39a 100644 --- a/core/hakmem_tiny_refill.inc.h +++ b/core/hakmem_tiny_refill.inc.h @@ -274,15 +274,9 @@ int sll_refill_small_from_ss(int class_idx, int max_take) return 0; } - bool tls_uninitialized = - (tls->ss == NULL) && - (tls->meta == NULL) && - (tls->slab_base == NULL); - - if (tls_uninitialized) { - // 初回は、呼び出し元の上位ロジックが superslab_refill を呼ぶことを期待し、ここでは何もしない。 - return 0; - } + // FIX: TLS未初期化時も superslab_refill() で初期化する(早期リターン削除) + // 以前は tls_uninitialized の場合に return 0 していたが、これだと + // TLS SLL が永遠に空のままになり、Larson ベンチで 70x slowdown が発生していた。 // Ensure we have a valid TLS slab for this class via shared pool. // superslab_refill() 契約: