Phase 24-26: Hot path atomic telemetry prune (+2.00% cumulative)
Summary: - Phase 24 (alloc stats): +0.93% GO - Phase 25 (free stats): +1.07% GO - Phase 26 (diagnostics): -0.33% NEUTRAL (code cleanliness) - Total: 11 atomics compiled-out, +2.00% improvement Phase 24: OBSERVE tax prune (tiny_class_stats_box.h) - Added HAKMEM_TINY_CLASS_STATS_COMPILED (default: 0) - Wrapped 5 stats functions: uc_miss, warm_hit, shared_lock, tls_carve_* - Result: +0.93% (baseline 56.675M vs compiled-in 56.151M ops/s) Phase 25: Tiny free stats prune (tiny_superslab_free.inc.h) - Added HAKMEM_TINY_FREE_STATS_COMPILED (default: 0) - Wrapped g_free_ss_enter atomic in free hot path - Result: +1.07% (baseline 57.017M vs compiled-in 56.415M ops/s) Phase 26: Hot path diagnostic atomics prune - Added 5 compile gates for low-frequency error counters: - HAKMEM_TINY_C7_FREE_COUNT_COMPILED - HAKMEM_TINY_HDR_MISMATCH_LOG_COMPILED - HAKMEM_TINY_HDR_META_MISMATCH_COMPILED - HAKMEM_TINY_METRIC_BAD_CLASS_COMPILED - HAKMEM_TINY_HDR_META_FAST_COMPILED - Result: -0.33% NEUTRAL (within noise, kept for cleanliness) Alignment with mimalloc principles: - "No atomics on hot path" - telemetry moved to compile-time opt-in - Fixed per-op tax elimination - Production builds: maximum performance (atomics compiled-out) - Research builds: full diagnostics (COMPILED=1) Generated with Claude Code https://claude.com/claude-code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -212,13 +212,16 @@ void* tiny_region_id_write_header(void* base, int class_idx);
|
||||
|
||||
static inline void* tiny_header_finalize_alloc(void* base, int class_idx) {
|
||||
#if HAKMEM_TINY_HEADER_CLASSIDX
|
||||
// Write-once optimization: Skip header write for C1-C6 if already prefilled
|
||||
if (tiny_header_write_once_enabled() && tiny_class_preserves_header(class_idx)) {
|
||||
#if HAKMEM_TINY_HEADER_WRITE_ONCE_COMPILED
|
||||
// Phase 23: Write-once optimization (compile-out when disabled, default OFF)
|
||||
// Evaluate class check first (short-circuit), then ENV check
|
||||
if (tiny_class_preserves_header(class_idx) && tiny_header_write_once_enabled()) {
|
||||
// Header already written at refill boundary → skip write, return USER pointer
|
||||
return (void*)((uint8_t*)base + 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Traditional path: C0, C7, or WRITE_ONCE=0
|
||||
// Traditional path: C0, C7, or WRITE_ONCE compiled-out/disabled
|
||||
return tiny_region_id_write_header(base, class_idx);
|
||||
#else
|
||||
(void)class_idx;
|
||||
|
||||
Reference in New Issue
Block a user