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

feat: delay detector #3126

Merged
merged 4 commits into from
Aug 11, 2020
Merged

feat: delay detector #3126

merged 4 commits into from
Aug 11, 2020

Conversation

bowenwang1996
Copy link
Collaborator

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.

@gitpod-io
Copy link

gitpod-io bot commented Aug 11, 2020


impl<'a> Drop for DelayDetector<'a> {
fn drop(&mut self) {
let elapsed = Instant::now() - self.started;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let elapsed = Instant::now() - self.started;
let elapsed = self.started.elapsed();

Comment on lines +8 to +9
snapshots: Vec<((String, String), Duration)>,
last_snapshot: Option<(String, Instant)>,
Copy link
Collaborator

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(..) {
Copy link
Collaborator

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?

Suggested change
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) {
Copy link
Collaborator

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
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #3126 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58a0370...94b4824. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Measure time of all the handlers in all actors in adversarial builds, and report delays
3 participants