Phase v6-6: Inline hot path optimization for SmallObject Core v6
Optimize v6 alloc/free by eliminating redundant route checks and adding inline hot path functions: - smallobject_core_v6_box.h: Add inline hot path functions: - small_alloc_c6_hot_v6() / small_alloc_c5_hot_v6(): Direct TLS pop - small_free_c6_hot_v6() / small_free_c5_hot_v6(): Direct TLS push - No route check needed (caller already validated via switch case) - smallobject_core_v6.c: Add cold path functions: - small_alloc_cold_v6(): Handle TLS refill from page - small_free_cold_v6(): Handle page freelist push (TLS full/cross-thread) - malloc_tiny_fast.h: Update front gate to use inline hot path: - Alloc: hot path first, cold path fallback on TLS miss - Free: hot path first, cold path fallback on TLS full Performance results: - C5-heavy: v6 ON 42.2M ≈ baseline (parity restored) - C6-heavy: v6 ON 34.5M ≈ baseline (parity restored) - Mixed 16-1024B: ~26.5M (v3-only: ~28.1M, gap is routing overhead) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -158,10 +158,20 @@ static inline void* malloc_tiny_fast(size_t size) {
|
||||
|
||||
switch (route) {
|
||||
case TINY_ROUTE_SMALL_HEAP_V6: {
|
||||
// Phase v6-1: C6-only Core v6 route stub (pool v1 fallback)
|
||||
// Phase v6-6: Inline hot path (no route check, direct TLS pop)
|
||||
SmallHeapCtxV6* ctx_v6 = small_heap_ctx_v6();
|
||||
const SmallPolicySnapshotV6* snap_v6 = tiny_policy_snapshot_v6();
|
||||
void* v6p = small_alloc_fast_v6(size, (uint32_t)class_idx, ctx_v6, snap_v6);
|
||||
void* v6p = NULL;
|
||||
if (class_idx == 6) {
|
||||
v6p = small_alloc_c6_hot_v6(ctx_v6);
|
||||
if (TINY_HOT_UNLIKELY(!v6p)) {
|
||||
v6p = small_alloc_cold_v6(6, ctx_v6);
|
||||
}
|
||||
} else if (class_idx == 5) {
|
||||
v6p = small_alloc_c5_hot_v6(ctx_v6);
|
||||
if (TINY_HOT_UNLIKELY(!v6p)) {
|
||||
v6p = small_alloc_cold_v6(5, ctx_v6);
|
||||
}
|
||||
}
|
||||
if (TINY_HOT_LIKELY(v6p != NULL)) {
|
||||
return v6p;
|
||||
}
|
||||
@ -374,10 +384,17 @@ static inline int free_tiny_fast(void* ptr) {
|
||||
if (__builtin_expect(use_tiny_heap, 0)) {
|
||||
switch (route) {
|
||||
case TINY_ROUTE_SMALL_HEAP_V6: {
|
||||
// Phase v6-1: C6-only Core v6 route stub
|
||||
// Phase v6-6: Inline hot path (no route check, direct TLS push)
|
||||
SmallHeapCtxV6* ctx_v6 = small_heap_ctx_v6();
|
||||
const SmallPolicySnapshotV6* snap_v6 = tiny_policy_snapshot_v6();
|
||||
small_free_fast_v6(base, (uint32_t)class_idx, ctx_v6, snap_v6);
|
||||
int handled = 0;
|
||||
if (class_idx == 6) {
|
||||
handled = small_free_c6_hot_v6(ctx_v6, base);
|
||||
} else if (class_idx == 5) {
|
||||
handled = small_free_c5_hot_v6(ctx_v6, base);
|
||||
}
|
||||
if (!handled) {
|
||||
small_free_cold_v6(base, (uint32_t)class_idx);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
case TINY_ROUTE_SMALL_HEAP_V5: {
|
||||
|
||||
Reference in New Issue
Block a user