-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve the floating point parser in dec2flt. #107007
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon. Please see the contribution instructions for more information. |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
let e = self[4]; | ||
let f = self[5]; | ||
let g = self[6]; | ||
let h = self[7]; |
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.
suggestion: maybe use one of the unstable methods to get an array without needing to write this all out?
Maybe something like
let first_8 = self.split_array_ref().0;
u64::from_le_bytes(*first_8)
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.
Well, I've already written it all out. The suggested code does produce the desired assembly while being a bit shorter,
but I otherwise don't see the need to change anything. How likely is stabilisation of this method?
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.
Something like what @scottmcm suggests seems more readable here. You can also do something like u64::from_le_bytes(self[..8].try_into().unwrap())
which probably works equally well and should be stable. (But we should confirm against generated code).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
r? t-libs |
Failed to set assignee to
|
r? libs |
This comment has been minimized.
This comment has been minimized.
@Mark-Simulacrum I've made some changes corresponding to your comments.
I've analyzed the changes using godbolt. |
@rustbot ready |
Please squash away the fixup commits, r=me with that done. |
afce93c
to
4bded37
Compare
* Remove all remaining traces of unsafe. * Put `parse_8digits` inside a loop. * Rework parsing of inf/NaN values.
4bded37
to
0f96c71
Compare
@Mark-Simulacrum Commits are squashed, and the merge commit has been removed to comply with the No-Merge policy. |
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (a732883): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
|
Greetings everyone,
I've benn studying the rust floating point parser recently and made the following tweaks:
unsafe
. The parser is now 100% safe Rust.On my system, the changes result in performance improvements for some input values.