Files
hakmem/core/box/tiny_ultra_classes_box.h
Moe Charm (CI) fb88725a43 Phase FREE-LEGACY-OPT-6: C4 ULTRA Implementation
Implement C4 ULTRA free TLS cache with parasitic free+alloc pattern,
achieving 99.7-99.9% elimination of C4 legacy fallback calls.

Key Features:
- TLS cache cap=64 (tuned for L1 cache fit, smaller than C5/C6's 128)
- Segment learning via ss_fast_lookup() on first free
- Free-side cache push + alloc-side TLS pop pattern
- ENV gate: HAKMEM_TINY_C4_ULTRA_FREE_ENABLED (default OFF)
- Full FREE_PATH_STATS instrumentation

Benchmark Results:
C4-heavy (65-128B range):
  - C4 legacy: 591,583 → 1,711 (-99.7%)
  - c4_ultra cache hits: ~599k (free) + ~599k (alloc)
  - Mixed load: 340,732 → 284 C4 legacy (-99.9%)

Legacy fallback reduction:
  - C4-heavy: 589,872 fewer legacy calls (-10.9% total)
  - Mixed: 340,448 fewer C4 legacy calls (-12.8% in mixed)

Performance note: ~2% throughput cost in isolated C4-heavy case,
acceptable tradeoff for 99%+ legacy elimination per class.

Files:
  NEW: core/box/tiny_c4_ultra_free_box.h/c
  NEW: core/box/tiny_c4_ultra_free_env_box.h
  MOD: core/box/tiny_ultra_classes_box.h (added C4 macros)
  MOD: core/box/free_path_stats_box.h/c (C4 ULTRA counters)
  MOD: core/front/malloc_tiny_fast.h (C4 alloc+free integration)
  MOD: Makefile (added C4 ULTRA object)

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

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

18 lines
689 B
C

#ifndef HAKMEM_TINY_ULTRA_CLASSES_BOX_H
#define HAKMEM_TINY_ULTRA_CLASSES_BOX_H
// Purpose: Named constants for ULTRA tier classes (C4, C5, C6, C7)
#define TINY_CLASS_C4 4
#define TINY_CLASS_C5 5
#define TINY_CLASS_C6 6
#define TINY_CLASS_C7 7
// Helper macros for class checking
#define tiny_class_is_c4(idx) ((idx) == TINY_CLASS_C4)
#define tiny_class_is_c5(idx) ((idx) == TINY_CLASS_C5)
#define tiny_class_is_c6(idx) ((idx) == TINY_CLASS_C6)
#define tiny_class_is_c7(idx) ((idx) == TINY_CLASS_C7)
#define tiny_class_is_ultra(idx) (tiny_class_is_c4(idx) || tiny_class_is_c5(idx) || tiny_class_is_c6(idx) || tiny_class_is_c7(idx))
#endif // HAKMEM_TINY_ULTRA_CLASSES_BOX_H