Objective: Clean up warm pool implementation by extracting inline boxes for statistics, carving, and prefill logic. Achieved full modularity with zero performance regression using aggressive inline optimization. Changes: 1. **Legacy Code Removal** (Phase 0) - Removed unused static __thread prefill_attempt_count variable - Cleaned up duplicate comments - Simplified carve failure handling 2. **Warm Pool Statistics Box** (Phase 1) - New file: core/box/warm_pool_stats_box.h - Inline APIs: warm_pool_record_hit/miss/prefilled() - All statistics recording externalized - Integrated into unified_cache.c - Performance: 0 cost (inlined to direct memory write) 3. **Slab Carving Box** (Phase 2) - New file: core/box/slab_carve_box.h - Inline API: slab_carve_from_ss() - Extracted unified_cache_carve_from_ss() function - Now reusable by other refill paths (P0, etc.) - Performance: 100% inlined, O(slabs) scan unchanged 4. **Warm Pool Prefill Box** (Phase 3) - New file: core/box/warm_pool_prefill_box.h - Inline API: warm_pool_do_prefill() - Extracted prefill loop with configurable budget - WARM_POOL_PREFILL_BUDGET = 3 (tunable) - Cold path optimization (only on empty pool) - Performance: Cold path cost (non-critical) Architecture: - core/front/tiny_unified_cache.c now 40+ lines shorter - Logic distributed to 3 well-defined boxes - Each box has single responsibility (SRP) - Inline compilation preserves hot path performance - LTO (-flto) enables cross-file inlining Performance Results: - 1M allocations: 4.099M ops/s (maintained) - 5M allocations: 4.046M ops/s (maintained) - 55.6% warm pool hit rate (unchanged) - Zero regression on throughput - All three boxes fully inlined by compiler Code Quality Improvements: ✅ Removed legacy unused variables ✅ Separated concerns into specialized boxes ✅ Improved readability and maintainability ✅ Preserved performance via aggressive inline ✅ Enabled future reuse (carve box for P0) Testing: ✅ Compilation: No errors ✅ Functionality: 1M and 5M allocation tests pass ✅ Performance: Baseline maintained ✅ Statistics: Output identical to pre-refactor Next Phase: Consider similar modularization for: - Registry scanning (registry_scan_box.h) - TLS management (tls_management_box.h) - Cache operations (unified_cache_policy_box.h) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
111 lines
4.7 KiB
Makefile
111 lines
4.7 KiB
Makefile
core/front/tiny_unified_cache.o: core/front/tiny_unified_cache.c \
|
|
core/front/tiny_unified_cache.h core/front/../hakmem_build_flags.h \
|
|
core/front/../hakmem_tiny_config.h core/front/../box/ptr_type_box.h \
|
|
core/front/../box/tiny_front_config_box.h \
|
|
core/front/../box/../hakmem_build_flags.h core/front/tiny_warm_pool.h \
|
|
core/front/../superslab/superslab_types.h \
|
|
core/hakmem_tiny_superslab_constants.h core/front/../tiny_tls.h \
|
|
core/front/../hakmem_tiny_superslab.h \
|
|
core/front/../superslab/superslab_types.h \
|
|
core/front/../superslab/superslab_inline.h \
|
|
core/front/../superslab/superslab_types.h \
|
|
core/front/../superslab/../tiny_box_geometry.h \
|
|
core/front/../superslab/../hakmem_tiny_superslab_constants.h \
|
|
core/front/../superslab/../hakmem_tiny_config.h \
|
|
core/front/../tiny_debug_ring.h core/front/../hakmem_build_flags.h \
|
|
core/front/../tiny_remote.h \
|
|
core/front/../hakmem_tiny_superslab_constants.h \
|
|
core/front/../tiny_box_geometry.h core/front/../box/tiny_next_ptr_box.h \
|
|
core/hakmem_tiny_config.h core/tiny_nextptr.h core/hakmem_build_flags.h \
|
|
core/tiny_region_id.h core/tiny_box_geometry.h core/ptr_track.h \
|
|
core/hakmem_super_registry.h core/hakmem_tiny_superslab.h \
|
|
core/box/ss_addr_map_box.h core/box/../hakmem_build_flags.h \
|
|
core/superslab/superslab_inline.h core/hakmem_tiny.h core/hakmem_trace.h \
|
|
core/hakmem_tiny_mini_mag.h core/box/hak_lane_classify.inc.h \
|
|
core/box/ptr_type_box.h core/tiny_debug_api.h core/box/tiny_layout_box.h \
|
|
core/box/../hakmem_tiny_config.h core/box/tiny_header_box.h \
|
|
core/box/tiny_layout_box.h core/box/../tiny_region_id.h \
|
|
core/front/../hakmem_tiny_superslab.h \
|
|
core/front/../superslab/superslab_inline.h \
|
|
core/front/../box/pagefault_telemetry_box.h \
|
|
core/front/../box/ss_tier_box.h \
|
|
core/front/../box/../superslab/superslab_types.h \
|
|
core/front/../box/ss_slab_meta_box.h \
|
|
core/front/../box/slab_freelist_atomic.h \
|
|
core/front/../box/warm_pool_stats_box.h \
|
|
core/front/../box/../hakmem_tiny_config.h \
|
|
core/front/../box/../front/tiny_warm_pool.h \
|
|
core/front/../box/slab_carve_box.h \
|
|
core/front/../box/../hakmem_tiny_superslab.h \
|
|
core/front/../box/../superslab/superslab_inline.h \
|
|
core/front/../box/../tiny_box_geometry.h \
|
|
core/front/../box/../box/pagefault_telemetry_box.h \
|
|
core/front/../box/warm_pool_prefill_box.h \
|
|
core/front/../box/../tiny_tls.h \
|
|
core/front/../box/../box/warm_pool_stats_box.h \
|
|
core/front/../hakmem_env_cache.h
|
|
core/front/tiny_unified_cache.h:
|
|
core/front/../hakmem_build_flags.h:
|
|
core/front/../hakmem_tiny_config.h:
|
|
core/front/../box/ptr_type_box.h:
|
|
core/front/../box/tiny_front_config_box.h:
|
|
core/front/../box/../hakmem_build_flags.h:
|
|
core/front/tiny_warm_pool.h:
|
|
core/front/../superslab/superslab_types.h:
|
|
core/hakmem_tiny_superslab_constants.h:
|
|
core/front/../tiny_tls.h:
|
|
core/front/../hakmem_tiny_superslab.h:
|
|
core/front/../superslab/superslab_types.h:
|
|
core/front/../superslab/superslab_inline.h:
|
|
core/front/../superslab/superslab_types.h:
|
|
core/front/../superslab/../tiny_box_geometry.h:
|
|
core/front/../superslab/../hakmem_tiny_superslab_constants.h:
|
|
core/front/../superslab/../hakmem_tiny_config.h:
|
|
core/front/../tiny_debug_ring.h:
|
|
core/front/../hakmem_build_flags.h:
|
|
core/front/../tiny_remote.h:
|
|
core/front/../hakmem_tiny_superslab_constants.h:
|
|
core/front/../tiny_box_geometry.h:
|
|
core/front/../box/tiny_next_ptr_box.h:
|
|
core/hakmem_tiny_config.h:
|
|
core/tiny_nextptr.h:
|
|
core/hakmem_build_flags.h:
|
|
core/tiny_region_id.h:
|
|
core/tiny_box_geometry.h:
|
|
core/ptr_track.h:
|
|
core/hakmem_super_registry.h:
|
|
core/hakmem_tiny_superslab.h:
|
|
core/box/ss_addr_map_box.h:
|
|
core/box/../hakmem_build_flags.h:
|
|
core/superslab/superslab_inline.h:
|
|
core/hakmem_tiny.h:
|
|
core/hakmem_trace.h:
|
|
core/hakmem_tiny_mini_mag.h:
|
|
core/box/hak_lane_classify.inc.h:
|
|
core/box/ptr_type_box.h:
|
|
core/tiny_debug_api.h:
|
|
core/box/tiny_layout_box.h:
|
|
core/box/../hakmem_tiny_config.h:
|
|
core/box/tiny_header_box.h:
|
|
core/box/tiny_layout_box.h:
|
|
core/box/../tiny_region_id.h:
|
|
core/front/../hakmem_tiny_superslab.h:
|
|
core/front/../superslab/superslab_inline.h:
|
|
core/front/../box/pagefault_telemetry_box.h:
|
|
core/front/../box/ss_tier_box.h:
|
|
core/front/../box/../superslab/superslab_types.h:
|
|
core/front/../box/ss_slab_meta_box.h:
|
|
core/front/../box/slab_freelist_atomic.h:
|
|
core/front/../box/warm_pool_stats_box.h:
|
|
core/front/../box/../hakmem_tiny_config.h:
|
|
core/front/../box/../front/tiny_warm_pool.h:
|
|
core/front/../box/slab_carve_box.h:
|
|
core/front/../box/../hakmem_tiny_superslab.h:
|
|
core/front/../box/../superslab/superslab_inline.h:
|
|
core/front/../box/../tiny_box_geometry.h:
|
|
core/front/../box/../box/pagefault_telemetry_box.h:
|
|
core/front/../box/warm_pool_prefill_box.h:
|
|
core/front/../box/../tiny_tls.h:
|
|
core/front/../box/../box/warm_pool_stats_box.h:
|
|
core/front/../hakmem_env_cache.h:
|