-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: Add slow log for peer and store msg #16605
Conversation
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
@@ -710,12 +716,20 @@ where | |||
} | |||
} | |||
self.on_loop_finished(); | |||
let elapsed = timer.saturating_elapsed(); | |||
slow_log!( |
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.
Using slow_log
is a better choice ? Why not use metrics
?
The default threshold for slow logging is 1s
, which is too long to output slow PeerMsg
.
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.
We have to get the duration for each message if using metrics, which may have some overhead in the hot path.
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.
Let me change the slow threshold for this
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.
The output of distribution ought to be something like this [x, y, z, ...,], maybe we can wrap it and implements a fmt to make it read friendly?
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.
How about adding to metrics if an event exceeds 100ms?
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.
It already has been observed in the below metric
@@ -619,7 +620,12 @@ where | |||
pub fn handle_msgs(&mut self, msgs: &mut Vec<PeerMsg<EK>>) { | |||
let timer = TiInstant::now_coarse(); | |||
let count = msgs.len(); | |||
let mut distribution = hash_map_with_capacity(std::mem::variant_count::<PeerMsg<EK>>()); |
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.
How about putting it to PollContext
? So that we can save frequent hashmap creation.
Also it could be an fixed size array as variant_count::<PeerMsg>
is a constant number.
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.
Using a fixed size array instead, as it's should be allocated on stack, I don't put it in PollContext
pub fn discriminant(&self) -> u8 { | ||
unsafe { *(self as *const Self as *const u8) } | ||
} |
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.
Could you add some comments about how it works?
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.
PTAL again
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
@@ -710,12 +716,20 @@ where | |||
} | |||
} | |||
self.on_loop_finished(); | |||
let elapsed = timer.saturating_elapsed(); | |||
slow_log!( |
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.
How about adding to metrics if an event exceeds 100ms?
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
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.
Rest LGTM
/merge |
@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: aaba689
|
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
/merge |
@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 2398fee
|
ref tikv#16600 Add slow log for peer and store msg Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> Signed-off-by: dbsid <chenhuansheng@pingcap.com>
ref tikv#16600 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
ref #16600 Add slow log for peer and store msg Signed-off-by: Connor <zbk602423539@gmail.com> Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Connor <zbk602423539@gmail.com> Co-authored-by: Connor1996 <zbk602423539@gmail.com>
In response to a cherrypick label: new pull request created to branch |
ref tikv#16600 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ref #16600 Add slow log for peer and store msg Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io> Signed-off-by: Qi Xu <tonyxuqqi@outlook.com> Co-authored-by: Connor <zbk602423539@gmail.com> Co-authored-by: Qi Xu <tonyxuqqi@outlook.com> Co-authored-by: tonyxuqqi <tonyxuqi@outlook.com>
In response to a cherrypick label: new pull request could not be created: failed to create pull request against tikv/tikv#release-7.5 from head ti-chi-bot:cherry-pick-16605-to-release-7.5: the GitHub API request returns a 403 error: {"message":"You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID 98EE:21F144:4FEBA32:80A6538:6639C0F0 and timestamp 2024-05-07 05:49:36 UTC.","documentation_url":"https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits"} |
ref tikv#16600 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
/cherry-pick release-7.5 |
@wuhuizuo: new pull request created to branch In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
ref tikv#16600 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ref #16600 Add slow log for peer and store msg Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io> Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Connor <zbk602423539@gmail.com> Co-authored-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
What is changed and how it works?
Issue Number: Ref #16600
What's Changed:
Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note