|
|
5c9fe34b40
|
Enable performance optimizations by default (+557% improvement)
## Performance Impact
**Before** (optimizations OFF):
- Random Mixed 256B: 9.4M ops/s
- System malloc ratio: 10.6% (9.5x slower)
**After** (optimizations ON):
- Random Mixed 256B: 61.8M ops/s (+557%)
- System malloc ratio: 70.0% (1.43x slower) ✅
- 3-run average: 60.1M - 62.8M ops/s (±2.2% variance)
## Changes
Enabled 3 critical optimizations by default:
### 1. HAKMEM_SS_EMPTY_REUSE (hakmem_shared_pool.c:810)
```c
// BEFORE: default OFF
empty_reuse_enabled = (e && *e && *e != '0') ? 1 : 0;
// AFTER: default ON
empty_reuse_enabled = (e && *e && *e == '0') ? 0 : 1;
```
**Impact**: Reuse empty slabs before mmap, reduces syscall overhead
### 2. HAKMEM_TINY_UNIFIED_CACHE (tiny_unified_cache.h:69)
```c
// BEFORE: default OFF
g_enable = (e && *e && *e != '0') ? 1 : 0;
// AFTER: default ON
g_enable = (e && *e && *e == '0') ? 0 : 1;
```
**Impact**: Unified TLS cache improves hit rate
### 3. HAKMEM_FRONT_GATE_UNIFIED (malloc_tiny_fast.h:42)
```c
// BEFORE: default OFF
g_enable = (e && *e && *e != '0') ? 1 : 0;
// AFTER: default ON
g_enable = (e && *e && *e == '0') ? 0 : 1;
```
**Impact**: Unified front gate reduces dispatch overhead
## ENV Override
Users can still disable optimizations if needed:
```bash
export HAKMEM_SS_EMPTY_REUSE=0 # Disable empty slab reuse
export HAKMEM_TINY_UNIFIED_CACHE=0 # Disable unified cache
export HAKMEM_FRONT_GATE_UNIFIED=0 # Disable unified front gate
```
## Comparison to Competitors
```
mimalloc: 113.34M ops/s (1.83x faster than HAKMEM)
System malloc: 88.20M ops/s (1.43x faster than HAKMEM)
HAKMEM: 61.80M ops/s ✅ Competitive performance
```
## Files Modified
- core/hakmem_shared_pool.c - EMPTY_REUSE default ON
- core/front/tiny_unified_cache.h - UNIFIED_CACHE default ON
- core/front/malloc_tiny_fast.h - FRONT_GATE_UNIFIED default ON
🚀 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-22 01:29:05 +09:00 |
|
|
|
5b36c1c908
|
Phase 26: Front Gate Unification - Tiny allocator fast path (+12.9%)
Implementation:
- New single-layer malloc/free path for Tiny (≤1024B) allocations
- Bypasses 3-layer overhead: malloc → hak_alloc_at (236 lines) → wrapper → tiny_alloc_fast
- Leverages Phase 23 Unified Cache (tcache-style, 2-3 cache misses)
- Safe fallback to normal path on Unified Cache miss
Performance (Random Mixed 256B, 100K iterations):
- Baseline (Phase 26 OFF): 11.33M ops/s
- Phase 26 ON: 12.79M ops/s (+12.9%)
- Prediction (ChatGPT): +10-15% → Actual: +12.9% (perfect match!)
Bug fixes:
- Initialization bug: Added hak_init() call before fast path
- Page boundary SEGV: Added guard for offset_in_page == 0
Also includes Phase 23 debug log fixes:
- Guard C2_CARVE logs with #if !HAKMEM_BUILD_RELEASE
- Guard prewarm logs with #if !HAKMEM_BUILD_RELEASE
- Set Hot_2048 as default capacity (C2/C3=2048, others=64)
Files:
- core/front/malloc_tiny_fast.h: Phase 26 implementation (145 lines)
- core/box/hak_wrappers.inc.h: Fast path integration (+28 lines)
- core/front/tiny_unified_cache.h: Hot_2048 default
- core/tiny_refill_opt.h: C2_CARVE log guard
- core/box/ss_hot_prewarm_box.c: Prewarm log guard
- CURRENT_TASK.md: Phase 26 completion documentation
ENV variables:
- HAKMEM_FRONT_GATE_UNIFIED=1 (enable Phase 26, default: OFF)
- HAKMEM_TINY_UNIFIED_CACHE=1 (Phase 23, required)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-17 05:29:08 +09:00 |
|