From 392398bfe63b43288a0fbd301491b564eb24dfe9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 8 Jul 2019 13:26:59 +0200 Subject: [PATCH] Make busy wait busier Another stab in the dark to fix the intermittent failures of timeout tests on macos CI: We're using ITIMER_PROF, which means that the timer counts against user+system time. The "busy" wait loop counts against real time. Currently it calls microtime() on every iteration. If that call is implemented as a syscall rather than going through vDSO or commpage we might be seeing many context switches here which drive up the real time, but not user or system time. See if making the loop busier and calling microtime() less helps the situation. --- tests/basic/timeout_config.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/basic/timeout_config.inc b/tests/basic/timeout_config.inc index 3bd9eeaa708..5cd156f471f 100644 --- a/tests/basic/timeout_config.inc +++ b/tests/basic/timeout_config.inc @@ -2,9 +2,9 @@ $t = 3; -function busy_wait($how_long) -{ - $until = microtime(TRUE) + $how_long; - - while ($until > microtime(TRUE)); +function busy_wait($how_long) { + $until = microtime(true) + $how_long; + do { + for ($i = 0; $i < 1000000; $i++); + } while ($until > microtime(true)); }