-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add shortcut for Grisu3 algorithm. #110389
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
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
@mazong1123: 🔑 Insufficient privileges: not in try users |
This comment has been minimized.
This comment has been minimized.
@simulacrum looks like I don't have permission to request a perf benchmark. As this change is perf related, is there any chance to grant me the right permission? |
Here is the benchmark data for .NET with the shortcut. Doing similar benchmark tests in rust would be great. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 9968365655939cad46b5ec70ff3f1d201d150ba8 with merge 09a6ce7b9a3eb5f779b7015c5138e9b8c54ff00c... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (09a6ce7b9a3eb5f779b7015c5138e9b8c54ff00c): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
This can be expected since rustc perf is mostly related to the performance of the compiler. You should consider writing your own benchmarks to see the performance changes. |
Appears current rust benchmark for Grisu3 does not have numbers to cover the fallback cases. I've added 3 benchmarks: Before changebenchmarks: After changebenchmarks:
|
Bumping. Anyone has a chance to review? |
@rustbot review |
@Mark-Simulacrum if you have time :) |
Please be aware the reviews can take 7-14 days; the reviewer pool is predominantly composed of volunteers. I will get to this fairly soon, likely today or tomorrow, but rest assured that as long as it's in S-waiting-on-review it's in my queue. |
r=me with nit fixed |
173069e
to
705f7a5
Compare
Check requested digit length and the fractional or integral parts of the number. Falls back earlier without trying the Grisu algorithm if the specific condition meets. Fix rust-lang#110129
705f7a5
to
b0a85d6
Compare
Thanks @Mark-Simulacrum . Updated accordingly. Commits are squashed as well. |
@bors r=Mark-Simulacrum |
☀️ Test successful - checks-actions |
Finished benchmarking commit (91b61a4): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
While Grisu3 is way more faster for most numbers compare to Dragon4, the fall back to Dragon4 procedure for certain numbers could cause some performance regressions compare to use Dragon4 directly. Mitigating the regression caused by falling back is important for a largely used core library.
In Grisu3 algorithm implementation, there's a shortcut to jump out earlier when the fractional or integrals cannot meet the requirement of requested digits. This could significantly improve the performance of converting floating number to string as it falls back even without starting trying the algorithm.
The original idea is from the .NET implementation and the code was originally added in this PR. This shortcut has been shipped long time ago and has been proved working.
Fix #110129