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:
@ -19,10 +19,9 @@
|
||||
#define TLS_CANARY_MAGIC 0xDEADBEEFDEADBEEFULL
|
||||
|
||||
// External canaries from 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;
|
||||
|
||||
// ============================================================================
|
||||
// Global Statistics (atomic for thread safety)
|
||||
@ -162,58 +161,32 @@ IntegrityResult integrity_validate_tls_canaries(const char* context) {
|
||||
atomic_fetch_add(&g_integrity_checks_performed, 1);
|
||||
atomic_fetch_add(&g_integrity_canary_checks, 1);
|
||||
|
||||
// Check canary before sll_head array
|
||||
if (g_tls_canary_before_sll_head != TLS_CANARY_MAGIC) {
|
||||
// Phase 3d-B: Check canary before unified g_tls_sll array
|
||||
if (g_tls_canary_before_sll != TLS_CANARY_MAGIC) {
|
||||
atomic_fetch_add(&g_integrity_checks_failed, 1);
|
||||
return (IntegrityResult){
|
||||
.passed = false,
|
||||
.check_name = "CANARY_CORRUPTED_BEFORE_HEAD",
|
||||
.check_name = "CANARY_CORRUPTED_BEFORE_SLL",
|
||||
.file = __FILE__,
|
||||
.line = __LINE__,
|
||||
.message = "Canary before g_tls_sll_head corrupted",
|
||||
.message = "Canary before g_tls_sll corrupted",
|
||||
.error_code = INTEGRITY_ERROR_CANARY_CORRUPTED_BEFORE_HEAD
|
||||
};
|
||||
}
|
||||
|
||||
// Check canary after sll_head array
|
||||
if (g_tls_canary_after_sll_head != TLS_CANARY_MAGIC) {
|
||||
// Phase 3d-B: Check canary after unified g_tls_sll array
|
||||
if (g_tls_canary_after_sll != TLS_CANARY_MAGIC) {
|
||||
atomic_fetch_add(&g_integrity_checks_failed, 1);
|
||||
return (IntegrityResult){
|
||||
.passed = false,
|
||||
.check_name = "CANARY_CORRUPTED_AFTER_HEAD",
|
||||
.check_name = "CANARY_CORRUPTED_AFTER_SLL",
|
||||
.file = __FILE__,
|
||||
.line = __LINE__,
|
||||
.message = "Canary after g_tls_sll_head corrupted",
|
||||
.message = "Canary after g_tls_sll corrupted",
|
||||
.error_code = INTEGRITY_ERROR_CANARY_CORRUPTED_AFTER_HEAD
|
||||
};
|
||||
}
|
||||
|
||||
// Check canary before sll_count array
|
||||
if (g_tls_canary_before_sll_count != TLS_CANARY_MAGIC) {
|
||||
atomic_fetch_add(&g_integrity_checks_failed, 1);
|
||||
return (IntegrityResult){
|
||||
.passed = false,
|
||||
.check_name = "CANARY_CORRUPTED_BEFORE_COUNT",
|
||||
.file = __FILE__,
|
||||
.line = __LINE__,
|
||||
.message = "Canary before g_tls_sll_count corrupted",
|
||||
.error_code = INTEGRITY_ERROR_CANARY_CORRUPTED_BEFORE_COUNT
|
||||
};
|
||||
}
|
||||
|
||||
// Check canary after sll_count array
|
||||
if (g_tls_canary_after_sll_count != TLS_CANARY_MAGIC) {
|
||||
atomic_fetch_add(&g_integrity_checks_failed, 1);
|
||||
return (IntegrityResult){
|
||||
.passed = false,
|
||||
.check_name = "CANARY_CORRUPTED_AFTER_COUNT",
|
||||
.file = __FILE__,
|
||||
.line = __LINE__,
|
||||
.message = "Canary after g_tls_sll_count corrupted",
|
||||
.error_code = INTEGRITY_ERROR_CANARY_CORRUPTED_AFTER_COUNT
|
||||
};
|
||||
}
|
||||
|
||||
atomic_fetch_add(&g_integrity_checks_passed, 1);
|
||||
return (IntegrityResult){
|
||||
.passed = true,
|
||||
|
||||
Reference in New Issue
Block a user