From c53b10e8829b6f3dbbe5d21f84110037c3f3f38a Mon Sep 17 00:00:00 2001 From: Miguel Sofer Date: Sun, 31 Jan 2016 08:28:44 +0000 Subject: (NON_PORTABLE) insure good cache alignment of NRE_callback --- TODO_DONE | 11 +++++++---- generic/tclNRE.h | 13 ++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/TODO_DONE b/TODO_DONE index 96a275b..6e59acf 100644 --- a/TODO_DONE +++ b/TODO_DONE @@ -15,10 +15,6 @@ * mig-alloc-reform: what can be brought in? At least forget -DPURIFY, make it usable from normal builds. -* mod the callback struct: make it have only 3 data fields, 4 in - total. This will reduce the size, possible improvements due to cache and - memory alignment issues. - ************************************************************************* **** DONE *************************************************************** ************************************************************************* @@ -71,3 +67,10 @@ This is done by defining HAVE_FAST_TSD in the defaut build; can remove it later on for the default - handy while developing. FIXME!! +* mod the callback struct: make it have only 3 data fields, 4 in + total. This will reduce the size, possible improvements due to cache and + memory alignment issues. + +* INCOMPATIBILITY ... or at least, no attention paid to windows. We are + using __atribute__ to insure good cache alignment of NRE_callback, this + is certainly not portable. diff --git a/generic/tclNRE.h b/generic/tclNRE.h index a00e75f..7cf2a55 100644 --- a/generic/tclNRE.h +++ b/generic/tclNRE.h @@ -18,10 +18,21 @@ typedef struct NRE_callback { ClientData data[3]; } NRE_callback; +/* + * - NOTES ON ALIGNMENT - + * + * . Cache lines are 64B long; callbacks are 32B on x86_64 and 16B on x32. In + * order to insure that no callback ever strides cache line boundaries, we + * require the first callback to be aligned to 32b (on x32, 16B would be + * enough). + * . we use a gcc'ism to insure alignment, portability not being the priority + * right now. + */ + typedef struct NRE_stack { struct NRE_callback items[NRE_STACK_SIZE]; struct NRE_stack *next; -} NRE_stack; +} NRE_stack __attribute__ ((aligned (32))); #define NRE_newExtra(ptr) \ TclSmallAlloc(5*sizeof(ClientData), ptr) -- cgit v0.12