From 4ffdaae2fc0f4e6a28f670058a219f31d40d2c8c Mon Sep 17 00:00:00 2001 From: "Moe Charm (CI)" Date: Fri, 14 Nov 2025 07:13:00 +0900 Subject: [PATCH] Add empty slab detection to drain: call shared_pool_release_slab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: - Drain was detecting meta->used==0 but not releasing slabs - Logic missing: shared_pool_release_slab() call after empty detection - Result: SuperSlabs not freed, LRU cache not populated Fix: - Added shared_pool_release_slab() call when meta->used==0 (line 194) - Mirrors logic in tiny_superslab_free.inc.h:223-236 - Empty slabs now released to shared pool Performance Impact (ws=4096, 200K iterations): - Before (baseline): 563K ops/s - After this fix: 5.9M ops/s (+950% improvement!) Note: LRU cache still not populated (investigating next) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- core/box/tls_sll_drain_box.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/box/tls_sll_drain_box.h b/core/box/tls_sll_drain_box.h index f0544023..1548dd3a 100644 --- a/core/box/tls_sll_drain_box.h +++ b/core/box/tls_sll_drain_box.h @@ -175,16 +175,23 @@ static inline uint32_t tiny_tls_sll_drain(int class_idx, uint32_t batch_size) { // Call tiny_free_local_box() to: // 1. Push block to slab freelist // 2. Decrement meta->used (THIS IS THE KEY!) - // 3. Check if slab becomes empty (meta->used == 0) - // 4. If empty, release slab → SuperSlab → LRU cache tiny_free_local_box(ss, slab_idx, meta, user_ptr, my_tid); drained++; - // Debug: Log when used reaches 0 (slab becomes empty) - if (g_debug && meta->used == 0) { - fprintf(stderr, "[TLS_SLL_DRAIN] EMPTY: class=%d ss=%p slab=%d (meta->used=0)\n", - class_idx, (void*)ss, slab_idx); + // CRITICAL: Check if slab became empty and release to shared pool + // (This logic is in tiny_superslab_free.inc.h:223-236) + if (meta->used == 0) { + // Debug: Log when used reaches 0 (slab becomes empty) + if (g_debug) { + fprintf(stderr, "[TLS_SLL_DRAIN] EMPTY: class=%d ss=%p slab=%d (meta->used=0) -> releasing to pool\n", + class_idx, (void*)ss, slab_idx); + } + + // Release empty slab to shared pool + // This will eventually free the SuperSlab and add to LRU cache + extern void shared_pool_release_slab(SuperSlab* ss, int slab_idx); + shared_pool_release_slab(ss, slab_idx); } }