-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
try to downgrade Arc -> Lrc -> Rc -> no-Rc in few places #111014
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
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.
a couple of nits
/// processing sequences. Mostly for sequence-ending possibilities that must be tried but end | ||
/// up failing. | ||
matches: Lrc<Vec<NamedMatch>>, | ||
matches: Rc<Vec<NamedMatch>>, |
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.
could this be Rc<[NamedMatch]>
? would it be better?
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've tried to only change rc stuff. This thing noted as hot
, so changing vec<->slice can potentially shadow other changes. @nnethercote changed this last time, maybe he already tried that and found, that there no gains?
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.
Okay, we can leave those nits for the future.
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.
I just tried it, there are tons of problems.
error[E0277]: the trait bound `[NamedMatch]: Clone` is not satisfied
--> compiler/rustc_expand/src/mbe/macro_parser.rs:275:37
|
275 | let matches = Lrc::make_mut(&mut self.matches);
| ------------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[NamedMatch]`
| |
| required by a bound introduced by this call
|
= help: the trait `Clone` is implemented for `[T; N]`
note: required by a bound in `Lrc::<T>::make_mut`
--> /home/njn/dev/rust1/library/alloc/src/rc.rs:1191:9
|
1191 | impl<T: Clone> Rc<T> {
| ^^^^^ required by this bound in `Rc::<T>::make_mut`
error[E0599]: no method named `push` found for mutable reference `&mut [NamedMatch]` in the current scope
--> compiler/rustc_expand/src/mbe/macro_parser.rs:280:25
|
280 | matches.push(m);
| ^^^^ method not found in `&mut [NamedMatch]`
error[E0277]: the trait bound `[NamedMatch]: Clone` is not satisfied
--> compiler/rustc_expand/src/mbe/macro_parser.rs:591:35
|
591 | Lrc::make_mut(&mut eof_mp.matches);
| ------------- ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[NamedMatch]`
| |
| required by a bound introduced by this call
|
= help: the trait `Clone` is implemented for `[T; N]`
note: required by a bound in `Lrc::<T>::make_mut`
--> /home/njn/dev/rust1/library/alloc/src/rc.rs:1191:9
|
1191 | impl<T: Clone> Rc<T> {
| ^^^^^ required by this bound in `Rc::<T>::make_mut`
error[E0277]: the size for values of type `[NamedMatch]` cannot be known at compilation time
--> compiler/rustc_expand/src/mbe/macro_parser.rs:592:51
|
592 | let matches = Lrc::try_unwrap(eof_mp.matches).unwrap().into_iter();
| --------------- ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `[NamedMatch]`
note: required by a bound in `Lrc::<T>::try_unwrap`
--> /home/njn/dev/rust1/library/alloc/src/rc.rs:360:6
|
360 | impl<T> Rc<T> {
| ^ required by this bound in `Rc::<T>::try_unwrap`
error[E0599]: the method `unwrap` exists for enum `Result<[NamedMatch], Rc<[NamedMatch]>>`, but its trait bounds were not satisfied
--> compiler/rustc_expand/src/mbe/macro_parser.rs:592:67
|
592 | let matches = Lrc::try_unwrap(eof_mp.matches).unwrap().into_iter();
| ^^^^^^ method cannot be called on `Result<[NamedMatch], Rc<[NamedMatch]>>` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`[NamedMatch]: Sized`
error[E0277]: the size for values of type `[NamedMatch]` cannot be known at compilation time
--> compiler/rustc_expand/src/mbe/macro_parser.rs:592:35
|
592 | let matches = Lrc::try_unwrap(eof_mp.matches).unwrap().into_iter();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[NamedMatch]`
note: required by a bound in `Result`
--> /home/njn/dev/rust1/library/core/src/result.rs:502:17
|
502 | pub enum Result<T, E> {
| ^ required by this bound in `Result`
error[E0308]: mismatched types
--> compiler/rustc_expand/src/mbe/macro_parser.rs:625:57
|
625 | self.cur_mps.push(MatcherPos { idx: 0, matches: self.empty_matches.clone() });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Rc<[NamedMatch]>`, found `Rc<Vec<NamedMatch>>`
|
= note: expected struct `Lrc<[NamedMatch]>`
found struct `Lrc<Vec<NamedMatch>>`
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.
Ugh. Clone
requiring Sized
was a mistake :(
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.
Perhaps, but that's not the only problem here.
Rc::make_mut(&mut eof_mp.matches); | ||
let matches = Rc::try_unwrap(eof_mp.matches).unwrap().into_iter(); |
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.
Would it make sense to just
Rc::make_mut(&mut eof_mp.matches); | |
let matches = Rc::try_unwrap(eof_mp.matches).unwrap().into_iter(); | |
let matches = Rc::make_mut(&mut eof_mp.matches).take().into_iter(); |
or even
Rc::make_mut(&mut eof_mp.matches); | |
let matches = Rc::try_unwrap(eof_mp.matches).unwrap().into_iter(); | |
eof_mp.matches.iter().cloned() |
@bors r+ rollup=never |
@klensy: how did you find these? Did you just spot them manually, or did you have some kind of process for finding them? |
Manual process: switched build to parallel = true, walked over Arc - Lrc - Rc (there not so many places with them), an tried to use next rc kind, if it looks easy and don't lead to rewriting more than i want. There more things probably can be rewritten, for example in |
☀️ Test successful - checks-actions |
Finished benchmarking commit (74c4821): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression 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.
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 sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 657.762s -> 654.9s (-0.44%) |
Expecting this be not slower on non-parallel compiler and probably faster on parallel (checked that this PR builds on it).