-
-
Notifications
You must be signed in to change notification settings - Fork 31
Perf: Borrow Ut1Provider, O(log n) UT1 offset lookup, and faster EOP parsing
#419
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
Conversation
- Change Epoch::{to_ut1,to_ut1_duration,ut1_offset} to take &Ut1Provider.
- Add Ut1Provider::{iter, as_slice} + IntoIterator for &Ut1Provider.
- Sort records once in from_eop_data; use partition_point (binary search) with fast-path.
- Remove Vec clones/allocs on hot paths → large UT1 conversion speedup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @FusRoman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the performance and usability of UT1 conversions by transitioning to borrowed Ut1Provider instances, optimizing the UT1 offset lookup to logarithmic time, and improving the efficiency of EOP data parsing. It also introduces new ergonomic iteration helpers for better data access.
Highlights
- Borrowing Ut1Provider: The
Ut1Provideris now passed by reference (&Ut1Provider) instead of by value in UT1 conversion functions (from_ut1_duration,to_ut1_duration,to_ut1). This change eliminates largeVecclones on hot paths, significantly reducing overhead. - Optimized UT1 Offset Lookup: The
ut1_offsetlookup has been optimized from a linear scan to anO(log n)operation usingslice::partition_point. A fast-path is also included for queries that are at or after the latest record, further improving performance for common scenarios. - Efficient EOP Data Parsing: The
Ut1Provider::from_eop_dataparser has been refactored to be single-pass, avoid per-line allocations, and conditionally sort the data only if it's detected as out of order. This makes EOP data parsing much more efficient. - Ergonomic Iteration Helpers: New ergonomic helpers (
iter,as_slice, andIntoIterator for &Ut1Provider) have been added toUt1Provider, providing zero-copy iteration and direct slice access to the underlying data.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #419 +/- ##
=========================================
Coverage ? 82.67%
=========================================
Files ? 24
Lines ? 3567
Branches ? 0
=========================================
Hits ? 2949
Misses ? 618
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This is an excellent pull request that brings significant performance improvements to UT1 conversions. The change to borrow Ut1Provider instead of moving it is a great optimization, and the breaking change is well-documented. The new O(log n) lookup in ut1_offset and the single-pass EOP parser are impressive. The code is clean and the new iterator helpers improve the API's ergonomics. I have a couple of minor suggestions to further improve the robustness and conciseness of the EOP parser.
ChristopherRabotin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent, thank you!
Could you implement one of the recommendations by Gemini , and also change the version in the Cargo.toml to 4.2.0? That's just to prevent accidentally releasing this minor breaking change as the next 4.1.x version.
Thank you
|
Thanks @FusRoman! |
Summary
This PR reduces the overhead of UT1 conversions by:
Ut1Providerinstead of moving it (no more largeVecclones on hot paths).Epoch::ut1_offsetwith anO(log n)lookup usingslice::partition_point, plus a fast-path when the query epoch is ≥ the last record.Ut1Provider::from_eop_data) single-pass with no per-line allocation and a conditional sort (only sort if input is detected out of order).Ut1Provider(iter,as_slice, andIntoIterator for &Ut1Provider).These changes eliminate unnecessary cloning, reduce allocations, and make UT1 offset queries scale with the number of records.
Breaking change & Migration
This PR introduces a small breaking change: UT1 conversion functions now take a
borrowed provider (
&Ut1Provider) instead of owning it. The migration is aone-liner at each call site.
What changed
close #418