Skip to content

Commit 392398b

Browse files
committed
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.
1 parent 9a83343 commit 392398b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/basic/timeout_config.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
$t = 3;
44

5-
function busy_wait($how_long)
6-
{
7-
$until = microtime(TRUE) + $how_long;
8-
9-
while ($until > microtime(TRUE));
5+
function busy_wait($how_long) {
6+
$until = microtime(true) + $how_long;
7+
do {
8+
for ($i = 0; $i < 1000000; $i++);
9+
} while ($until > microtime(true));
1010
}

0 commit comments

Comments
 (0)