Infrastructure and build updates
- Update build configuration and flags - Add missing header files and dependencies - Update TLS list implementation with proper scoping - Fix various compilation warnings and issues - Update debug ring and tiny allocation infrastructure - Update benchmark results documentation Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@ -31,7 +31,7 @@ sfc_stats_t g_sfc_stats[TINY_NUM_CLASSES] = {0};
|
||||
// Box 5-NEW: Global Config (from ENV)
|
||||
// ============================================================================
|
||||
|
||||
int g_sfc_enabled = 0; // Default: OFF (A/B testing)
|
||||
int g_sfc_enabled = 1; // Default: ON (bench-focused; A/B via HAKMEM_SFC_ENABLE)
|
||||
|
||||
static int g_sfc_default_capacity = SFC_DEFAULT_CAPACITY;
|
||||
static int g_sfc_default_refill = SFC_DEFAULT_REFILL_COUNT;
|
||||
@ -110,6 +110,9 @@ void sfc_init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Register shutdown hook for optional stats dump
|
||||
atexit(sfc_shutdown);
|
||||
|
||||
// One-shot debug log
|
||||
static int debug_printed = 0;
|
||||
if (!debug_printed) {
|
||||
@ -144,6 +147,37 @@ void sfc_shutdown(void) {
|
||||
// No cleanup needed (TLS memory freed by OS)
|
||||
}
|
||||
|
||||
// Cascade a first batch from TLS SLL into SFC after TLS prewarm.
|
||||
// Hot classes only (0..3 and 5) to focus on 256B/小サイズ。
|
||||
void sfc_cascade_from_tls_initial(void) {
|
||||
if (!g_sfc_enabled) return;
|
||||
// TLS SLL externs
|
||||
extern __thread void* g_tls_sll_head[];
|
||||
extern __thread uint32_t g_tls_sll_count[];
|
||||
for (int cls = 0; cls < TINY_NUM_CLASSES; cls++) {
|
||||
if (!(cls <= 3 || cls == 5)) continue; // focus: 8..64B and 256B
|
||||
uint32_t cap = g_sfc_capacity[cls];
|
||||
if (cap == 0) continue;
|
||||
// target: max half of SFC cap or available SLL count
|
||||
uint32_t avail = g_tls_sll_count[cls];
|
||||
if (avail == 0) continue;
|
||||
uint32_t target = cap / 2;
|
||||
if (target == 0) target = (avail < 16 ? avail : 16);
|
||||
if (target > avail) target = avail;
|
||||
// transfer
|
||||
while (target-- > 0 && g_tls_sll_count[cls] > 0 && g_sfc_count[cls] < g_sfc_capacity[cls]) {
|
||||
void* ptr = NULL;
|
||||
// pop one from SLL
|
||||
extern int tls_sll_pop(int class_idx, void** out_ptr);
|
||||
if (!tls_sll_pop(cls, &ptr)) break;
|
||||
// push into SFC
|
||||
tiny_next_store(ptr, cls, g_sfc_head[cls]);
|
||||
g_sfc_head[cls] = ptr;
|
||||
g_sfc_count[cls]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Box 5-NEW: Refill (Slow Path) - STUB (real logic in hakmem.c)
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user