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

69 lines
2.0 KiB
C

// hakmem_tiny_simple.h
// Phase 6-1: Ultra-Simple Tiny Allocator (Learning-Based)
//
// Design Philosophy: "Simple Front + Smart Back"
// - Front: Ultra-simple fast path (3-4 instructions, tcache-style)
// - Back: Learning layer (adaptive capacity, hotness tracking)
//
// Inspired by Mid-Large HAKX success (+171%)
#ifndef HAKMEM_TINY_SIMPLE_H
#define HAKMEM_TINY_SIMPLE_H
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
// ============================================================================
// Phase 1: Ultra-Simple Fast Path
// ============================================================================
// Size classes (same as existing Tiny)
#define TINY_NUM_CLASSES 8
// TLS Free List (per size class)
// This is the ONLY data structure in the fast path!
extern __thread void* g_tls_tiny_cache[TINY_NUM_CLASSES];
// Inline size-to-class conversion (must be FAST!)
static inline int hak_tiny_simple_size_to_class(size_t size) {
if (size <= 8) return 0;
if (size <= 16) return 1;
if (size <= 32) return 2;
if (size <= 64) return 3;
if (size <= 128) return 4;
if (size <= 256) return 5;
if (size <= 512) return 6;
if (size <= 1024) return 7;
return -1; // >1KB
}
// ============================================================================
// Public API
// ============================================================================
// Initialize simple tiny allocator
void hak_tiny_simple_init(void);
// Ultra-fast allocation (3-4 instructions!)
void* hak_tiny_simple_alloc(size_t size);
// Fast free
void hak_tiny_simple_free(void* ptr, size_t size);
// Slow path (refill from SuperSlab)
void* hak_tiny_simple_alloc_slow(size_t size, int class_idx);
// Stats (for debugging/profiling)
typedef struct {
uint64_t alloc_count;
uint64_t free_count;
uint64_t miss_count;
uint64_t hit_count;
} TinySimpleStats;
void hak_tiny_simple_get_stats(int class_idx, TinySimpleStats* stats);
void hak_tiny_simple_print_stats(void);
#endif // HAKMEM_TINY_SIMPLE_H