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

Fix regression in the MIR lowering of or-patterns #127028

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

Nadrieril
Copy link
Member

@Nadrieril Nadrieril commented Jun 27, 2024

In #126553 I made a silly indexing mistake and regressed the MIR lowering of or-patterns. This fixes it.

r? @compiler-errors because I'd like this to be merged quickly 🙏

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 27, 2024
Comment on lines +1414 to +1416
if expand_until != 0 {
expand_until = i + 1;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The idea was "include as many candidates until we find a candidate where we should stop" but I forgot to keep incrementing the index so I cut off candidates I should have included. As you can see in the test file, this created unnecessary extra SwitchInts.

@Nadrieril Nadrieril changed the title Fix expansion of or-patterns Fix regression in the codegen of or-patterns Jun 27, 2024
@Nadrieril Nadrieril changed the title Fix regression in the codegen of or-patterns Fix regression in the MOR lowering of or-patterns Jun 27, 2024
@Nadrieril Nadrieril changed the title Fix regression in the MOR lowering of or-patterns Fix regression in the MIR lowering of or-patterns Jun 27, 2024
@matthewjasper
Copy link
Contributor

r? @matthewjasper
@bors r+

@bors
Copy link
Contributor

bors commented Jul 9, 2024

📌 Commit 834f043 has been approved by matthewjasper

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 Jul 9, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 9, 2024
…matthewjasper

Fix regression in the MIR lowering of or-patterns

In rust-lang#126553 I made a silly indexing mistake and regressed the MIR lowering of or-patterns. This fixes it.

r? `@compiler-errors` because I'd like this to be merged quickly 🙏
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 9, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127028 (Fix regression in the MIR lowering of or-patterns)
 - rust-lang#127091 (impl FusedIterator and a size hint for the error sources iter)
 - rust-lang#127358 (Automatically taint when reporting errors from ItemCtxt)
 - rust-lang#127382 (Use verbose style when suggesting changing `const` with `let`)
 - rust-lang#127397 (fix interleaved output in the default panic hook when multiple threads panic simultaneously)
 - rust-lang#127484 (`#[doc(alias)]`'s doc: say that ASCII spaces are allowed)
 - rust-lang#127496 (Update `f16`/`f128` FIXMEs that needed `(NEG_)INFINITY`)
 - rust-lang#127508 (small search graph refactor)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Jul 9, 2024

⌛ Testing commit 834f043 with merge 9dcaa7f...

@bors
Copy link
Contributor

bors commented Jul 9, 2024

☀️ Test successful - checks-actions
Approved by: matthewjasper
Pushing 9dcaa7f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 9, 2024
@bors bors merged commit 9dcaa7f into rust-lang:master Jul 9, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 9, 2024
@Nadrieril Nadrieril deleted the fix-or-pat-expansion branch July 9, 2024 19:44
@Nadrieril
Copy link
Member Author

Ty!

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9dcaa7f): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.7% [0.3%, 1.2%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [0.3%, 1.2%] 3

Max RSS (memory usage)

Results (primary 0.4%)

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)
3.9% [2.5%, 6.9%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-6.7% [-7.8%, -5.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [-7.8%, 6.9%] 6

Cycles

Results (primary 1.1%, secondary -2.3%)

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)
1.1% [1.0%, 1.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-3.4%, -1.2%] 2
All ❌✅ (primary) 1.1% [1.0%, 1.1%] 2

Binary size

Results (primary 0.0%)

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.1% [0.0%, 0.6%] 11
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 18
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.1%, 0.6%] 29

Bootstrap: 701.812s -> 702.397s (0.08%)
Artifact size: 328.73 MiB -> 328.67 MiB (-0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Jul 10, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 12, 2024
…atthewjasper

match lowering: Clarify the main loop of the algorithm

Now that we expand or-patterns in a single place in the algorithm, we can move it (back) to the main part of the loop. This makes the call-graph of the main loop rather simple: `match_candidates` has three branches that each call back to `match_candidates`. The remaining tricky part is `finalize_or_candidate`.

I also factored out the whole "process a prefix of the candidates then process the rest" thing which I think helps legibility.

The first two commits are a fix for an indexing mistake I introduced in rust-lang#126553, already sumitted in rust-lang#127028 but feel free to merge this first.

r? `@matthewjasper`
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 12, 2024
Rollup merge of rust-lang#127164 - Nadrieril:clean-lowering-loop, r=matthewjasper

match lowering: Clarify the main loop of the algorithm

Now that we expand or-patterns in a single place in the algorithm, we can move it (back) to the main part of the loop. This makes the call-graph of the main loop rather simple: `match_candidates` has three branches that each call back to `match_candidates`. The remaining tricky part is `finalize_or_candidate`.

I also factored out the whole "process a prefix of the candidates then process the rest" thing which I think helps legibility.

The first two commits are a fix for an indexing mistake I introduced in rust-lang#126553, already sumitted in rust-lang#127028 but feel free to merge this first.

r? `@matthewjasper`
@rylev
Copy link
Member

rylev commented Jul 17, 2024

Given this is a correctness fix, and the regressions seem in line with previous historical performance (i.e., it regressed back to a previous baseline), I think it's safe to call this triaged. Let me know if anyone disagrees.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants