From b8a9c90e4fe29821f2ef40796c07c48bd8fac8cc Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 25 Aug 2014 15:58:19 -0400 Subject: sanitize number of spins in userspace before futex wait the previous spin limit of 10000 was utterly unreasonable. empirically, it could consume up to 200000 cycles, whereas a failed futex wait (EAGAIN) typically takes 1000 cycles or less, and even a true wait/wake round seems much less expensive. the new counts (100 for general wait, 200 in barrier) were simply chosen to be in the range of what's reasonable without having adverse effects on casual micro-benchmark tests I have been running. they may still be too high, from a standpoint of not wasting cpu cycles, but at least they're a lot better than before. rigorous testing across different archs and cpu models should be performed at some point to determine whether further adjustments should be made. --- src/thread/__wait.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/thread/__wait.c') diff --git a/src/thread/__wait.c b/src/thread/__wait.c index 3d0d9204..c1d6b61c 100644 --- a/src/thread/__wait.c +++ b/src/thread/__wait.c @@ -2,7 +2,7 @@ void __wait(volatile int *addr, volatile int *waiters, int val, int priv) { - int spins=10000; + int spins=100; if (priv) priv = 128; while (spins--) { if (*addr==val) a_spin(); -- cgit v1.2.1