-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Pass all paths to Step::run
at once when using ShouldRun::krate
#96501
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
Hmm, it would probably be good to add tests for the commands the second two commits fix; I have a feeling they'll regress otherwise since the logic is more complicated than before :( |
This comment has been minimized.
This comment has been minimized.
ecfbe8c
to
77e567d
Compare
☔ The latest upstream changes (presumably #96804) made this pull request unmergeable. Please resolve the merge conflicts. |
d371542
to
dc82ac6
Compare
This comment has been minimized.
This comment has been minimized.
So, this is failing because since #96660, the process exits on "no paths matched" rather than panicking. @Mark-Simulacrum how much would you hate me if I wrote a |
OH I'm silly, I can just change it to panic only when @bors author |
@rustbot author |
I'd prefer to avoid extra dependencies, but it sounds like you have an alternative solution regardless. |
@rustbot ready |
Error: The "Ready" shortcut only works on pull requests. Please let |
@rustbot ready |
Ok, this should be ready for review. Like we discussed on our call, PathSet now means "multiple aliases that execute the same task"; Steps that do different things depending on the path, like |
This comment has been minimized.
This comment has been minimized.
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.
r=me with nits resolved
src/bootstrap/builder.rs
Outdated
/// This is used for `StepDescription::krate`, which passes all matching crates at once to | ||
/// `Step::make_run`, rather than calling it many times with a single crate. | ||
/// See `tests.rs` for examples. | ||
fn intersection(&self, needles: &mut Vec<&Path>, module: Option<Kind>) -> PathSet { |
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.
intersection
to me doesn't signal "will remove from the needles" -- I wonder if something like remove_matching here or so might be a better fit? Updating the doc comment to note the removal would also be good, regardless.
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.
Went with intersection_removing_matches
, and added another test for how it modifies needles
.
src/bootstrap/builder.rs
Outdated
/// | ||
/// The reason we return PathSet instead of PathBuf is to allow for aliases that mean the same thing | ||
/// (for now, just `all_krates` and `paths`, but we may want to add an `aliases` function in the future?) | ||
fn pathset_for_paths(&self, paths: &mut Vec<&Path>, kind: Kind) -> Vec<PathSet> { |
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.
Similarly to before I'd prefer to avoid an innocuous name like this removing elements from paths. Not sure I have a good suggestion naming wise though. (If we can't come up with anything, let's keep this name for lack of better options).
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 went with pathset_for_paths_removing_matches
which seems kinda long, but it's only used in one place so I think it's ok to err on the side of being clear.
@@ -2011,8 +2020,8 @@ impl Step for Crate { | |||
} | |||
|
|||
builder.info(&format!( | |||
"{} {} stage{} ({} -> {})", | |||
test_kind, krate, compiler.stage, &compiler.host, target | |||
"{} {:?} stage{} ({} -> {})", |
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.
Hm, is this going to be a really long array in the future when we're not testing one by one?
Today it ends up as Testing ["panic_abort"] stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
(for example) which seems OK though not great. Let's leave it for now though.
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 can, yes:
Testing ["rustc-main", "rustc_data_structures", "rustc_metadata", "rustc_middle", "rustc_trait_selection"] stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
I think I remember you saying we're not going to encourage running all unit tests, though; I think it's ok to have this be kind of long if people do it anyway.
This was surprisingly complicated. The main changes are: 1. Invert the order of iteration in `StepDescription::run`. Previously, it did something like: ```python for path in paths: for (step, should_run) in should_runs: if let Some(set) = should_run.pathset_for_path(path): step.run(builder, set) ``` That worked ok for individual paths, but didn't allow passing more than one path at a time to `Step::run` (since `pathset_for_paths` only had one path available to it). Change it to instead look at the intersection of `paths` and `should_run.paths`: ```python for (step, should_run) in should_runs: if let Some(set) = should_run.pathset_for_paths(paths): step.run(builder, set) ``` 2. Change `pathset_for_path` to take multiple pathsets. The goal is to avoid `x test library/alloc` testing *all* library crates, instead of just alloc. The changes here are similarly subtle, to use the intersection between the paths rather than all paths in `should_run.paths`. I added a test for the behavior to try and make it more clear. Note that we use pathsets instead of just paths to allow for sets with multiple aliases (*cough* `all_krates` *cough*). See the documentation added in the next commit for more detail. 3. Change `StepDescription::run` to explicitly handle 0 paths. Before this was implicitly handled by the `for` loop, which just didn't excute when there were no paths. Now it needs a check, to avoid trying to run all steps (this is a problem for steps that use `default_condition`). 4. Change `RunDescription` to have a list of pathsets, rather than a single path. 5. Remove paths as they're matched This allows checking at the end that no invalid paths are left over. Note that if two steps matched the same path, this will no longer run both; but that's a bug anyway. 6. Handle suite paths separately from regular sets. Running multiple suite paths at once instead of in separate `make_run` invocations is both tricky and not particularly useful. The respective test Steps already handle this by introspecting the original paths. Avoid having to deal with it by moving suite handling into a seperate loop than `PathSet::Set` checks.
@bors r=Mark-Simulacrum rollup=iffy (affects nearly every step in bootstrap) |
📌 Commit fca6dbd has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (21e9336): comparison url. Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
Running steps multiple times defeats the whole point of rust-lang#96501, since lint messages will be duplicated.
Helps with #95503. The goal is to run
cargo test -p rustc_data_structures -p rustc_lint_defs
instead ofcargo test -p rustc_data_structures; cargo test -p rustc_lint_defs
, which should both recompile less and avoid replaying cached warnings.This was surprisingly complicated. The main changes are:
Invert the order of iteration in
StepDescription::run
.Previously, it did something like:
That worked ok for individual paths, but didn't allow passing more than one path at a time to
Step::run
(since
pathset_for_paths
only had one path available to it).Change it to instead look at the intersection of
paths
andshould_run.paths
:Change
pathset_for_path
to take multiple pathsets.The goal is to avoid
x test library/alloc
testing all library crates, instead of just alloc.The changes here are similarly subtle, to use the intersection between the paths rather than all
paths in
should_run.paths
. I added a test for the behavior to try and make it more clear.Note that we use pathsets instead of just paths to allow for sets with multiple aliases (cough
all_krates
cough).See the documentation added in the next commit for more detail.
Change
StepDescription::run
to explicitly handle 0 paths.Before this was implicitly handled by the
for
loop, which just didn't excute when there were no paths.Now it needs a check, to avoid trying to run all steps (this is a problem for steps that use
default_condition
).Change
RunDescription
to have a list of pathsets, rather than a single path.Remove paths as they're matched
This allows checking at the end that no invalid paths are left over.
Note that if two steps matched the same path, this will no longer run both;
but that's a bug anyway.
Handle suite paths separately from regular sets.
Running multiple suite paths at once instead of in separate
make_run
invocations is both tricky and not particularly useful.The respective test Steps already handle this by introspecting the original paths.
Avoid having to deal with it by moving suite handling into a seperate loop than
PathSet::Set
checks.@rustbot label +A-rustbuild