From 48ec09ca1036fa66e2a197987946dfdb04128ee9 Mon Sep 17 00:00:00 2001 From: d-netto Date: Sun, 21 Jan 2024 10:14:12 -0300 Subject: [PATCH] place work-stealing queue indices on different cache lines to avoid false-sharing --- src/work-stealing-queue.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/work-stealing-queue.h b/src/work-stealing-queue.h index 38429e02886e9..070a42b98ef85 100644 --- a/src/work-stealing-queue.h +++ b/src/work-stealing-queue.h @@ -36,6 +36,13 @@ static inline ws_array_t *create_ws_array(size_t capacity, int32_t eltsz) JL_NOT typedef struct { _Atomic(int64_t) top; + // put `top` and `bottom` on different cache lines + // to avoid false sharing +#ifdef _P64 + void *_ignore[7]; +#else + void *_ignore[15]; +#endif _Atomic(int64_t) bottom; _Atomic(ws_array_t *) array; } ws_queue_t;