-
Notifications
You must be signed in to change notification settings - Fork 664
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
feat: delay detector #3126
feat: delay detector #3126
Conversation
|
||
impl<'a> Drop for DelayDetector<'a> { | ||
fn drop(&mut self) { | ||
let elapsed = Instant::now() - self.started; |
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 elapsed = Instant::now() - self.started; | |
let elapsed = self.started.elapsed(); |
snapshots: Vec<((String, String), Duration)>, | ||
last_snapshot: Option<(String, Instant)>, |
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.
Consider having structs with named fields as (String, String)
is very hard to reason about.
self.snapshot("end"); | ||
} | ||
self.snapshots.sort_by(|a, b| b.1.cmp(&a.1)); | ||
for ((s1, s2), duration) in self.snapshots.drain(..) { |
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 do we need to drain here?
for ((s1, s2), duration) in self.snapshots.drain(..) { | |
for ((s1, s2), duration) in &self.snapshots { |
impl<'a> Drop for DelayDetector<'a> { | ||
fn drop(&mut self) { | ||
let elapsed = Instant::now() - self.started; | ||
if elapsed > Duration::from_millis(50) && elapsed <= Duration::from_millis(500) { |
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.
To avoid typo-bugs, I suggest we swap the if
statements, so we can use else
branch.
Codecov Report
@@ Coverage Diff @@
## master #3126 +/- ##
=======================================
Coverage 87.23% 87.23%
=======================================
Files 212 212
Lines 41377 41377
=======================================
Hits 36096 36096
Misses 5281 5281 Continue to review full report at Codecov.
|
A delay detector that logs information when it detects that the node has spent too much time in some function. Fixes #3115.
Test plan
Manual test with a real node.