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

Clock.delta_as_nanos, a delta that skips conversion to Duration #86

Merged
merged 2 commits into from
May 28, 2023

Conversation

antifuchs
Copy link
Contributor

@antifuchs antifuchs commented May 25, 2023

This change addresses #84.

Relevant Benchmarks

These look great - 2ns on the mac and 7ns on my linux testbed: I think high-frequency usage of the raw quanta functions will benefit a lot from using delta_as_nanos.

macOS (m1 max)

quanta/quanta_raw_delta time:   [16.591 ns 16.620 ns 16.648 ns]
Found 26 outliers among 100 measurements (26.00%)
  6 (6.00%) low severe
  2 (2.00%) low mild
  5 (5.00%) high mild
  13 (13.00%) high severe
quanta/quanta_raw_delta_as_nanos
                        time:   [14.150 ns 14.163 ns 14.176 ns]
Found 12 outliers among 100 measurements (12.00%)
  5 (5.00%) high mild
  7 (7.00%) high severe

Linux (dual Xeon Silver 4114)

quanta/quanta_raw_delta time:   [24.551 ns 24.686 ns 24.841 ns]
Found 11 outliers among 100 measurements (11.00%)
  8 (8.00%) high mild
  3 (3.00%) high severe
quanta/quanta_raw_delta_as_nanos
                        time:   [17.353 ns 17.517 ns 17.704 ns]
Found 12 outliers among 100 measurements (12.00%)
  4 (4.00%) high mild
  8 (8.00%) high severe

This addresses metrics-rs#84 and
should results in a benchmark that's 2ns faster (on a m1 max macOS
machine) than the corresponding Duration-converting benchmark.
Copy link
Member

@tobz tobz left a comment

Choose a reason for hiding this comment

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

Overall, looks good to me. Just some tweaks to tighten up the wording in the doc comments.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@antifuchs
Copy link
Contributor Author

Updated, thank you!

@antifuchs antifuchs requested a review from tobz May 26, 2023 19:41
@tobz tobz merged commit 894ebdf into metrics-rs:main May 28, 2023
@tobz
Copy link
Member

tobz commented May 28, 2023

Released as [email protected].

Thanks again for your contribution. ❤️

@antifuchs
Copy link
Contributor Author

Fantastic, thank you! This brings performance back to the baseline I was expecting to see! (:

@antifuchs antifuchs deleted the delta_as_nanos branch May 28, 2023 22:48
bors bot added a commit to boinkor-net/governor that referenced this pull request May 28, 2023
190: Use direct nanosecond operations in quanta, bring speed back to baseline r=antifuchs a=antifuchs

This uses metrics-rs/quanta#86 to avoid roundtripping nanosecond counts through Duration, which does a bunch of integer math on construction and deconstruction, which we don't even need (unless we exceed the 270 years of governor's useful operational uptime).

In benchmarks, this brings speeds back to the baseline pre-quanta-0.11 (see #175)

Co-authored-by: Andreas Fuchs <[email protected]>
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.

2 participants