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

64 lines
2.0 KiB
C

// hakmem_tiny_registry.c
// Phase 2B-3: Registry Operations
// Extracted from hakmem_tiny.c (lines 2653-2674, 2677-2701)
#include <pthread.h>
#include <stdatomic.h>
#include "hakmem_tiny.h"
#include "hakmem_tiny_registry_api.h"
// External globals
extern SlabRegistryEntry g_slab_registry[];
// registry_hash() is defined as static inline in hakmem_tiny_registry_api.h
int registry_register(uintptr_t slab_base, TinySlab* owner) {
pthread_mutex_lock(&g_tiny_registry_lock);
int hash = registry_hash(slab_base);
// Linear probing (max 8 attempts)
for (int i = 0; i < SLAB_REGISTRY_MAX_PROBE; i++) {
int idx = (hash + i) & SLAB_REGISTRY_MASK;
SlabRegistryEntry* entry = &g_slab_registry[idx];
if (entry->slab_base == 0) {
// Empty slot found
entry->slab_base = slab_base;
atomic_store_explicit(&entry->owner, owner, memory_order_release);
pthread_mutex_unlock(&g_tiny_registry_lock);
return 1;
}
}
// Registry full (collision limit exceeded)
pthread_mutex_unlock(&g_tiny_registry_lock);
return 0;
}
void registry_unregister(uintptr_t slab_base) {
pthread_mutex_lock(&g_tiny_registry_lock);
int hash = registry_hash(slab_base);
// Linear probing search
for (int i = 0; i < SLAB_REGISTRY_MAX_PROBE; i++) {
int idx = (hash + i) & SLAB_REGISTRY_MASK;
SlabRegistryEntry* entry = &g_slab_registry[idx];
if (entry->slab_base == slab_base) {
// Found - clear entry (atomic store prevents TOCTOU race)
atomic_store_explicit(&entry->owner, NULL, memory_order_release);
entry->slab_base = 0;
pthread_mutex_unlock(&g_tiny_registry_lock);
return;
}
if (entry->slab_base == 0) {
// Empty slot - not found
pthread_mutex_unlock(&g_tiny_registry_lock);
return;
}
}
pthread_mutex_unlock(&g_tiny_registry_lock);
}