boinkor-net / governor

A rate-limiting library for Rust (f.k.a. ratelimit_meter)
https://github.com/boinkor-net/governor
MIT License
550 stars 43 forks source link

Use direct nanosecond operations in quanta, bring speed back to baseline #190

Closed antifuchs closed 1 year ago

antifuchs commented 1 year ago

This uses https://github.com/metrics-rs/quanta/pull/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)

antifuchs commented 1 year ago

bors merge

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (78ad701) 97.69% compared to head (9c24837) 97.69%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #190 +/- ## ======================================= Coverage 97.69% 97.69% ======================================= Files 31 31 Lines 2208 2208 ======================================= Hits 2157 2157 Misses 51 51 ``` | [Impacted Files](https://app.codecov.io/gh/antifuchs/governor/pull/190?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andreas+Fuchs) | Coverage Δ | | |---|---|---| | [governor/src/clock/quanta.rs](https://app.codecov.io/gh/antifuchs/governor/pull/190?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andreas+Fuchs#diff-Z292ZXJub3Ivc3JjL2Nsb2NrL3F1YW50YS5ycw==) | `98.52% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

bors[bot] commented 1 year ago

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here. For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.