Phase 35-39: FAST build optimization complete (+7.13% cumulative)

Phase 35-A: BENCH_MINIMAL gate function elimination (GO +4.39%)
- tiny_front_v3_enabled() → constant true
- tiny_metadata_cache_enabled() → constant 0
- learner_v7_enabled() → constant false
- small_learner_v2_enabled() → constant false

Phase 36: Policy snapshot init-once (GO +0.71%)
- small_policy_v7_snapshot() version check skip in BENCH_MINIMAL
- TLS cache for policy snapshot

Phase 37: Standard TLS cache (NO-GO -0.07%)
- TLS cache for Standard build attempted
- Runtime gate overhead negates benefit

Phase 38: FAST/OBSERVE/Standard workflow established
- make perf_fast, make perf_observe targets
- Scorecard and documentation updates

Phase 39: Hot path gate constantization (GO +1.98%)
- front_gate_unified_enabled() → constant 1
- alloc_dualhot_enabled() → constant 0
- g_bench_fast_front, g_v3_enabled blocks → compile-out
- free_dispatch_stats_enabled() → constant false

Results:
- FAST v3: 56.04M ops/s (47.4% of mimalloc)
- Standard: 53.50M ops/s (45.3% of mimalloc)
- M1 target (50%): 5.5% remaining

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-12-16 15:01:56 +09:00
parent 506e724c3b
commit b7085c47e1
22 changed files with 1550 additions and 397 deletions

View File

@ -26,6 +26,17 @@
# endif
#endif
// ------------------------------------------------------------
// Phase 35-A: Benchmark Minimal Mode
// ------------------------------------------------------------
// HAKMEM_BENCH_MINIMAL: Eliminate gate function overhead for benchmarks
// When =1: Gate functions return compile-time constants (no lazy init check)
// When =0: Normal runtime gate behavior (default)
// Usage: Build with -DHAKMEM_BENCH_MINIMAL=1 for benchmark-only binaries
#ifndef HAKMEM_BENCH_MINIMAL
# define HAKMEM_BENCH_MINIMAL 0
#endif
// ------------------------------------------------------------
// Instrumentation & counters (compile-time)
// ------------------------------------------------------------
@ -372,6 +383,35 @@
# define HAKMEM_TINY_FREE_TRACE_COMPILED 0
#endif
// ------------------------------------------------------------
// Phase 32: Tiny Free Calls Atomic Prune (Compile-out diagnostic counter)
// ------------------------------------------------------------
// Tiny Free Calls: Compile gate (default OFF = compile-out)
// Set to 1 for research builds that need free path call counting
// Target: g_hak_tiny_free_calls atomic in core/hakmem_tiny_free.inc:335
// Impact: HOT path atomic (every free operation, unconditional)
// Expected improvement: +0.3% to +0.7% (diagnostic counter, less critical than Phase 25)
#ifndef HAKMEM_TINY_FREE_CALLS_COMPILED
# define HAKMEM_TINY_FREE_CALLS_COMPILED 0
#endif
// ------------------------------------------------------------
// Phase 34: Batch Atomic Prune (Compile-out remaining WARM path atomics)
// ------------------------------------------------------------
// Phase 34A: Splice Debug Counter (WARM path, refill)
// Target: g_splice_count in core/tiny_refill_opt.h:79
// Impact: WARM path atomic (every refill splice operation)
#ifndef HAKMEM_SPLICE_DEBUG_COMPILED
# define HAKMEM_SPLICE_DEBUG_COMPILED 0
#endif
// Phase 34B: Alloc Gate Class Mismatch (ERROR path, rare)
// Target: g_alloc_gate_cls_mis in core/box/tiny_alloc_gate_box.h:95
// Impact: ERROR path atomic (class mismatch detection, rare)
#ifndef HAKMEM_ALLOC_GATE_CLS_MIS_COMPILED
# define HAKMEM_ALLOC_GATE_CLS_MIS_COMPILED 0
#endif
// ------------------------------------------------------------
// Helper enum (for documentation / logging)
// ------------------------------------------------------------