Boxify superslab registry, add bench profile, and document C7 hotpath experiments

This commit is contained in:
Moe Charm (CI)
2025-12-07 03:12:27 +09:00
parent 18faa6a1c4
commit fda6cd2e67
71 changed files with 2052 additions and 286 deletions

View File

@ -7,6 +7,7 @@
#include "hakmem_prof.h"
#include "hakmem_internal.h"
#include "box/tiny_next_ptr_box.h" // Box API: Next pointer read/write
#include "box/tiny_mem_stats_box.h"
#include <pthread.h>
static inline uint32_t tiny_self_u32_guard(void) {
@ -36,6 +37,14 @@ int g_mag_cap_limit = TINY_TLS_MAG_CAP;
int g_mag_cap_override[TINY_NUM_CLASSES] = {0}; // HAKMEM_TINY_MAG_CAP_C{0..7}
__thread int g_tls_small_mags_inited = 0;
static __thread int g_tls_mag_mem_recorded = 0;
static inline void tiny_mag_record_mem_once(void) {
if (!g_tls_mag_mem_recorded) {
tiny_mem_stats_add_tls_magazine((ssize_t)sizeof(g_tls_mags));
g_tls_mag_mem_recorded = 1;
}
}
// tiny_default_cap() and tiny_cap_max_for_class() now defined as inline functions
// in hakmem_tiny_config.h for centralized configuration
@ -49,6 +58,7 @@ int tiny_effective_cap(int class_idx) {
void tiny_small_mags_init_once(void) {
if (__builtin_expect(g_tls_small_mags_inited, 1)) return;
tiny_mag_record_mem_once();
for (int k = 0; k <= 3; k++) {
TinyTLSMag* m = &g_tls_mags[k];
if (m->cap == 0) {
@ -65,6 +75,7 @@ void tiny_small_mags_init_once(void) {
void tiny_mag_init_if_needed(int class_idx) {
TinyTLSMag* mag = &g_tls_mags[class_idx];
if (mag->cap == 0) {
tiny_mag_record_mem_once();
int base = tiny_effective_cap(class_idx);
int cap = (base < TINY_TLS_MAG_CAP) ? base : TINY_TLS_MAG_CAP;
if (g_mag_cap_limit < cap) cap = g_mag_cap_limit;