Files
hakmem/hakmem.d
Moe Charm (CI) ea6ed1a6e4 Phase FREE-LEGACY-OPT-5-1/5-2: C5 ULTRA free+alloc integration
Summary:
========
Implemented C5 ULTRA TLS cache pattern following the successful C6 ULTRA design:
- Phase 5-1: Free-side TLS cache + segment learning
- Phase 5-2: Alloc-side TLS pop for complete free+alloc cycle integration

Targets C5 class (129-256B) as next legacy reduction after C6 completion.

Key Changes:
============

1. NEW FILES:
   - core/box/tiny_c5_ultra_free_box.h: C5 ULTRA TLS cache structure
   - core/box/tiny_c5_ultra_free_box.c: C5 free path implementation (same pattern as C6)
   - core/box/tiny_c5_ultra_free_env_box.h: ENV gating (HAKMEM_TINY_C5_ULTRA_FREE_ENABLED)

2. MODIFIED FILES:
   - core/front/malloc_tiny_fast.h:
     * Added C5 ULTRA includes
     * Added C5 alloc-side TLS pop at lines 186-194 (integrated with C6)
     * Added C5 free path at lines 333-337 (integrated with C6)

   - core/box/tiny_ultra_classes_box.h:
     * Added TINY_CLASS_C5 constant
     * Added tiny_class_is_c5() macro
     * Extended tiny_class_is_ultra() to include C5

   - core/box/free_path_stats_box.h:
     * Added c5_ultra_free_fast counter
     * Added c5_ultra_alloc_hit counter

   - core/box/free_path_stats_box.c:
     * Updated stats dump to output C5 counters

   - Makefile:
     * Added core/box/tiny_c5_ultra_free_box.o to all object lists

3. Design Rationale:
   - Exact copy of C6 ULTRA pattern (proven effective)
   - TLS cache capacity: 128 blocks (same as C6 for consistency)
   - Segment learning on first C5 free via ss_fast_lookup()
   - Alloc-side pop integrated directly in malloc_tiny_fast.h hotpath
   - Legacy fallback unification via tiny_legacy_fallback_free_base()

4. Expected Impact:
   - C5 legacy calls: 68,871 → 0 (100% elimination)
   - Total legacy reduction: ~53% of remaining 129,623
   - Mixed workload: Minimal regression (C5 is smaller class, fewer allocations)

5. Stats Collection:
   Run with: HAKMEM_TINY_C5_ULTRA_FREE_ENABLED=1 HAKMEM_FREE_PATH_STATS=1 ./bench_allocators_hakmem

   Expected output:
   [FREE_PATH_STATS] ... c5_ultra_free=68871 c5_ultra_alloc=68871 ... legacy_fb=60752 ...
   [FREE_PATH_STATS_LEGACY_BY_CLASS] ... c5=0 ...

Status:
=======
- Code:  COMPLETE (3 new files + 5 modified files)
- Compilation:  Verified (no errors, only unused variable warnings unrelated to C5)
- Functionality: Ready to benchmark (ENV gating: default OFF, opt-in via ENV)

Phase Progression:
==================
 Phase 4-4: C6 ULTRA free+alloc (legacy C6: 137,319 → 0)
 Phase 5-1/5-2: C5 ULTRA free+alloc (legacy C5: 68,871 → 0 expected)
 Phase 4.5: C4 ULTRA (34,727 remaining)
📋 Future: C3/C2 ULTRA if beneficial

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-11 19:26:51 +09:00

329 lines
14 KiB
Makefile

