Phase 6-2: Promote Front FastLane Free DeDup (default ON)

Results:
- A/B test: +5.18% on Mixed (10-run, clean env)
- Baseline: 46.68M ops/s
- Optimized: 49.10M ops/s
- Improvement: +2.42M ops/s (+5.18%)

Strategy:
- Eliminate duplicate header validation in front_fastlane_try_free()
- Direct call to free_tiny_fast() when dedup enabled
- Single validation path (no redundant checks)

Success factors:
1. Complete duplicate elimination (free path optimization)
2. Free path importance (50% of Mixed workload)
3. Improved execution stability (CV: 1.00% → 0.58%)

Phase 6 cumulative:
- Phase 6-1 FastLane: +11.13%
- Phase 6-2 Free DeDup: +5.18%
- Total: ~+16-17% from baseline (multiplicative effect)

Promotion:
- Default: HAKMEM_FRONT_FASTLANE_FREE_DEDUP=1 (opt-out)
- Added to MIXED_TINYV3_C7_SAFE preset
- Added to C6_HEAVY_LEGACY_POOLV1 preset
- Rollback: HAKMEM_FRONT_FASTLANE_FREE_DEDUP=0

Files modified:
- core/box/front_fastlane_env_box.h: default 0 → 1
- core/bench_profile.h: added to presets
- CURRENT_TASK.md: Phase 6-2 GO result

Health check: PASSED (all profiles)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-14 17:38:21 +09:00
parent c0d2f47f7d
commit dcc1d42e7f
5 changed files with 281 additions and 10 deletions

View File

@ -102,9 +102,10 @@ static inline void* front_fastlane_try_malloc(size_t size) {
// Hot Inline: try_free
// ============================================================================
// Patch 6: Actual Tiny direct path implementation
// Strategy: Header validation → direct Tiny free (same pattern as E5-1)
// Only handle cases where we have high confidence (Tiny header magic)
// Phase 6-2: Free DeDup optimization
// Strategy:
// - When dedup=1 and class_mask=0xFF: Direct call to free_tiny_fast() (no duplicate header check)
// - Otherwise: Existing header validation path (backward compatible)
static inline bool front_fastlane_try_free(void* ptr) {
FRONT_FASTLANE_STAT_INC(free_total);
@ -115,6 +116,24 @@ static inline bool front_fastlane_try_free(void* ptr) {
}
#if HAKMEM_TINY_HEADER_CLASSIDX
// Phase 6-2: DeDup path (eliminate duplicate header validation)
// Conditions:
// 1. Free DeDup enabled (ENV=1)
// 2. All classes enabled (mask=0xFF, no gradual rollout)
if (__builtin_expect(front_fastlane_free_dedup_enabled() && front_fastlane_class_mask() == 0xFF, 1)) {
// Direct call to free_tiny_fast() (handles all validation internally)
// free_tiny_fast() is static inline in malloc_tiny_fast.h, no extern needed
int result = free_tiny_fast(ptr);
if (__builtin_expect(result, 1)) {
FRONT_FASTLANE_STAT_INC(free_hit);
return true; // Handled
}
// Not handled → fallback
FRONT_FASTLANE_STAT_INC(free_fallback_failure);
return false;
}
// Traditional path (backward compatible, for class mask filtering or dedup=0)
// Page boundary guard: ptr must not be page-aligned
// (Accessing ptr-1 when ptr is page-aligned could segfault)
uintptr_t off = (uintptr_t)ptr & 0xFFFu;
@ -151,8 +170,7 @@ static inline bool front_fastlane_try_free(void* ptr) {
// Call existing hot handler (no duplication)
// This is the winning path from E5-1 (free_tiny_fast returns 1 on success)
// Forward declaration needed - free_tiny_fast is in malloc_tiny_fast.h
extern int free_tiny_fast(void* ptr);
// free_tiny_fast() is static inline in malloc_tiny_fast.h, no extern needed
if (__builtin_expect(free_tiny_fast(ptr), 1)) {
FRONT_FASTLANE_STAT_INC(free_hit);
return true; // Success