Commit bc6736ac authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

Cut an extra rdtsc in DistributedMutex spin

Summary: [Folly] Cut an extra `rdtsc` in `DistributedMutex` spin.

Reviewed By: aary

Differential Revision: D21947987

fbshipit-source-id: 8d6dca75f5290581a886385cefe994c19af839e1
parent 8cde5e00
...@@ -873,7 +873,8 @@ std::uint64_t publish( ...@@ -873,7 +873,8 @@ std::uint64_t publish(
// passes. So we defer time publishing to the point when the current thread // passes. So we defer time publishing to the point when the current thread
// gets preempted // gets preempted
auto current = time(); auto current = time();
if ((current - previous) >= kScheduledAwaySpinThreshold) { if (previous != decltype(time())::zero() &&
(current - previous) >= kScheduledAwaySpinThreshold) {
shouldPublish = true; shouldPublish = true;
} }
previous = current; previous = current;
...@@ -906,7 +907,7 @@ template <typename Waiter> ...@@ -906,7 +907,7 @@ template <typename Waiter>
bool spin(Waiter& waiter, std::uint32_t& sig, std::uint32_t mode) { bool spin(Waiter& waiter, std::uint32_t& sig, std::uint32_t mode) {
auto spins = std::uint64_t{0}; auto spins = std::uint64_t{0};
auto waitMode = (mode == kCombineUninitialized) ? kCombineWaiting : kWaiting; auto waitMode = (mode == kCombineUninitialized) ? kCombineWaiting : kWaiting;
auto previous = time(); auto previous = decltype(time())::zero();
auto shouldPublish = false; auto shouldPublish = false;
while (true) { while (true) {
auto signal = publish(spins++, shouldPublish, previous, waiter, waitMode); auto signal = publish(spins++, shouldPublish, previous, waiter, waitMode);
......
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