Commit 16a7ef38 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

on non-Linux platforms allow 20ms of extra leeway on timeout checks

Summary:
In the folly/io/async tests, allow an extra 20ms of tolerance when performing
timeout checks on non-Linux platforms.

On Linux we can fairly reliably determine the amount of time that the test
spent waiting to be scheduled on the CPU.  This allows the timeout tests to be
relatively accurate even on overloaded systems.

On non-Linux platforms we cannot determine the time spent waiting to be
scheduled, and the `getSchedTimeWaiting()` implementation always returns 0.
This causes the tests to fail pretty frequently on Mac OS.  Adding an extra
20ms of tolerance should hopefully help reduce the test failure rate on Mac.

Reviewed By: yfeldblum

Differential Revision: D15464672

fbshipit-source-id: 2c3096df6a15dcdc68bf14c947736e4731929c0f
parent 818e09c0
......@@ -32,6 +32,7 @@
#include <stdexcept>
#include <folly/Conv.h>
#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
#include <folly/String.h>
#include <folly/portability/Unistd.h>
......@@ -276,6 +277,13 @@ bool checkTimeout(
effectiveElapsedTime = elapsedTime - timeExcluded;
}
if (!kIsLinux) {
// We can only compute timeExcluded accurately on Linux.
// On other platforms, just increase the amount of tolerance allowed to
// account for time possibly spent waiting to be scheduled.
tolerance += 20ms;
}
// On x86 Linux, sleep calls generally have precision only to the nearest
// millisecond. The tolerance parameter lets users allow a few ms of slop.
auto overrun = effectiveElapsedTime - expected;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment