Files
hakmem/core/hakmem_ace_controller.h
Moe Charm (CI) 52386401b3 Debug Counters Implementation - Clean History
Major Features:
- Debug counter infrastructure for Refill Stage tracking
- Free Pipeline counters (ss_local, ss_remote, tls_sll)
- Diagnostic counters for early return analysis
- Unified larson.sh benchmark runner with profiles
- Phase 6-3 regression analysis documentation

Bug Fixes:
- Fix SuperSlab disabled by default (HAKMEM_TINY_USE_SUPERSLAB)
- Fix profile variable naming consistency
- Add .gitignore patterns for large files

Performance:
- Phase 6-3: 4.79 M ops/s (has OOM risk)
- With SuperSlab: 3.13 M ops/s (+19% improvement)

This is a clean repository without large log files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 12:31:14 +09:00

107 lines
3.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* hakmem_ace_controller.h - ACE Learning Controller
*
* ACE (Adaptive Control Engine) コントローラー:
* - Fast loop (0.5-1s): TLS capacity, drain threshold調整
* - Slow loop (30-60s): Fragmentation/RSS対策
* - UCB1学習で最適なブ値を選択
*/
#ifndef HAKMEM_ACE_CONTROLLER_H
#define HAKMEM_ACE_CONTROLLER_H
#include "hakmem_ace_metrics.h"
#include "hakmem_ace_ucb1.h"
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
/* ========== TLS Capacity候補値 ========== */
static const uint32_t TLS_CAP_CANDIDATES[] = {
16, 32, 64, 128, 256, 512
};
#define TLS_CAP_N_CANDIDATES (sizeof(TLS_CAP_CANDIDATES) / sizeof(TLS_CAP_CANDIDATES[0]))
/* ========== Drain Threshold候補値 ========== */
static const uint32_t DRAIN_THRESH_CANDIDATES[] = {
64, 128, 256, 512, 1024
};
#define DRAIN_THRESH_N_CANDIDATES (sizeof(DRAIN_THRESH_CANDIDATES) / sizeof(DRAIN_THRESH_CANDIDATES[0]))
/* ========== ACE Controller 構造体 ========== */
struct hkm_ace_controller {
/* 有効/無効フラグ */
bool enabled;
bool running; /* スレッド実行中フラグ */
/* メトリクス */
struct hkm_ace_metrics current;
struct hkm_ace_metrics prev;
/* UCB1 バンディット(クラス毎) */
struct hkm_ucb1_bandit tls_cap_bandit[8]; /* TLS capacity学習 */
struct hkm_ucb1_bandit drain_bandit[8]; /* Drain threshold学習 */
/* 現在のノブ値 */
uint32_t tls_capacity[8]; /* Per-class TLS magazine capacity */
uint32_t drain_threshold[8]; /* Per-class remote free drain threshold */
/* Fast loop設定 */
uint64_t fast_interval_ms; /* Fast loopインターバルデフォルト500ms */
uint64_t last_fast_tick_ms; /* 前回Fast loop実行時刻 */
/* Slow loop設定 */
uint64_t slow_interval_ms; /* Slow loopインターバルデフォルト30000ms */
uint64_t last_slow_tick_ms; /* 前回Slow loop実行時刻 */
/* ログレベル */
int log_level; /* 0=off, 1=info, 2=debug */
/* バックグラウンドスレッド */
pthread_t bg_thread;
bool stop_requested;
};
/* ========== API ========== */
/* 初期化(環境変数から設定読み込み) */
void hkm_ace_controller_init(struct hkm_ace_controller *ctrl);
/* 破棄(スレッド停止) */
void hkm_ace_controller_destroy(struct hkm_ace_controller *ctrl);
/* Tick処理fast/slow両方実行 */
void hkm_ace_controller_tick(struct hkm_ace_controller *ctrl);
/* Fast loop0.5-1s間隔 */
void hkm_ace_controller_fast_loop(struct hkm_ace_controller *ctrl);
/* Slow loop30-60s間隔 */
void hkm_ace_controller_slow_loop(struct hkm_ace_controller *ctrl);
/* バックグラウンドスレッド開始 */
void hkm_ace_controller_start(struct hkm_ace_controller *ctrl);
/* バックグラウンドスレッド停止 */
void hkm_ace_controller_stop(struct hkm_ace_controller *ctrl);
/* ========== Inline Helpers ========== */
/* コントローラーが有効か確認 */
static inline bool hkm_ace_is_enabled(const struct hkm_ace_controller *ctrl) {
return ctrl && ctrl->enabled;
}
/* ログ出力ヘルパー */
static inline bool hkm_ace_log_info_enabled(const struct hkm_ace_controller *ctrl) {
return ctrl && ctrl->log_level >= 1;
}
static inline bool hkm_ace_log_debug_enabled(const struct hkm_ace_controller *ctrl) {
return ctrl && ctrl->log_level >= 2;
}
#endif /* HAKMEM_ACE_CONTROLLER_H */