-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Explain why inlining default ToString impl #74852
Conversation
Can I have a perf run, @Mark-Simulacrum ? |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 682726ecab5eb6e0c7b6f4cf5698360fb9fb3300 with merge afd3e8ab7e3e1c925fc3893aab125617395808c8... |
☀️ Try build successful - checks-actions, checks-azure |
Queued afd3e8ab7e3e1c925fc3893aab125617395808c8 with parent 9be8ffc, future comparison URL. |
Finished benchmarking try commit (afd3e8ab7e3e1c925fc3893aab125617395808c8): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
682726e
to
7683f68
Compare
The number is ... different than local perf.
I will try to perf with non-incremental and compare. |
I tried 2 approaches with master commit 1f5d69d:
The locally perf result is here: results.db.tar.gz. The perf result is complicated, most are regressions. But I think it is better to be decided by perf experts. In the case removing inline attribute is unaccepted, I would like to add a comment in the code to explain why. |
I looked at the results, they are clearly regressions. I don't think comments are necessary, because it's not that surprising that marking a hot function as inline would improve performance, and doing the opposite would hurt performance. But if you really want to add comments I won't object. |
7683f68
to
b91de8c
Compare
Updated PR description. |
library/alloc/src/string.rs
Outdated
@@ -2196,6 +2196,9 @@ pub trait ToString { | |||
/// since `fmt::Write for String` never returns an error itself. | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl<T: fmt::Display + ?Sized> ToString for T { | |||
// The general guide line is to not inline generic functions. However, |
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.
s/guide line/guideline/
Is that really a guideline? I'm sure I've seen many generic functions marked with inline
.
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.
The guideline is documented here: https://forge.rust-lang.org/libs/maintaining-std.html#is-that-inline-right .
Or I may infer it wrong.
r=me once the typo is fixed. |
b91de8c
to
27e1b06
Compare
@bors r+ |
📌 Commit 27e1b06 has been approved by |
@bors rollup=always |
⌛ Testing commit 27e1b06 with merge 78c154293cdf2aafd42d7b65ecaafb689e996d1c... |
💔 Test failed - checks-actions |
Spurious error
|
@bors r+ |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 27e1b06 has been approved by |
…arth Rollup of 10 pull requests Successful merges: - rust-lang#74742 (Remove links to rejected errata 4406 for RFC 4291) - rust-lang#74819 (Point towards `format_spec`; it is in other direction) - rust-lang#74852 (Explain why inlining default ToString impl) - rust-lang#74869 (Make closures and generators a must use types) - rust-lang#74873 (symbol mangling: use ty::print::Print for consts) - rust-lang#74902 (Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions) - rust-lang#74904 (Fix some typos in src/librustdoc/clean/auto_trait.rs) - rust-lang#74910 (fence docs: fix example Mutex) - rust-lang#74912 (Fix broken link in unstable book `plugin`) - rust-lang#74927 (Change the target data layout to specify more values) Failed merges: r? @ghost
Trying to remove inline attribute from default ToString impl causes regression.
Perf result at #74852 (comment).