-
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
Remove or document uses of #[rustc_box] in library #108476
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 589cb6e35f32b2da7c206f5cd54aeff261bb2c7b with merge e3337189d45e02992e5cd2be28ad35470f90f10c... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (e3337189d45e02992e5cd2be28ad35470f90f10c): comparison URL. Overall result: ❌ regressions - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never 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.
|
589cb6e
to
34198ee
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 34198eef64f920b0a0c2b72302765972c5586930 with merge 56d7174232da03c5cf3a5e13f90d40c09121fbdf... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (56d7174232da03c5cf3a5e13f90d40c09121fbdf): 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.
CyclesThis benchmark run did not return any relevant results for this metric. |
34198ee
to
5448123
Compare
(#[rustc_box] | ||
Box::new(x)) | ||
.into() | ||
Box::new(x).into() |
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.
In an unoptimized build, T
already needs to be on the stack, so this change shouldn't inhibit any in-place heap initialization.
fn from(array: [T; N]) -> Box<[T]> { | ||
#[rustc_box] | ||
Box::new(array) |
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.
Same as Box::pin
, in an unoptimized build, T
already needs to be on the stack, so this change shouldn't inhibit any in-place heap initialization.
<[T]>::into_vec( | ||
#[rustc_box] | ||
Box::new(s), | ||
) | ||
<[T]>::into_vec(Box::new(s)) |
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.
Same as other cases; in an unoptimized build, T
already needs to be on the stack, so this change shouldn't inhibit any in-place heap initialization.
fn default() -> Self { | ||
#[rustc_box] |
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 "T
is already a function argument" justification doesn't apply here.
But what does matter is that T
is the return value for the T::default()
call. So this use is slightly more exciting than the other cases.
Initially, I was concerned that this might require #[rustc_box]
. But in a totally unoptimized build, you still cannot Box::default
a T
which is more than half your stack size: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e4322542645a0afe6c2644511b838e5c
One possible complaint is that this halves the size of the T
that can be defaulted, because now we have to pass it through two function calls. That is true. But MIR optimizations can also halve the possible size of T
, if T::default()
is inlined into Box::default
. We don't do MIR inlining currently at -Copt-level=0
, but my point is that anyone relying on the size of a T
they can default with this function is already lined up for trouble outside of this PR.
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
This looks fine to me. Thanks for working through it! @bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (64165aa): comparison URL. Overall result: ✅ improvements - 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.
CyclesThis benchmark run did not return any relevant results for this metric. |
r? @thomcc
Only one of these uses is tested for in the rustc-perf benchmark suite. The impact there on compile time is somewhat dramatic, but I am inclined to make this change as a simplification to the library and wait for people to complain if it explodes their compilation time. I think in the absence of data or reports from users about what code paths really matter, if we are optimizing for compilation time, it's hard to argue against using
#[rustc_box]
everywhere we currently callBox::new
.