Skip to content
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

optimize tidy check on src/tools/tidy/src/issues.txt #123339

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

onur-ozkan
Copy link
Member

@onur-ozkan onur-ozkan commented Apr 1, 2024

This change applies to the following:

  • Handles is_sorted in the first iteration without needing a second.
  • Fixes line sorting on --bless.
  • Reads issues.txt as str rather than making it part of the source code.

Fixes #123002

@rustbot
Copy link
Collaborator

rustbot commented Apr 1, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 1, 2024
Comment on lines -189 to -197
if bless && !remaining_issue_names.is_empty() {
let issues_txt_header = r#"
/*
============================================================
⚠️⚠️⚠️NOTHING SHOULD EVER BE ADDED TO THIS LIST⚠️⚠️⚠️
============================================================
*/
[
"#;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I genuinely do not think we should remove this.

Copy link
Member Author

@onur-ozkan onur-ozkan Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the concern but I'm not sure how this will help. If someone adds a line to the end of this file, reviewers won't be able to see this header anyway.

How about hardcoding the current length and checking if it's not equal to the lines in this file? This way we will continuously be aware of it without relying on reviewers mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not for informing a reviewer.

const ISSUES_ENTRY_LIMIT is already checked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not for informing a reviewer.

It has to. When someone accidentally adds a line, reviewer should be aware of this information.

const ISSUES_ENTRY_LIMIT is already checked.

What I mean is this:

diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 5b3b948d4a1..86e72823036 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -100,6 +100,9 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
 }

 pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
+    // This can be decreased but can never be increased.
+    const EXPECTED_LINE_COUNT: usize = 4372;
+
     let path = &root_path.join("tests");
     check_entries(&path, bad);

@@ -120,6 +123,8 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
         })
         .collect();

+    assert_eq!(EXPECTED_LINE_COUNT, allowed_issue_names.len(), "If you have added new lines to issues.txt, please revert them; otherwise, decrease the EXPECTED_LINE_COUNT.");
+
     if !is_sorted && !bless {
         tidy_error!(
             bad,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has to. When someone accidentally adds a line, reviewer should be aware of this information.

The vast majority of the information in the Rust repository is addressed directly at the contributor, and only incidentally useful to a reviewer, so I disagree with this "has to" assertion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyways, the reason there's nothing exactingly doing assert_eq! is because there was a request in the original PR to make this list --blessable, to reduce annoyance. So I implemented that. Making sure this number --blesses only up and not down would require a lot of fiddly logic, I would think? And it would also invite merge conflicts on the value a lot.

@bors
Copy link
Contributor

bors commented Apr 3, 2024

☔ The latest upstream changes (presumably #123429) made this pull request unmergeable. Please resolve the merge conflicts.

@Mark-Simulacrum
Copy link
Member

It seems like we ought to be able to move to using include_str!() and skip a fixed header before iterating through the lines, without making any other, unrelated changes to the behavior (e.g., adding an assertion about a specific number).

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 5, 2024
@onur-ozkan
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 5, 2024
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a 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 fixed

let mut is_sorted = true;
let allowed_issue_names: BTreeSet<_> = include_str!("issues.txt")
.lines()
.skip(issues_txt_header.lines().count()) // skip the header lines
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a strip_prefix(issues_txt_header), so that we assert that the contents of that block have not changed.

is_sorted = false;
}

prev_line = line.clone();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, there's some needless copying going on here AFAICT. BTreeSet<&'static str> should be fine (and should be what you get from iterating lines).

@onur-ozkan
Copy link
Member Author

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Apr 5, 2024

📌 Commit 49c10e4 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 5, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 6, 2024
…Mark-Simulacrum

optimize tidy check on `src/tools/tidy/src/issues.txt`

This change applies to the following:

- Handles `is_sorted` in the first iteration without needing a second.
- Fixes line sorting on `--bless`.
- Reads `issues.txt` as str rather than making it part of the source code.

Fixes rust-lang#123002
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 6, 2024
…Mark-Simulacrum

optimize tidy check on `src/tools/tidy/src/issues.txt`

This change applies to the following:

- Handles `is_sorted` in the first iteration without needing a second.
- Fixes line sorting on `--bless`.
- Reads `issues.txt` as str rather than making it part of the source code.

Fixes rust-lang#123002
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock)
 - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`)
 - rust-lang#123321 (Bump dependencies)
 - rust-lang#123339 (optimize tidy check on `src/tools/tidy/src/issues.txt`)
 - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs)
 - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 6, 2024
…Mark-Simulacrum

optimize tidy check on `src/tools/tidy/src/issues.txt`

This change applies to the following:

- Handles `is_sorted` in the first iteration without needing a second.
- Fixes line sorting on `--bless`.
- Reads `issues.txt` as str rather than making it part of the source code.

Fixes rust-lang#123002
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#114788 (impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock)
 - rust-lang#122291 (Stabilize `const_caller_location` and `const_location_fields`)
 - rust-lang#123339 (optimize tidy check on `src/tools/tidy/src/issues.txt`)
 - rust-lang#123357 (CI: Redirect stderr to stdout to order GHA logs)
 - rust-lang#123504 (bootstrap: split cargo-miri test into separate Step)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

@bors r-
#123544 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 6, 2024
This change applies to the following:

- Handles `is_sorted` in the first iteration without needing a second.
- Fixes line sorting on `--bless`.
- Reads `issues.txt` as str rather than making it part of the source code.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan
Copy link
Member Author

@bors r=Mark-Simulacrum (corrected the usage of / in Windows paths.)

@bors
Copy link
Contributor

bors commented Apr 6, 2024

📌 Commit b0f2e60 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 6, 2024
@bors
Copy link
Contributor

bors commented Apr 6, 2024

⌛ Testing commit b0f2e60 with merge 773fb88...

@bors
Copy link
Contributor

bors commented Apr 6, 2024

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 773fb88 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 6, 2024
@bors bors merged commit 773fb88 into rust-lang:master Apr 6, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 6, 2024
@onur-ozkan onur-ozkan deleted the optimize-tidy-check branch April 6, 2024 17:14
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (773fb88): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 666.761s -> 668.041s (0.19%)
Artifact size: 318.27 MiB -> 318.25 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tidy compiles very slowly
7 participants