-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Faster fmt::Display of 128-bit integers, without unsafe pointer #136594
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
@pascaldekloe: 🔑 Insufficient privileges: not in try users |
Do you have a link to the asm diff? |
☔ The latest upstream changes (presumably #136409) made this pull request unmergeable. Please resolve the merge conflicts. |
|
658adc6
to
3a09315
Compare
This comment has been minimized.
This comment has been minimized.
Constant calculation done with https://gist.github.com/pascaldekloe/df103c17ebf01920958053c76505aedf. |
I don't have any concerns here but the tests need to be fixed of course :) @rustbot author |
Reminder, once the PR becomes ready for a review, use |
3a09315
to
bfb09cf
Compare
This comment has been minimized.
This comment has been minimized.
bfb09cf
to
1ce1b97
Compare
@rustbot ready |
☔ The latest upstream changes (presumably #142133) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Hey, I'm very sorry this PR kept falling off my todo list. I have now had a chance to read through thoroughly and it looks great. Left a few small comments, but with those, a rebase, and a final try job I think this should be good to go.
Any chance you could post local benchmarks as well?
} else { | ||
n.widening_mul(FACTOR).1 >> 62 | ||
}; | ||
// These constant values are computed with the CHOOSE_MULTIPLIER procedure. |
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.
What is CHOOSE_MULTIPLIER
referring to?
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.
It is described in the paper.
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.
Ah, annoyingly the paper can't be searched for "CHOOSE_MULTIPLIER" since it uses a weird underscore. I'm trying to check the algorithm - if d
is 1_0000_0000_0000_0000, what values are prec
and N
?
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.
Maybe I should use the weird underscore in the code too then? 🤔
N is the input argument and prec(ision) is 128-bit.
https://gist.github.com/pascaldekloe/df103c17ebf01920958053c76505aedf#file-main-go-L26
/// | ||
/// Integer division algorithm is based on the following paper: | ||
/// The integer division algorithm is based on the following paper: | ||
/// | ||
/// T. Granlund and P. Montgomery, “Division by Invariant Integers Using Multiplication” | ||
/// in Proc. of the SIGPLAN94 Conference on Programming Language Design and | ||
/// Implementation, 1994, pp. 61–72 |
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.
It seems like the implementation has changed quite a bit - is it still from the paper?
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.
Yes the algorithm is an exact match of the paper now, including the names of each parameter involved.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Faster fmt::Display of 128-bit integers, without unsafe pointer In followup of #135265, hereby the 128-bit part. * Batches per 16 instead of 19 digits * Buffer access as array insteaf of unsafe pointer * Added test coverage for i128 and u128 r? tgross35 ChrisDenton
No problem @tgross35. This is no priority patch. Happy with these feedback loops. Getting to learn the language. Local benchmark will follow in an hour or so... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (f791aa5): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 0.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 754.321s -> 755.157s (0.11%) |
In followup of #135265, hereby the 128-bit part.
r? tgross35 ChrisDenton