refactor: Guard SuperSlab expansion debug logs + Update CURRENT_TASK
## Changes
### 1. Debug Log Cleanup (Release Build Optimization)
**Files Modified:**
- `core/tiny_superslab_alloc.inc.h:183-234`
- `core/hakmem_tiny_superslab.c:567-618`
**Problem:**
- SuperSlab expansion logs flooded output (268+ lines per benchmark run)
- Massive I/O overhead masked true performance in benchmarks
- Production builds should not spam stderr
**Solution:**
- Guard all expansion logs with `#if !defined(NDEBUG) || defined(HAKMEM_SUPERSLAB_VERBOSE)`
- Debug builds: Logs enabled by default
- Release builds: Logs disabled (clean output)
- Can re-enable with `-DHAKMEM_SUPERSLAB_VERBOSE` for debugging
**Guarded Messages:**
- "SuperSlab chunk exhausted for class X, expanding..."
- "Successfully expanded SuperSlabHead for class X"
- "CRITICAL: Failed to expand SuperSlabHead..." (OOM)
- "Expanded SuperSlabHead for class X: N chunks now"
**Impact:**
- Release builds: Clean benchmark output (no log spam)
- Debug builds: Full visibility into expansion behavior
- Performance: No I/O overhead in production benchmarks
### 2. CURRENT_TASK.md Update
**New Focus:** ACE Investigation for Mid-Large Performance Recovery
**Context:**
- ✅ 100% stability achieved (commit 616070cf7)
- ✅ Tiny Hot Path: **First time beating BOTH System and mimalloc** (+48.5% vs System)
- 🔴 Critical issue: Mid-Large MT collapsed (-88% vs System)
- Root cause: ACE disabled → all allocations go to mmap (slow)
**Next Task:**
Task Agent to investigate ACE mechanism (Ultrathink mode):
1. Why is ACE disabled?
2. How does ACE improve Mid-Large performance?
3. Can we re-enable ACE to recover +171% advantage?
4. Implementation plan and risk assessment
**Benchmark Results:**
Comprehensive results saved to: `benchmarks/results/comprehensive_20251108_214317/`
---
## Testing
Verified clean build output:
```bash
make clean && make HEADER_CLASSIDX=1 AGGRESSIVE_INLINE=1 PREWARM_TLS=1 larson_hakmem
./larson_hakmem 1 1 128 1024 1 12345 1
# No expansion log spam in release build
```
🎉 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -180,11 +180,13 @@ static SuperSlab* superslab_refill(int class_idx) {
|
||||
}
|
||||
} else {
|
||||
// Current chunk exhausted (all slabs occupied), try to expand
|
||||
#if !defined(NDEBUG) || defined(HAKMEM_SUPERSLAB_VERBOSE)
|
||||
extern __thread int g_hakmem_lock_depth;
|
||||
g_hakmem_lock_depth++;
|
||||
fprintf(stderr, "[HAKMEM] SuperSlab chunk exhausted for class %d (bitmap=0x%08x), expanding...\n",
|
||||
class_idx, current_chunk->slab_bitmap);
|
||||
g_hakmem_lock_depth--;
|
||||
#endif
|
||||
|
||||
// Protect expansion with global lock (race condition fix)
|
||||
static pthread_mutex_t expand_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -199,15 +201,19 @@ static SuperSlab* superslab_refill(int class_idx) {
|
||||
// Still exhausted, expand now
|
||||
if (expand_superslab_head(head) < 0) {
|
||||
pthread_mutex_unlock(&expand_lock);
|
||||
#if !defined(NDEBUG) || defined(HAKMEM_SUPERSLAB_VERBOSE)
|
||||
g_hakmem_lock_depth++;
|
||||
fprintf(stderr, "[HAKMEM] CRITICAL: Failed to expand SuperSlabHead for class %d (system OOM)\n", class_idx);
|
||||
g_hakmem_lock_depth--;
|
||||
#endif
|
||||
return NULL; // True system OOM
|
||||
}
|
||||
|
||||
#if !defined(NDEBUG) || defined(HAKMEM_SUPERSLAB_VERBOSE)
|
||||
g_hakmem_lock_depth++;
|
||||
fprintf(stderr, "[HAKMEM] Successfully expanded SuperSlabHead for class %d\n", class_idx);
|
||||
g_hakmem_lock_depth--;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Update current_chunk and tls->ss to point to (potentially new) chunk
|
||||
@ -219,9 +225,11 @@ static SuperSlab* superslab_refill(int class_idx) {
|
||||
full_mask = (ss_slabs_capacity(current_chunk) >= 32) ? 0xFFFFFFFF :
|
||||
((1U << ss_slabs_capacity(current_chunk)) - 1);
|
||||
if (!current_chunk || current_chunk->slab_bitmap == full_mask) {
|
||||
#if !defined(NDEBUG) || defined(HAKMEM_SUPERSLAB_VERBOSE)
|
||||
g_hakmem_lock_depth++;
|
||||
fprintf(stderr, "[HAKMEM] CRITICAL: Chunk still has no free slabs for class %d after expansion\n", class_idx);
|
||||
g_hakmem_lock_depth--;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user