commit e3e60f1c3c09a3d65c1008735edc464eaea76b06 Author: Daniel Black Date: Thu Feb 25 23:22:28 2016 -0600 LF memory allocator to align to line cache size Rather than using a constant 64 line size, this used the CPU_LEVEL1_DCACHE_LINESIZE as a mechanism to calculate the pad size. diff --git a/include/lf.h b/include/lf.h index d807b21..3e9cdb3 100644 --- a/include/lf.h +++ b/include/lf.h @@ -115,9 +115,9 @@ typedef struct { void *purgatory; uint32 purgatory_count; uint32 volatile link; -/* we want sizeof(LF_PINS) to be 64 to avoid false sharing */ -#if SIZEOF_INT*2+SIZEOF_CHARP*(LF_PINBOX_PINS+3) != 64 - char pad[64-sizeof(uint32)*2-sizeof(void*)*(LF_PINBOX_PINS+3)]; +/* we want sizeof(LF_PINS) to be CPU_LEVEL1_DCACHE_LINESIZE to avoid false sharing */ +#if SIZEOF_INT*2+SIZEOF_CHARP*(LF_PINBOX_PINS+3) != CPU_LEVEL1_DCACHE_LINESIZE + char pad[CPU_LEVEL1_DCACHE_LINESIZE-sizeof(uint32)*2-sizeof(void*)*(LF_PINBOX_PINS+3)]; #endif } LF_PINS; diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c index 65db784..b41c508 100644 --- a/mysys/lf_alloc-pin.c +++ b/mysys/lf_alloc-pin.c @@ -115,7 +115,7 @@ void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset, lf_pinbox_free_func *free_func, void *free_func_arg) { DBUG_ASSERT(free_ptr_offset % sizeof(void *) == 0); - compile_time_assert(sizeof(LF_PINS) == 64); + compile_time_assert(sizeof(LF_PINS) == CPU_LEVEL1_DCACHE_LINESIZE); lf_dynarray_init(&pinbox->pinarray, sizeof(LF_PINS)); pinbox->pinstack_top_ver= 0; pinbox->pins_in_array= 0;