hakmem.o: core/hakmem.c core/hakmem.h core/hakmem_build_flags.h \
core/hakmem_config.h core/hakmem_features.h core/hakmem_internal.h \
core/hakmem_sys.h core/hakmem_whale.h core/box/ptr_type_box.h \
core/hakmem_bigcache.h core/hakmem_pool.h \
core/box/hak_lane_classify.inc.h core/hakmem_l25_pool.h \
core/hakmem_policy.h core/hakmem_learner.h core/hakmem_size_hist.h \
core/hakmem_ace.h core/hakmem_site_rules.h core/hakmem_tiny.h \
core/hakmem_trace.h core/hakmem_tiny_mini_mag.h \
core/hakmem_tiny_superslab.h core/superslab/superslab_types.h \
core/hakmem_tiny_superslab_constants.h core/superslab/superslab_inline.h \
core/superslab/superslab_types.h core/superslab/../tiny_box_geometry.h \
core/superslab/../hakmem_tiny_superslab_constants.h \
core/superslab/../hakmem_tiny_config.h \
core/superslab/../hakmem_super_registry.h \
core/superslab/../hakmem_tiny_superslab.h \
core/superslab/../box/ss_addr_map_box.h \
core/superslab/../box/../hakmem_build_flags.h \
core/superslab/../box/super_reg_box.h core/tiny_debug_ring.h \
core/tiny_remote.h core/hakmem_tiny_superslab_constants.h \
core/tiny_fastcache.h core/hakmem_env_cache.h \
core/box/tiny_next_ptr_box.h core/hakmem_tiny_config.h \
core/tiny_nextptr.h core/tiny_region_id.h core/tiny_box_geometry.h \
core/ptr_track.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/../hakmem_build_flags.h core/box/tiny_layout_box.h \
core/box/../tiny_region_id.h core/hakmem_elo.h core/hakmem_ace_stats.h \
core/hakmem_batch.h core/hakmem_evo.h core/hakmem_debug.h \
core/hakmem_prof.h core/hakmem_syscall.h core/hakmem_ace_controller.h \
core/hakmem_ace_metrics.h core/hakmem_ace_ucb1.h \
core/box/bench_fast_box.h core/ptr_trace.h core/hakmem_trace_master.h \
core/hakmem_stats_master.h core/box/hak_kpi_util.inc.h \
core/box/hak_core_init.inc.h core/hakmem_phase7_config.h \
core/box/libm_reloc_guard_box.h core/box/init_bench_preset_box.h \
core/box/init_diag_box.h core/box/init_env_box.h \
core/box/../tiny_destructors.h core/box/../hakmem_tiny.h \
core/box/ss_hot_prewarm_box.h core/box/hak_alloc_api.inc.h \
core/box/../hakmem_tiny.h core/box/../hakmem_pool.h \
core/box/../hakmem_smallmid.h core/box/tiny_heap_env_box.h \
core/box/c7_hotpath_env_box.h core/box/tiny_heap_box.h \
core/box/../hakmem_tiny_superslab.h \
core/box/../superslab/superslab_inline.h core/box/../tiny_tls.h \
core/box/../hakmem_tiny_superslab.h core/box/../tiny_box_geometry.h \
core/box/tiny_stats_box.h core/box/tiny_c7_hotbox.h \
core/box/mid_large_config_box.h core/box/../hakmem_config.h \
core/box/../hakmem_features.h core/box/hak_free_api.inc.h \
core/hakmem_tiny_superslab.h core/box/../hakmem_trace_master.h \
core/box/front_gate_v2.h core/box/external_guard_box.h \
core/box/../hakmem_stats_master.h core/box/ss_slab_meta_box.h \
core/box/../superslab/superslab_types.h core/box/slab_freelist_atomic.h \
core/box/fg_tiny_gate_box.h core/box/tiny_free_gate_box.h \
core/box/ptr_type_box.h core/box/ptr_conversion_box.h \
core/box/tiny_ptr_bridge_box.h \
core/box/../hakmem_tiny_superslab_internal.h \
core/box/../hakmem_build_flags.h core/box/../box/ss_hot_cold_box.h \
core/box/../box/../superslab/superslab_types.h \
core/box/../box/ss_allocation_box.h core/box/../hakmem_debug_master.h \
core/box/../hakmem_tiny_config.h core/box/../hakmem_shared_pool.h \
core/box/../superslab/superslab_types.h core/box/../hakmem_internal.h \
core/box/../tiny_region_id.h core/box/../hakmem_tiny_integrity.h \
core/box/../box/slab_freelist_atomic.h \
core/box/../tiny_free_fast_v2.inc.h core/box/../box/tls_sll_box.h \
core/box/../box/../hakmem_internal.h \
core/box/../box/../hakmem_tiny_config.h \
core/box/../box/../hakmem_build_flags.h \
core/box/../box/../hakmem_debug_master.h \
core/box/../box/../tiny_remote.h core/box/../box/../tiny_region_id.h \
core/box/../box/../hakmem_tiny_integrity.h \
core/box/../box/../ptr_track.h core/box/../box/../tiny_debug_ring.h \
core/box/../box/ss_addr_map_box.h \
core/box/../box/../superslab/superslab_inline.h \
core/box/../box/tiny_ptr_bridge_box.h core/box/../box/tiny_header_box.h \
core/box/../box/tls_sll_drain_box.h core/box/../box/tls_sll_box.h \
core/box/../box/slab_recycling_box.h \
core/box/../box/../hakmem_tiny_superslab.h \
core/box/../box/ss_hot_cold_box.h core/box/../box/ss_release_guard_box.h \
core/box/../box/../hakmem_tiny_superslab_internal.h \
core/box/../box/free_local_box.h core/box/../box/ptr_type_box.h \
core/box/../box/free_publish_box.h core/hakmem_tiny.h \
core/tiny_region_id.h core/box/../hakmem_env_cache.h \
core/box/../superslab/superslab_inline.h \
core/box/../box/ss_slab_meta_box.h core/box/../box/free_remote_box.h \
core/hakmem_tiny_integrity.h core/box/../box/ptr_conversion_box.h \
core/box/hak_wrappers.inc.h core/box/front_gate_classifier.h \
core/box/../front/malloc_tiny_fast.h \
core/box/../front/../hakmem_build_flags.h \
core/box/../front/../hakmem_tiny_config.h \
core/box/../front/../superslab/superslab_inline.h \
core/box/../front/../box/ss_slab_meta_box.h \
core/box/../front/tiny_unified_cache.h \
core/box/../front/../box/ptr_type_box.h \
core/box/../front/../box/tiny_front_config_box.h \
core/box/../front/../box/../hakmem_build_flags.h \
core/box/../front/../tiny_region_id.h core/box/../front/../hakmem_tiny.h \
core/box/../front/../box/tiny_front_hot_box.h \
core/box/../front/../box/../hakmem_tiny_config.h \
core/box/../front/../box/../tiny_region_id.h \
core/box/../front/../box/../front/tiny_unified_cache.h \
core/box/../front/../box/tiny_layout_box.h \
core/box/../front/../box/tiny_front_cold_box.h \
core/box/../front/../box/tiny_hotheap_v2_box.h \
core/box/../front/../box/smallobject_hotbox_v3_box.h \
core/box/../front/../box/tiny_geometry_box.h \
core/box/../front/../box/../hakmem_tiny_superslab_internal.h \
core/box/../front/../box/../superslab/superslab_inline.h \
core/box/../front/../box/smallobject_hotbox_v3_env_box.h \
core/box/../front/../box/smallobject_hotbox_v4_box.h \
core/box/../front/../box/smallobject_hotbox_v5_box.h \
core/box/../front/../box/tiny_c7_ultra_box.h \
core/box/../front/../box/tiny_c7_ultra_segment_box.h \
core/box/../front/../box/tiny_c6_ultra_free_box.h \
core/box/../front/../box/tiny_c6_ultra_free_env_box.h \
core/box/../front/../box/tiny_c5_ultra_free_box.h \
core/box/../front/../box/tiny_c5_ultra_free_env_box.h \
core/box/../front/../box/tiny_ultra_classes_box.h \
core/box/../front/../box/tiny_legacy_fallback_box.h \
core/box/../front/../box/tiny_front_v3_env_box.h \
core/box/../front/../box/free_path_stats_box.h \
core/box/../front/../box/tiny_front_hot_box.h \
core/box/../front/../box/tiny_ptr_convert_box.h \
core/box/../front/../box/tiny_route_env_box.h \
core/box/../front/../box/smallobject_hotbox_v4_env_box.h \
core/box/../front/../box/smallobject_v5_env_box.h \
core/box/../front/../box/tiny_front_stats_box.h \
core/box/../front/../box/free_path_stats_box.h \
core/box/tiny_alloc_gate_box.h core/box/tiny_route_box.h \
core/box/tiny_front_config_box.h core/box/wrapper_env_box.h \
core/box/../hakmem_internal.h
core/hakmem.h:
core/hakmem_build_flags.h:
core/hakmem_config.h:
core/hakmem_features.h:
core/hakmem_internal.h:
core/hakmem_sys.h:
core/hakmem_whale.h:
core/box/ptr_type_box.h:
core/hakmem_bigcache.h:
core/hakmem_pool.h:
core/box/hak_lane_classify.inc.h:
core/hakmem_l25_pool.h:
core/hakmem_policy.h:
core/hakmem_learner.h:
core/hakmem_size_hist.h:
core/hakmem_ace.h:
core/hakmem_site_rules.h:
core/hakmem_tiny.h:
core/hakmem_trace.h:
core/hakmem_tiny_mini_mag.h:
core/hakmem_tiny_superslab.h:
core/superslab/superslab_types.h:
core/hakmem_tiny_superslab_constants.h:
core/superslab/superslab_inline.h:
core/superslab/superslab_types.h:
core/superslab/../tiny_box_geometry.h:
core/superslab/../hakmem_tiny_superslab_constants.h:
core/superslab/../hakmem_tiny_config.h:
core/superslab/../hakmem_super_registry.h:
core/superslab/../hakmem_tiny_superslab.h:
core/superslab/../box/ss_addr_map_box.h:
core/superslab/../box/../hakmem_build_flags.h:
core/superslab/../box/super_reg_box.h:
core/tiny_debug_ring.h:
core/tiny_remote.h:
core/hakmem_tiny_superslab_constants.h:
core/tiny_fastcache.h:
core/hakmem_env_cache.h:
core/box/tiny_next_ptr_box.h:
core/hakmem_tiny_config.h:
core/tiny_nextptr.h:
core/tiny_region_id.h:
core/tiny_box_geometry.h:
core/ptr_track.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/../hakmem_build_flags.h:
core/box/tiny_layout_box.h:
core/box/../tiny_region_id.h:
core/hakmem_elo.h:
core/hakmem_ace_stats.h:
core/hakmem_batch.h:
core/hakmem_evo.h:
core/hakmem_debug.h:
core/hakmem_prof.h:
core/hakmem_syscall.h:
core/hakmem_ace_controller.h:
core/hakmem_ace_metrics.h:
core/hakmem_ace_ucb1.h:
core/box/bench_fast_box.h:
core/ptr_trace.h:
core/hakmem_trace_master.h:
core/hakmem_stats_master.h:
core/box/hak_kpi_util.inc.h:
core/box/hak_core_init.inc.h:
core/hakmem_phase7_config.h:
core/box/libm_reloc_guard_box.h:
core/box/init_bench_preset_box.h:
core/box/init_diag_box.h:
core/box/init_env_box.h:
core/box/../tiny_destructors.h:
core/box/../hakmem_tiny.h:
core/box/ss_hot_prewarm_box.h:
core/box/hak_alloc_api.inc.h:
core/box/../hakmem_tiny.h:
core/box/../hakmem_pool.h:
core/box/../hakmem_smallmid.h:
core/box/tiny_heap_env_box.h:
core/box/c7_hotpath_env_box.h:
core/box/tiny_heap_box.h:
core/box/../hakmem_tiny_superslab.h:
core/box/../superslab/superslab_inline.h:
core/box/../tiny_tls.h:
core/box/../hakmem_tiny_superslab.h:
core/box/../tiny_box_geometry.h:
core/box/tiny_stats_box.h:
core/box/tiny_c7_hotbox.h:
core/box/mid_large_config_box.h:
core/box/../hakmem_config.h:
core/box/../hakmem_features.h:
core/box/hak_free_api.inc.h:
core/hakmem_tiny_superslab.h:
core/box/../hakmem_trace_master.h:
core/box/front_gate_v2.h:
core/box/external_guard_box.h:
core/box/../hakmem_stats_master.h:
core/box/ss_slab_meta_box.h:
core/box/../superslab/superslab_types.h:
core/box/slab_freelist_atomic.h:
core/box/fg_tiny_gate_box.h:
core/box/tiny_free_gate_box.h:
core/box/ptr_type_box.h:
core/box/ptr_conversion_box.h:
core/box/tiny_ptr_bridge_box.h:
core/box/../hakmem_tiny_superslab_internal.h:
core/box/../hakmem_build_flags.h:
core/box/../box/ss_hot_cold_box.h:
core/box/../box/../superslab/superslab_types.h:
core/box/../box/ss_allocation_box.h:
core/box/../hakmem_debug_master.h:
core/box/../hakmem_tiny_config.h:
core/box/../hakmem_shared_pool.h:
core/box/../superslab/superslab_types.h:
core/box/../hakmem_internal.h:
core/box/../tiny_region_id.h:
core/box/../hakmem_tiny_integrity.h:
core/box/../box/slab_freelist_atomic.h:
core/box/../tiny_free_fast_v2.inc.h:
core/box/../box/tls_sll_box.h:
core/box/../box/../hakmem_internal.h:
core/box/../box/../hakmem_tiny_config.h:
core/box/../box/../hakmem_build_flags.h:
core/box/../box/../hakmem_debug_master.h:
core/box/../box/../tiny_remote.h:
core/box/../box/../tiny_region_id.h:
core/box/../box/../hakmem_tiny_integrity.h:
core/box/../box/../ptr_track.h:
core/box/../box/../tiny_debug_ring.h:
core/box/../box/ss_addr_map_box.h:
core/box/../box/../superslab/superslab_inline.h:
core/box/../box/tiny_ptr_bridge_box.h:
core/box/../box/tiny_header_box.h:
core/box/../box/tls_sll_drain_box.h:
core/box/../box/tls_sll_box.h:
core/box/../box/slab_recycling_box.h:
core/box/../box/../hakmem_tiny_superslab.h:
core/box/../box/ss_hot_cold_box.h:
core/box/../box/ss_release_guard_box.h:
core/box/../box/../hakmem_tiny_superslab_internal.h:
core/box/../box/free_local_box.h:
core/box/../box/ptr_type_box.h:
core/box/../box/free_publish_box.h:
core/hakmem_tiny.h:
core/tiny_region_id.h:
core/box/../hakmem_env_cache.h:
core/box/../superslab/superslab_inline.h:
core/box/../box/ss_slab_meta_box.h:
core/box/../box/free_remote_box.h:
core/hakmem_tiny_integrity.h:
core/box/../box/ptr_conversion_box.h:
core/box/hak_wrappers.inc.h:
core/box/front_gate_classifier.h:
core/box/../front/malloc_tiny_fast.h:
core/box/../front/../hakmem_build_flags.h:
core/box/../front/../hakmem_tiny_config.h:
core/box/../front/../superslab/superslab_inline.h:
core/box/../front/../box/ss_slab_meta_box.h:
core/box/../front/tiny_unified_cache.h:
core/box/../front/../box/ptr_type_box.h:
core/box/../front/../box/tiny_front_config_box.h:
core/box/../front/../box/../hakmem_build_flags.h:
core/box/../front/../tiny_region_id.h:
core/box/../front/../hakmem_tiny.h:
core/box/../front/../box/tiny_front_hot_box.h:
core/box/../front/../box/../hakmem_tiny_config.h:
core/box/../front/../box/../tiny_region_id.h:
core/box/../front/../box/../front/tiny_unified_cache.h:
core/box/../front/../box/tiny_layout_box.h:
core/box/../front/../box/tiny_front_cold_box.h:
core/box/../front/../box/tiny_hotheap_v2_box.h:
core/box/../front/../box/smallobject_hotbox_v3_box.h:
core/box/../front/../box/tiny_geometry_box.h:
core/box/../front/../box/../hakmem_tiny_superslab_internal.h:
core/box/../front/../box/../superslab/superslab_inline.h:
core/box/../front/../box/smallobject_hotbox_v3_env_box.h:
core/box/../front/../box/smallobject_hotbox_v4_box.h:
core/box/../front/../box/smallobject_hotbox_v5_box.h:
core/box/../front/../box/tiny_c7_ultra_box.h:
core/box/../front/../box/tiny_c7_ultra_segment_box.h:
core/box/../front/../box/tiny_c6_ultra_free_box.h:
core/box/../front/../box/tiny_c6_ultra_free_env_box.h:
core/box/../front/../box/tiny_c5_ultra_free_box.h:
core/box/../front/../box/tiny_c5_ultra_free_env_box.h:
core/box/../front/../box/tiny_ultra_classes_box.h:
core/box/../front/../box/tiny_legacy_fallback_box.h:
core/box/../front/../box/tiny_front_v3_env_box.h:
core/box/../front/../box/free_path_stats_box.h:
core/box/../front/../box/tiny_front_hot_box.h:
core/box/../front/../box/tiny_ptr_convert_box.h:
core/box/../front/../box/tiny_route_env_box.h:
core/box/../front/../box/smallobject_hotbox_v4_env_box.h:
core/box/../front/../box/smallobject_v5_env_box.h:
core/box/../front/../box/tiny_front_stats_box.h:
core/box/../front/../box/free_path_stats_box.h:
core/box/tiny_alloc_gate_box.h:
core/box/tiny_route_box.h:
core/box/tiny_front_config_box.h:
core/box/wrapper_env_box.h:
core/box/../hakmem_internal.h: