Files
hakmem/core/hakmem_ace_metrics.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

84 lines
2.8 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_metrics.h - ACE Learning Layer Metrics Collection
*
* メトリクス収集システム:
* - Fast metrics (1Hz): throughput, LLC miss, mutex wait, backlog
* - Slow metrics (60s): fragmentation ratio, RSS
* - Inline helpers for hot-path tracking
*/
#ifndef HAKMEM_ACE_METRICS_H
#define HAKMEM_ACE_METRICS_H
#include <stdint.h>
#include <stdbool.h>
#include <stdatomic.h>
#include <time.h>
/* メトリクス構造体 */
struct hkm_ace_metrics {
/* Fast metrics (updated every 0.5-1s) */
uint64_t throughput_ops; /* Operations per second */
double llc_miss_rate; /* LLC miss rate (0.0-1.0) */
uint64_t mutex_wait_ns; /* Cumulative mutex contention time */
uint32_t remote_free_backlog[8]; /* Per-class remote free backlog */
/* Slow metrics (updated every 60s) */
double fragmentation_ratio; /* allocated / reserved bytes */
uint64_t rss_mb; /* Resident set size in MB */
/* Timestamp */
uint64_t timestamp_ms; /* Collection timestamp */
};
/* グローバルカウンタhot-path用 */
extern _Atomic uint64_t g_ace_alloc_count;
extern _Atomic uint64_t g_ace_free_count;
extern _Atomic uint64_t g_ace_mutex_wait_ns;
/* 初期化・破棄 */
void hkm_ace_metrics_init(void);
void hkm_ace_metrics_destroy(void);
/* メトリクス収集 */
void hkm_ace_metrics_collect(struct hkm_ace_metrics *out);
void hkm_ace_metrics_collect_fast(struct hkm_ace_metrics *out);
void hkm_ace_metrics_collect_slow(struct hkm_ace_metrics *out);
/* Hot-path inline helpers */
/* アロケーションカウント(高速インクリメント) */
static inline void hkm_ace_track_alloc(void) {
atomic_fetch_add_explicit(&g_ace_alloc_count, 1, memory_order_relaxed);
}
/* フリーカウント(高速インクリメント) */
static inline void hkm_ace_track_free(void) {
atomic_fetch_add_explicit(&g_ace_free_count, 1, memory_order_relaxed);
}
/* ミューテックス待機時間トラッキング
* 使い方:
* uint64_t t0 = hkm_ace_mutex_timer_start();
* pthread_mutex_lock(&lock);
* hkm_ace_mutex_timer_end(t0);
*/
static inline uint64_t hkm_ace_mutex_timer_start(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)ts.tv_sec * 1000000000ULL + (uint64_t)ts.tv_nsec;
}
static inline void hkm_ace_mutex_timer_end(uint64_t start_ns) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
uint64_t end_ns = (uint64_t)ts.tv_sec * 1000000000ULL + (uint64_t)ts.tv_nsec;
uint64_t delta = (end_ns > start_ns) ? (end_ns - start_ns) : 0;
atomic_fetch_add_explicit(&g_ace_mutex_wait_ns, delta, memory_order_relaxed);
}
/* LLC miss monitoring (rdpmc wrapper) */
bool hkm_ace_llc_available(void);
void hkm_ace_llc_read(uint64_t *misses, uint64_t *references);
#endif /* HAKMEM_ACE_METRICS_H */