Skip to content

Conversation

@mladedav
Copy link
Contributor

Motivation

The timings measurements were done naively in a way where they added busy time in on_exit and idle time in `on_enter. This works only if the spans are not entered multiple times. For example if a span is:

entered
wait 1 second
entered
exited
exited

The timing would be about 1 second of idle time and no busy time.

Solution

Count the relative number of enters and exits and only increment the timers on top-level enters and exits.

@mladedav mladedav requested review from a team, davidbarsky and hawkw as code owners April 20, 2024 19:35
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

yup, this is what we do in tokio-console, so it makes sense to do it here as well! thanks!

@davidbarsky davidbarsky enabled auto-merge (squash) May 25, 2024 18:07
joshka added a commit to joshka/tracing that referenced this pull request Jul 23, 2024
This commit refactors the `Timings` struct to use `Duration` instead of
`u64` to store the idle and busy times of a span, and moves the logic to
update the timings to the `Timings` struct itself. This commit also
introduces a `display` method to the `Timings` struct that returns the
idle and busy times as `HumanReadableDuration` instances (renamed from
`TimingDisplay`).

Replaces: tokio-rs#2944
joshka added a commit to joshka/tracing that referenced this pull request Jul 23, 2024
This commit refactors the `Timings` struct to use `Duration` instead of
`u64` to store the idle and busy times of a span, and moves the logic to
update the timings to the `Timings` struct itself. This commit also
introduces a `display` method to the `Timings` struct that returns the
idle and busy times as `HumanReadableDuration` instances (renamed from
`TimingDisplay`).

Replaces: tokio-rs#2944
@joshka
Copy link
Contributor

joshka commented Jul 23, 2024

I made the timings a little better in #3038 with an eye towards #2946

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.

4 participants