You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by la...@apache.org on 2021/10/18 10:07:05 UTC

[kudu] branch master updated: [ntp] improve two arithmetic operator

This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 5588962  [ntp] improve two arithmetic operator
5588962 is described below

commit 5588962fb4e6acb54c1e5cab5edce4aa543a73a7
Author: shenxingwuying <sh...@gmail.com>
AuthorDate: Thu Sep 16 16:07:16 2021 +0800

    [ntp] improve two arithmetic operator
    
    use shift operator instead multiply/divided, compiler
    maybe optimize it (gcc/g++ can do it).
    
    Change-Id: I5775d9206e82dfd1febd98219dbde1bb69a44240
    Reviewed-on: http://gerrit.cloudera.org:8080/17852
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Yingchun Lai <ac...@gmail.com>
---
 src/kudu/clock/hybrid_clock.cc | 2 +-
 src/kudu/clock/system_ntp.cc   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/kudu/clock/hybrid_clock.cc b/src/kudu/clock/hybrid_clock.cc
index e88744a..d52c7fb 100644
--- a/src/kudu/clock/hybrid_clock.cc
+++ b/src/kudu/clock/hybrid_clock.cc
@@ -584,7 +584,7 @@ Status HybridClock::InitWithTimeSource(TimeSource time_source) {
       need_log = false;
     }
     SleepFor(MonoDelta::FromMilliseconds(poll_backoff_ms));
-    poll_backoff_ms = std::min(2 * poll_backoff_ms, 1000);
+    poll_backoff_ms = std::min(poll_backoff_ms << 1, 1000);
   } while (MonoTime::Now() < deadline);
 
   if (!s.ok()) {
diff --git a/src/kudu/clock/system_ntp.cc b/src/kudu/clock/system_ntp.cc
index e000c85..0994573 100644
--- a/src/kudu/clock/system_ntp.cc
+++ b/src/kudu/clock/system_ntp.cc
@@ -126,7 +126,7 @@ Status SystemNtp::Init() {
   // The unit of the reported tolerance is ppm with 16-bit fractional part:
   // 65536 is 1 ppm (see http://man7.org/linux/man-pages/man3/ntp_adjtime.3.html
   // for details).
-  skew_ppm_ = t.tolerance / 65536;
+  skew_ppm_ = t.tolerance >> 16;
   VLOG(1) << "ntp_adjtime(): tolerance is " << t.tolerance;
 
   return Status::OK();