// Box: ACE (Adaptive Control Engine) // Purpose: Dynamic SuperSlab size adaptation based on allocation patterns // // Responsibilities: // - Maintain ACE state per size class (hot_score, current_lg, target_lg) // - Provide ACE-aware size selection for SuperSlab allocation // - Implement promotion/demotion logic (1MB ↔ 2MB) // - Registry-based observation with zero hot-path overhead // - Periodic tick function for counter decay // // Dependencies: // - hakmem_super_registry (for registry-based observation) // - hakmem_tiny_superslab.h (for SuperSlabACEState, TINY_NUM_CLASSES_SS) // // API: // - hak_tiny_superslab_next_lg() - ACE-aware size selection // - hak_tiny_superslab_ace_tick() - periodic ACE tick (counter decay) // - hak_tiny_superslab_ace_observe_all() - learner thread API (registry scan) // - superslab_ace_print_stats() - ACE statistics #ifndef SS_ACE_BOX_H #define SS_ACE_BOX_H #include "hakmem_tiny_superslab.h" #include // ACE state (global, per-class) extern SuperSlabACEState g_ss_ace[TINY_NUM_CLASSES_SS]; // ACE-aware size selection static inline uint8_t hak_tiny_superslab_next_lg(int class_idx); // Optional: runtime profile switch for ACE thresholds (index-based). // Profiles are defined in ss_ace_box.c and selected via env or this setter. void hak_tiny_superslab_ace_set_profile(int idx); // ACE tick function (counter decay) void hak_tiny_superslab_ace_tick(int class_idx, uint64_t now); // Registry-based observation (learner thread API) void hak_tiny_superslab_ace_observe_all(void); // ACE statistics void superslab_ace_print_stats(void); #endif // SS_ACE_BOX_H