Add empty slab detection to drain: call shared_pool_release_slab

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 <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-11-14 07:13:00 +09:00
parent 2ef28ee5ab
commit 4ffdaae2fc

View File

@ -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);
}
}