From 2986be1dd50be033cd8573afd544fc164bd12bc7 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 11 Oct 2026 00:47:00 +0100 Subject: Spin way less before futexing in fastspin According to some reading I did recently on hybrid locks, a value of around 40 is optimal, or at least was at one point. It might have changed in more recent years and I have by no means made any effort to tune the value, but it seems clear that 1000 is way too high. --- src/chunklets/fastspin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/chunklets/fastspin.c b/src/chunklets/fastspin.c index d349395..c61d781 100644 --- a/src/chunklets/fastspin.c +++ b/src/chunklets/fastspin.c @@ -236,7 +236,7 @@ int fastspin_wait(volatile int *p_) { #else if (x > 0) return x; if (!x) { - for (int c = 1000; c; --c) { + for (int c = 40; c; --c) { x = atomic_load_explicit(p, memory_order_relaxed); RELAX(); if (x > 0) return x; @@ -269,7 +269,7 @@ top: x = 0; return; } if (x) { - for (int c = 1000; c; --c) { + for (int c = 40; c; --c) { x = atomic_load_explicit(p, memory_order_relaxed); RELAX(); // note: top sets x to 0 unnecessarily but clang actually does -- cgit v1.2.3-54-g00ecf