Skip to content

Commit

Permalink
console_subscriber: remove clock skew warning in start_poll
Browse files Browse the repository at this point in the history
Remove "possible Instant clock skew" message in start_poll. This warning could occur when a task switches threads between 2 polls. Replaced the code to use saturating_duration_since, which clamps the elapsed time to 0, if the starting poll time is less than the scheduled time.

Fixes tokio-rs#433
  • Loading branch information
h33p committed Jun 8, 2023
1 parent ea00694 commit 9b6cb7c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions console-subscriber/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,8 @@ impl<H: RecordDuration> PollStats<H> {
None => return, // Async operations record polls, but not wakes
};

let elapsed = match at.checked_duration_since(scheduled) {
Some(elapsed) => elapsed,
None => {
eprintln!(
"possible Instant clock skew detected: a poll's start timestamp \
was before the wake time/last poll end timestamp\nwake = {:?}\n start = {:?}",
scheduled, at
);
return;
}
};
// `at < scheduled` is possible when a task switches threads between polls.
let elapsed = at.saturating_duration_since(scheduled);

// if we have a scheduled time histogram, add the timestamp
timestamps.scheduled_histogram.record_duration(elapsed);
Expand Down

0 comments on commit 9b6cb7c

Please sign in to comment.