-
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
Set default move_size_limit
to 4kB for large_assignments
lint on nightly
#115684
Conversation
This comment has been minimized.
This comment has been minimized.
dec3078
to
a7d3667
Compare
large_assignments
lint by default with 4096 byte limitlarge_assignments
lint by default with move_size_limit
= 4096 bytes
This comment has been minimized.
This comment has been minimized.
a7d3667
to
86b195e
Compare
These commits modify compiler targets. |
This comment has been minimized.
This comment has been minimized.
86b195e
to
44b30ce
Compare
large_assignments
lint by default with move_size_limit
= 4096 bytesmove_size_limit
to 4kB for large_assignments
lint on nightly
This comment has been minimized.
This comment has been minimized.
44b30ce
to
84f8c26
Compare
library/core/src/cell.rs
Outdated
pub const fn new(value: T) -> UnsafeCell<T> { | ||
#[allow(large_assignments)] | ||
UnsafeCell { value } | ||
} |
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.
Is this actually reported while compiling libcore? Or is this from a use of Cell::new
with large types?
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.
Good point. It is the latter. Should be fixed now. Unfortunately the diagnostics does not tell from where the move is, so it was a bit tricky to figure out. For the black_box()
case the diagnostic looks like this:
error: moving 65536 bytes
--> /home/martin/src/rust/library/core/src/hint.rs:293:5
|
293 | crate::intrinsics::black_box(dummy)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here
|
= note: The current maximum size is 4096, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
= note: `-D large-assignments` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(large_assignments)]`
error: moving 131072 bytes
--> /home/martin/src/rust/library/core/src/hint.rs:293:5
|
293 | crate::intrinsics::black_box(dummy)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here
|
= note: The current maximum size is 4096, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
error: could not compile `alloc` (bench "collectionsbenches") due to 2 previous errors
I added a task that we should add to the tracking issue that we need to improve diagnostics.
// revisions: attribute option | ||
// [option]compile-flags: -Zmove-size-limit=1000 | ||
// revisions: attribute option nothing | ||
// [option]compile-flags: -Zmove-size-limit=2000 |
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.
Please change this in a separate commit so I can see the changes from the code changes separately from the test changes
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.
oof yea, this is an issue. Maybe we should only emit the lint on items in the local crate. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…=<try> Set default `move_size_limit` to 4kB for `large_assignments` lint on nightly Only enable it by default in the nightly compiler. The limit can be changed on a per-crate basis with: #![feature(large_assignments)] #![move_size_limit = "8192"] or with -Zmove-size-limit=8192 Does the _"enable the lint by default with a 4k threshold"_ step in rust-lang#83518. TODO: - [ ] Figure out how to write a test that tests that the stable compiler still has a default move_size_limit of 0. I suspect it is easy once you know the trick, but I haven't been able to figure out the trick yet. - [ ] I found a bug where the lint is duplicated unnecessarily when generic instantiations are involved. See FIXME in the test. We should file an issue about it so we don't forget it. Or at least write a row in the tracking issue. - [ ] The compiler seems very slow after this change. Might be tricky to fix.. r? `@oli-obk` who is E-mentor.
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
…nightly Only enable it by default in the nightly compiler. The limit can be changed on a per-crate basis with: #![feature(large_assignments)] #![move_size_limit = "8192"] or with -Zmove-size-limit=8192
84f8c26
to
2505a7d
Compare
Just want to make sure I understand: In what way would that help? Here is an example where the lint is duplicated using only items from the local crate: struct NotBox<const N: usize> {
_data: [u8; N],
}
impl<const N: usize> NotBox<N> {
fn new(data: [u8; N]) -> Self {
Self { _data: data } // NOTE: Duplicated here three times: warning: moving 5000/6000/7000 bytes
}
}
fn main() {
let _ = NotBox::new([0u8; 5000]);
let _ = NotBox::new([0u8; 6000]);
let _ = NotBox::new([0u8; 7000]);
}
|
Finished benchmarking commit (9f87deb): 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.
Binary sizeResultsThis 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.
Bootstrap: 630.224s -> 630.254s (0.00%) |
The perf run does not support my claim of the compiler seemed "very slow". I now realized stage1 -> stage2 must be slow simply because I have enabled some debug options for the compiler. So it was a false alarm from me. That said, there is still a noticeable regression in performance, as you can see. |
Mostly because you can't do anything about lints reported in your dependencies. You can't disable lints emitted in generic functions in libcore if they are only emitted there because of something you did locally. Wrt the perf issue, it does look like it's all these new |
Might take a while until this is redo for re-review, so: @rustbot author |
☔ The latest upstream changes (presumably #116054) made this pull request unmergeable. Please resolve the merge conflicts. |
I think we're quite far off from being able to merge this PR, so I will close this PR for now. I plan on re-opening it and resume work on this once the timing is right. See the tracking issue for newly added tasks we probably should do before enabling |
Only enable it by default in the nightly compiler. The limit can be changed on a per-crate basis with:
or with
Does the "enable the lint by default with a 4k threshold" step in #83518.
Tasks for this PR:
Tasks after this PR:
./x test library/alloc
clearly says from where a large move into e.g.black_box()
is made (when 39a42c3 is temporarily reverted)r? @oli-obk who is E-mentor.