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:
@ -126,36 +126,23 @@ static inline int validate_ptr_range(void* ptr, const char* location) {
|
||||
#define TLS_CANARY_MAGIC 0xDEADBEEFDEADBEEFULL
|
||||
|
||||
// External declarations (defined in hakmem_tiny.c)
|
||||
extern __thread uint64_t g_tls_canary_before_sll_head;
|
||||
extern __thread uint64_t g_tls_canary_after_sll_head;
|
||||
extern __thread uint64_t g_tls_canary_before_sll_count;
|
||||
extern __thread uint64_t g_tls_canary_after_sll_count;
|
||||
// Phase 3d-B: TLS Cache Merge - Unified canaries for unified TLS SLL array
|
||||
extern __thread uint64_t g_tls_canary_before_sll;
|
||||
extern __thread uint64_t g_tls_canary_after_sll;
|
||||
|
||||
// Validate TLS canaries (call periodically)
|
||||
static inline void validate_tls_canaries(const char* location) {
|
||||
if (g_tls_canary_before_sll_head != TLS_CANARY_MAGIC) {
|
||||
fprintf(stderr, "[TLS_CANARY] %s: g_tls_sll_head BEFORE canary corrupted: 0x%016lx (expected 0x%016lx)\n",
|
||||
location, g_tls_canary_before_sll_head, TLS_CANARY_MAGIC);
|
||||
if (g_tls_canary_before_sll != TLS_CANARY_MAGIC) {
|
||||
fprintf(stderr, "[TLS_CANARY] %s: g_tls_sll BEFORE canary corrupted: 0x%016lx (expected 0x%016lx)\n",
|
||||
location, g_tls_canary_before_sll, TLS_CANARY_MAGIC);
|
||||
fflush(stderr);
|
||||
assert(0 && "TLS canary before sll_head corrupted");
|
||||
assert(0 && "TLS canary before g_tls_sll corrupted");
|
||||
}
|
||||
if (g_tls_canary_after_sll_head != TLS_CANARY_MAGIC) {
|
||||
fprintf(stderr, "[TLS_CANARY] %s: g_tls_sll_head AFTER canary corrupted: 0x%016lx (expected 0x%016lx)\n",
|
||||
location, g_tls_canary_after_sll_head, TLS_CANARY_MAGIC);
|
||||
if (g_tls_canary_after_sll != TLS_CANARY_MAGIC) {
|
||||
fprintf(stderr, "[TLS_CANARY] %s: g_tls_sll AFTER canary corrupted: 0x%016lx (expected 0x%016lx)\n",
|
||||
location, g_tls_canary_after_sll, TLS_CANARY_MAGIC);
|
||||
fflush(stderr);
|
||||
assert(0 && "TLS canary after sll_head corrupted");
|
||||
}
|
||||
if (g_tls_canary_before_sll_count != TLS_CANARY_MAGIC) {
|
||||
fprintf(stderr, "[TLS_CANARY] %s: g_tls_sll_count BEFORE canary corrupted: 0x%016lx (expected 0x%016lx)\n",
|
||||
location, g_tls_canary_before_sll_count, TLS_CANARY_MAGIC);
|
||||
fflush(stderr);
|
||||
assert(0 && "TLS canary before sll_count corrupted");
|
||||
}
|
||||
if (g_tls_canary_after_sll_count != TLS_CANARY_MAGIC) {
|
||||
fprintf(stderr, "[TLS_CANARY] %s: g_tls_sll_count AFTER canary corrupted: 0x%016lx (expected 0x%016lx)\n",
|
||||
location, g_tls_canary_after_sll_count, TLS_CANARY_MAGIC);
|
||||
fflush(stderr);
|
||||
assert(0 && "TLS canary after sll_count corrupted");
|
||||
assert(0 && "TLS canary after g_tls_sll corrupted");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user