Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/timer: introduce steady timer #4060

Merged
merged 2 commits into from Jan 12, 2019
Merged

Conversation

BusyJay
Copy link
Member

@BusyJay BusyJay commented Jan 11, 2019

Steady timer is used to create futures that is notified after a given
duration. It's called steady because it won't be affected by the time
adjustment. This is important for raftstore as the lease mechanism is
based on a steady time.

Steady timer is used to create futures that is notified after a given
duration. It's called steady because it won't be affected by the time
adjustment. This is important for raftstore as the lease mechanism is
based on a steady time.

Signed-off-by: Jay Lee <busyjaylee@gmail.com>
@BusyJay BusyJay added priority/critical Priority: Critical component/util Component: tikv::util labels Jan 11, 2019
let clock = SteadyClock::default();
let clock_ = clock.clone();
Builder::new()
.name(thd_name!("steady timer"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to steady-timer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it can also take time-monitor thread's job checks if time jumps back, but it can be left for future work.

}

impl SteadyTimer {
/// Create a delay future that will be notified after the given duration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Create a delay future that will be notified after the given duration.
/// Creates a delay future that will be notified after the given duration.


impl SteadyTimer {
/// Create a delay future that will be notified after the given duration.
pub fn delay(&self, dur: Duration) -> Delay {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do every leader need to create a Delay?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@overvenus
Copy link
Member

Why not keep the old style of lease renewal that renew lease by propoals?

@BusyJay
Copy link
Member Author

BusyJay commented Jan 11, 2019

It's for tick scheduling instead of lease.

Signed-off-by: Jay Lee <busyjaylee@gmail.com>
Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Connor1996 Connor1996 added the status/LGT2 Status: PR - There are already 2 approvals label Jan 12, 2019
@BusyJay
Copy link
Member Author

BusyJay commented Jan 12, 2019

/run-integration-tests

@BusyJay BusyJay merged commit 404e61d into tikv:master Jan 12, 2019
@BusyJay BusyJay deleted the introduce-steady-timer branch January 12, 2019 06:10
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Steady timer is used to create futures that is notified after a given
duration. It's called steady because it won't be affected by the time
adjustment. This is important for raftstore as the lease mechanism is
based on a steady time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/util Component: tikv::util priority/critical Priority: Critical status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants