This is an automated email from the ASF dual-hosted git repository. alexey pushed a commit to branch branch-1.11.x in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 26b994365e66cd53b65e586f5ab30c2c21d4206c Author: Alexey Serbin <[email protected]> AuthorDate: Wed Oct 16 15:18:49 2019 -0700 [clock] add exponential backoff in HybridClock::Init() This patch introduces exponential back-off when polling the synchronisation status of the underlying time service (i.e. calling TimeService::WalltimeWithError()) during HybridClock::Init(). Now, the polling interval starts with 1 millisecond and exponentially grows up to 1 second. Prior to this patch, the polling interval was one second, and in case if time source synchronized faster than in one second, HybridClock::Init() would incur extra latency (e.g., in case of tests running with the built-in NTP client synchronized against MiniChronyd). I verified that with the new approach ExternalMiniCluster-based tests run faster: before [ OK ] AllTypesItest/9.TestTimestampPadding (6794 ms) after [ OK ] AllTypesItest/9.TestTimestampPadding (2730 ms) Change-Id: I75924f1fdcf6a32684cda29bbfa959b00172b50e Reviewed-on: http://gerrit.cloudera.org:8080/14472 Reviewed-by: Adar Dembo <[email protected]> Tested-by: Kudu Jenkins (cherry picked from commit 1bb267bd8587473c567ca76426689e33ff4c9b89) Reviewed-on: http://gerrit.cloudera.org:8080/14476 Reviewed-by: Grant Henke <[email protected]> --- src/kudu/clock/hybrid_clock.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/kudu/clock/hybrid_clock.cc b/src/kudu/clock/hybrid_clock.cc index 07170f6..99ea277 100644 --- a/src/kudu/clock/hybrid_clock.cc +++ b/src/kudu/clock/hybrid_clock.cc @@ -151,6 +151,7 @@ Status HybridClock::Init() { Status s; uint64_t now_usec; uint64_t error_usec; + int poll_backoff_ms = 1; do { s = time_service_->WalltimeWithError(&now_usec, &error_usec); if (!s.IsServiceUnavailable()) { @@ -168,7 +169,8 @@ Status HybridClock::Init() { } need_log = false; } - SleepFor(MonoDelta::FromSeconds(1)); + SleepFor(MonoDelta::FromMilliseconds(poll_backoff_ms)); + poll_backoff_ms = std::min(2 * poll_backoff_ms, 1000); } while (MonoTime::Now() < deadline); if (!s.ok()) {
