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

94 lines
3.4 KiB
C

// hakmem_features.h - Feature Flags & Capability Enumeration
// Purpose: Centralize all feature toggles for mode-based configuration
#ifndef HAKMEM_FEATURES_H
#define HAKMEM_FEATURES_H
#include <stdint.h>
// ===========================================================================
// Feature Categories (Bitflags)
// ===========================================================================
// Category 1: Allocation Strategies
typedef enum {
HAKMEM_FEATURE_MALLOC = 1 << 0, // Basic malloc/free
HAKMEM_FEATURE_MMAP = 1 << 1, // mmap for large allocations
HAKMEM_FEATURE_POOL = 1 << 2, // Per-thread pools (future)
} HakemAllocFeatures;
// Category 2: Caching
typedef enum {
HAKMEM_FEATURE_BIGCACHE = 1 << 0, // Tier-2 large block cache
HAKMEM_FEATURE_TINYPOOL = 1 << 1, // Tier-1 small block pool (future)
} HakemCacheFeatures;
// Category 3: Learning & Adaptation
typedef enum {
HAKMEM_FEATURE_ELO = 1 << 0, // ELO strategy selection
HAKMEM_FEATURE_EVOLUTION = 1 << 1, // Learning lifecycle (LEARN/FROZEN/CANARY)
HAKMEM_FEATURE_PROFILING = 1 << 2, // Call-site profiling
} HakemLearningFeatures;
// Category 4: Memory Management Policies
typedef enum {
HAKMEM_FEATURE_BATCH_MADVISE = 1 << 0, // Batch madvise for TLB optimization
HAKMEM_FEATURE_THP = 1 << 1, // Transparent Huge Pages
HAKMEM_FEATURE_FREE_POLICY = 1 << 2, // Hot/Warm/Cold free policy
} HakemMemoryFeatures;
// Category 5: Debug & Instrumentation
typedef enum {
HAKMEM_FEATURE_DEBUG_LOG = 1 << 0, // Verbose debug logging
HAKMEM_FEATURE_STATISTICS = 1 << 1, // Detailed statistics collection
HAKMEM_FEATURE_TRACE = 1 << 2, // Allocation tracing
} HakemDebugFeatures;
// ===========================================================================
// Feature Set (Combined)
// ===========================================================================
typedef struct {
uint32_t alloc; // HakemAllocFeatures
uint32_t cache; // HakemCacheFeatures
uint32_t learning; // HakemLearningFeatures
uint32_t memory; // HakemMemoryFeatures
uint32_t debug; // HakemDebugFeatures
} HakemFeatureSet;
// ===========================================================================
// Feature Queries (Inline helpers)
// ===========================================================================
static inline int hak_has_feature_alloc(HakemFeatureSet* fs, HakemAllocFeatures f) {
return (fs->alloc & f) != 0;
}
static inline int hak_has_feature_cache(HakemFeatureSet* fs, HakemCacheFeatures f) {
return (fs->cache & f) != 0;
}
static inline int hak_has_feature_learning(HakemFeatureSet* fs, HakemLearningFeatures f) {
return (fs->learning & f) != 0;
}
static inline int hak_has_feature_memory(HakemFeatureSet* fs, HakemMemoryFeatures f) {
return (fs->memory & f) != 0;
}
static inline int hak_has_feature_debug(HakemFeatureSet* fs, HakemDebugFeatures f) {
return (fs->debug & f) != 0;
}
// ===========================================================================
// Mode Presets (Defined in hakmem_config.c)
// ===========================================================================
// Get feature set for a mode
HakemFeatureSet hak_features_for_mode(const char* mode);
// Print feature set (debug)
void hak_features_print(HakemFeatureSet* fs);
#endif // HAKMEM_FEATURES_H