Files
hakmem/core/box/ss_ace_box.h
Moe Charm (CI) 9b0d746407 Phase 3d-B: TLS Cache Merge - Unified g_tls_sll[] structure (+12-18% expected)
Merge separate g_tls_sll_head[] and g_tls_sll_count[] arrays into unified
TinyTLSSLL struct to improve L1D cache locality. Expected performance gain:
+12-18% from reducing cache line splits (2 loads → 1 load per operation).

Changes:
- core/hakmem_tiny.h: Add TinyTLSSLL type (16B aligned, head+count+pad)
- core/hakmem_tiny.c: Replace separate arrays with g_tls_sll[8]
- core/box/tls_sll_box.h: Update Box API (13 sites) for unified access
- Updated 32+ files: All g_tls_sll_head[i] → g_tls_sll[i].head
- Updated 32+ files: All g_tls_sll_count[i] → g_tls_sll[i].count
- core/hakmem_tiny_integrity.h: Unified canary guards
- core/box/integrity_box.c: Simplified canary validation
- Makefile: Added core/box/tiny_sizeclass_hist_box.o to link

Build:  PASS (10K ops sanity test)
Warnings: Only pre-existing LTO type mismatches (unrelated)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 07:32:30 +09:00

47 lines
1.6 KiB
C

// 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 <stdint.h>
// 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