-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
raftstore: cache term #1154
raftstore: cache term #1154
Conversation
@@ -160,6 +163,16 @@ impl PeerStorage { | |||
raft_state | |||
} | |||
}; | |||
let last_term = match raft_state.get_last_index() { | |||
0 => 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any test to cover 0 and RAFT_INIT_LOG_INDEX ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing cases cover it already.
@@ -279,6 +293,9 @@ impl PeerStorage { | |||
return Ok(self.truncated_term()); | |||
} | |||
try!(self.check_range(idx, idx + 1)); | |||
if self.truncated_term() == self.last_term || idx == self.last_index() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why check truncated_term() here?
LGTM |
PTAL |
LGTM |
1 similar comment
LGTM |
* Configurable lowres tso update interval Signed-off-by: Ari Ekmekji <aekmekji@gmail.com> * Review comments Signed-off-by: Ari Ekmekji <aekmekji@gmail.com> * Comment for exported function Signed-off-by: Ari Ekmekji <aekmekji@gmail.com> --------- Signed-off-by: Ari Ekmekji <aekmekji@gmail.com> Co-authored-by: Ari Ekmekji <ari.ekmekji@airbnb.com>
Currently almost every call to term will invoke
rocksdb::get
. This pr reduce the call times by caching the term of last_index. Iftruncated_term
is equal tolast_term
, then every entry between truncated_index and last_index should have the same term.