Files
hakmem/core/box/ss_ace_box.h
Moe Charm (CI) acc64f2438 Phase ML1: Pool v1 memset 89.73% overhead 軽量化 (+15.34% improvement)
## Summary
- ChatGPT により bench_profile.h の setenv segfault を修正(RTLD_NEXT 経由に切り替え)
- core/box/pool_zero_mode_box.h 新設:ENV キャッシュ経由で ZERO_MODE を統一管理
- core/hakmem_pool.c で zero mode に応じた memset 制御(FULL/header/off)
- A/B テスト結果:ZERO_MODE=header で +15.34% improvement(1M iterations, C6-heavy)

## Files Modified
- core/box/pool_api.inc.h: pool_zero_mode_box.h include
- core/bench_profile.h: glibc setenv → malloc+putenv(segfault 回避)
- core/hakmem_pool.c: zero mode 参照・制御ロジック
- core/box/pool_zero_mode_box.h (新設): enum/getter
- CURRENT_TASK.md: Phase ML1 結果記載

## Test Results
| Iterations | ZERO_MODE=full | ZERO_MODE=header | Improvement |
|-----------|----------------|-----------------|------------|
| 10K       | 3.06 M ops/s   | 3.17 M ops/s    | +3.65%     |
| 1M        | 23.71 M ops/s  | 27.34 M ops/s   | **+15.34%** |

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-10 09:08:18 +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
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