Phase 3d-B: TLS Cache Merge - Unified g_tls_sll[] structure (+12-18% expected)

Merge separate g_tls_sll_head[] and g_tls_sll_count[] arrays into unified
TinyTLSSLL struct to improve L1D cache locality. Expected performance gain:
+12-18% from reducing cache line splits (2 loads → 1 load per operation).

Changes:
- core/hakmem_tiny.h: Add TinyTLSSLL type (16B aligned, head+count+pad)
- core/hakmem_tiny.c: Replace separate arrays with g_tls_sll[8]
- core/box/tls_sll_box.h: Update Box API (13 sites) for unified access
- Updated 32+ files: All g_tls_sll_head[i] → g_tls_sll[i].head
- Updated 32+ files: All g_tls_sll_count[i] → g_tls_sll[i].count
- core/hakmem_tiny_integrity.h: Unified canary guards
- core/box/integrity_box.c: Simplified canary validation
- Makefile: Added core/box/tiny_sizeclass_hist_box.o to link

Build:  PASS (10K ops sanity test)
Warnings: Only pre-existing LTO type mismatches (unrelated)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm (CI)
2025-11-20 07:32:30 +09:00
parent 38552c3f39
commit 9b0d746407
83 changed files with 7509 additions and 259 deletions

View File

@ -81,7 +81,7 @@ void grow_tls_cache(int class_idx) {
}
void drain_excess_blocks(int class_idx, int count) {
void** head = &g_tls_sll_head[class_idx];
void** head = &g_tls_sll[class_idx].head;
int drained = 0;
while (*head && drained < count) {
@ -94,8 +94,8 @@ void drain_excess_blocks(int class_idx, int count) {
// TODO: Integrate with proper SuperSlab return path
drained++;
if (g_tls_sll_count[class_idx] > 0) {
g_tls_sll_count[class_idx]--;
if (g_tls_sll[class_idx].count > 0) {
g_tls_sll[class_idx].count--;
}
}
@ -117,8 +117,8 @@ void shrink_tls_cache(int class_idx) {
}
// Evict excess blocks if current count > new_capacity
if (g_tls_sll_count[class_idx] > new_capacity) {
int excess = (int)(g_tls_sll_count[class_idx] - new_capacity);
if (g_tls_sll[class_idx].count > new_capacity) {
int excess = (int)(g_tls_sll[class_idx].count - new_capacity);
drain_excess_blocks(class_idx, excess);
}
@ -173,7 +173,7 @@ void adapt_tls_cache_size(int class_idx) {
}
// Reset stats for next window
stats->high_water_mark = g_tls_sll_count[class_idx];
stats->high_water_mark = g_tls_sll[class_idx].count;
stats->refill_count = 0;
stats->last_adapt_time = now;
}