Phase 12 SP-SLOT + Mid-Large P0 fix: Pool TLS debug logging & analysis

Phase 12 SP-SLOT Box (Complete):
- Per-slot state tracking (UNUSED/ACTIVE/EMPTY) for shared SuperSlabs
- 3-stage allocation: EMPTY reuse → UNUSED reuse → New SS
- Results: 877 → 72 SuperSlabs (-92%), 563K → 1.30M ops/s (+131%)
- Reports: PHASE12_SP_SLOT_BOX_IMPLEMENTATION_REPORT.md, CURRENT_TASK.md

Mid-Large P0 Analysis (2025-11-14):
- Root cause: Pool TLS disabled by default (build.sh:106 → POOL_TLS_PHASE1=0)
- Fix: POOL_TLS_PHASE1=1 build flag → 0.24M → 0.97M ops/s (+304%)
- Identified P0-2: futex bottleneck (67% syscall time) in pool_remote_push mutex
- Added debug logging: pool_tls.c (refill failures), pool_tls_arena.c (mmap/chunk failures)
- Reports: MID_LARGE_P0_FIX_REPORT_20251114.md, BOTTLENECK_ANALYSIS_REPORT_20251114.md

Next: Lock-free remote queue to reduce futex from 67% → <10%

Files modified:
- core/hakmem_shared_pool.c (SP-SLOT implementation)
- core/pool_tls.c (debug logging + stdatomic.h)
- core/pool_tls_arena.c (debug logging + stdio.h/errno.h/stdatomic.h)
- CURRENT_TASK.md (Phase 12 completion status)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-11-14 14:18:56 +09:00
parent 9830237d56
commit 40be86425b
7 changed files with 2107 additions and 407 deletions

View File

@ -4,6 +4,7 @@
#include <stdbool.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <stdatomic.h>
#include "pool_tls_registry.h"
static inline pid_t gettid_cached(void){
@ -115,7 +116,17 @@ void* pool_alloc(size_t size) {
}
// Cold path: refill
return pool_refill_and_alloc(class_idx);
void* refill_ret = pool_refill_and_alloc(class_idx);
if (!refill_ret) {
// DEBUG: Log refill failure
static _Atomic int refill_fail_count = 0;
int fail_num = atomic_fetch_add(&refill_fail_count, 1);
if (fail_num < 10) {
fprintf(stderr, "[POOL_TLS] pool_refill_and_alloc FAILED: class=%d, size=%zu\n",
class_idx, POOL_CLASS_SIZES[class_idx]);
}
}
return refill_ret;
}
// Ultra-fast free (5-6 cycles)