From: Nikita Popov Date: Mon, 8 Jul 2019 11:26:59 +0000 (+0200) Subject: Make busy wait busier X-Git-Tag: php-7.4.0alpha3~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=392398bfe63b43288a0fbd301491b564eb24dfe9;p=php 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. --- diff --git a/tests/basic/timeout_config.inc b/tests/basic/timeout_config.inc index 3bd9eeaa70..5cd156f471 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)); }