Commit b5404457 by Derek Mauro Committed by Copybara-Service

KernelTimeout optimization: Use absl::GetCurrentTimeNanos()

instead of absl::ToUnixNanos(absl::Now());

PiperOrigin-RevId: 509829866
Change-Id: Ib34362762304ad6eb7980a1227d717069b84f656
parent 8aa88cd1
...@@ -89,7 +89,7 @@ int64_t KernelTimeout::MakeAbsNanos() const { ...@@ -89,7 +89,7 @@ int64_t KernelTimeout::MakeAbsNanos() const {
int64_t nanos = RawNanos(); int64_t nanos = RawNanos();
if (is_relative_timeout()) { if (is_relative_timeout()) {
int64_t now = ToUnixNanos(absl::Now()); int64_t now = absl::GetCurrentTimeNanos();
if (nanos > kMaxNanos - now) { if (nanos > kMaxNanos - now) {
// Overflow. // Overflow.
nanos = kMaxNanos; nanos = kMaxNanos;
...@@ -118,7 +118,7 @@ struct timespec KernelTimeout::MakeRelativeTimespec() const { ...@@ -118,7 +118,7 @@ struct timespec KernelTimeout::MakeRelativeTimespec() const {
} }
int64_t nanos = RawNanos(); int64_t nanos = RawNanos();
int64_t now = ToUnixNanos(absl::Now()); int64_t now = absl::GetCurrentTimeNanos();
if (now > nanos) { if (now > nanos) {
// Convert past values to 0 to be safe. // Convert past values to 0 to be safe.
nanos = 0; nanos = 0;
...@@ -146,7 +146,7 @@ KernelTimeout::DWord KernelTimeout::InMillisecondsFromNow() const { ...@@ -146,7 +146,7 @@ KernelTimeout::DWord KernelTimeout::InMillisecondsFromNow() const {
return static_cast<DWord>(ms); return static_cast<DWord>(ms);
} }
int64_t now = ToUnixNanos(absl::Now()); int64_t now = absl::GetCurrentTimeNanos();
if (nanos >= now) { if (nanos >= now) {
// Round up so that now + ms_from_now >= nanos. // Round up so that now + ms_from_now >= nanos.
constexpr uint64_t kMaxValueNanos = constexpr uint64_t kMaxValueNanos =
......
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