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

Exhaustiveness: remove the need for arena-allocation within the algorithm #119581

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

Nadrieril
Copy link
Member

@Nadrieril Nadrieril commented Jan 4, 2024

After #119688, exhaustiveness checking doesn't need access to the arena anymore. This simplifies the lifetime story and makes it compile on stable without the extra dependency.

r? @compiler-errors

@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 Jan 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 4, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Nadrieril
Copy link
Member Author

That's got a high potential of perf impact.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 4, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 4, 2024
Exhaustiveness: remove the need for arena-allocation within the algorithm

WARNING: skip the first commit, it's from rust-lang#119329 which is getting merged.

This nicely cleans up the lifetime story: after this PR, all the `&'p DeconstructedPat` ever handled in the algorithm are coming from user input; we never build one ourselves.

r? `@compiler-errors`
@bors
Copy link
Contributor

bors commented Jan 4, 2024

⌛ Trying commit 044ff22 with merge da5b704...

@rust-log-analyzer

This comment has been minimized.

@@ -87,11 78,9 @@ pub trait TypeCx: Sized fmt::Debug {
/// Context that provides information global to a match.
#[derive(derivative::Derivative)]
#[derivative(Clone(bound = ""), Copy(bound = ""))]
pub struct MatchCtxt<'a, 'p, Cx: TypeCx> {
pub struct MatchCtxt<'a, Cx: TypeCx> {
Copy link
Member

Choose a reason for hiding this comment

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

Can you replace MatchCtxt<'a, Cx> with &'a Cx in all of its usages?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, there are other things I'll need to put in there later

Copy link
Member

Choose a reason for hiding this comment

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

Like what?

Copy link
Member Author

@Nadrieril Nadrieril Jan 4, 2024

Choose a reason for hiding this comment

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

Currently planning:

@bors
Copy link
Contributor

bors commented Jan 4, 2024

☀️ Try build successful - checks-actions
Build commit: da5b704 (da5b704d1e483b378f2384880bb010940ca7ef53)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (da5b704): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking 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 @rustbot label: perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf perf-regression

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
Regressions ❌
(secondary)
2.8% [2.7%, 3.0%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 670.05s -> 669.832s (-0.03%)
Artifact size: 311.83 MiB -> 311.88 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 4, 2024
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 4, 2024

The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging.

cc @davidtwco, @wesleywiser

@Nadrieril
Copy link
Member Author

(I'm actually removing a third-party dependency (which I added quite recently (oh well)))

@Nadrieril Nadrieril removed A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 4, 2024
@Nadrieril
Copy link
Member Author

I'm realizing this PR does a few different things. Would you prefer me to split it up for ease of review?

@compiler-errors
Copy link
Member

I'm realizing this PR does a few different things. Would you prefer me to split it up for ease of review?

Yes, I'd like this to be split I think, or at least a write-up that explains wtf it's doing, lol. The PR description is kinda barren.

@Nadrieril Nadrieril 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 Jan 6, 2024
@Nadrieril Nadrieril removed the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jan 7, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 11, 2024
…s, r=compiler-errors

Exhaustiveness: use an `Option` instead of allocating fictitious patterns

In the process of exhaustiveness checking, `Matrix` stores a 2D array of patterns. Those are subpatterns of the patterns we were provided as input, _except_ sometimes we allocate some extra wildcard patterns to fill a hole during specialization.

Morally though, we could store `Option<&'p DeconstructedPat>` in the matrix, where `None` signifies a wildcard. That way we'd only have "real" patterns in the matrix and we wouldn't need the arena to allocate these wildcards. This is what this PR does.

This is part of me splitting up rust-lang#119581 for ease of review.

r? `@compiler-errors`
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 11, 2024
…iler-errors

Exhaustiveness: use an `Option` instead of allocating fictitious patterns

In the process of exhaustiveness checking, `Matrix` stores a 2D array of patterns. Those are subpatterns of the patterns we were provided as input, _except_ sometimes we allocate some extra wildcard patterns to fill a hole during specialization.

Morally though, we could store `Option<&'p DeconstructedPat>` in the matrix, where `None` signifies a wildcard. That way we'd only have "real" patterns in the matrix and we wouldn't need the arena to allocate these wildcards. This is what this PR does.

This is part of me splitting up rust-lang/rust#119581 for ease of review.

r? `@compiler-errors`
@bors
Copy link
Contributor

bors commented Jan 11, 2024

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

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 11, 2024
@Nadrieril
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 Jan 11, 2024
@Nadrieril Nadrieril removed the A-testsuite Area: The testsuite used to check the correctness of rustc label Jan 11, 2024
@bors

This comment was marked as outdated.

@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Jan 14, 2024
@compiler-errors
Copy link
Member

@bors r

@bors
Copy link
Contributor

bors commented Jan 14, 2024

📌 Commit db36304 has been approved by compiler-errors

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 Jan 14, 2024
@bors
Copy link
Contributor

bors commented Jan 15, 2024

⌛ Testing commit db36304 with merge 9567c3e...

@bors
Copy link
Contributor

bors commented Jan 15, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 9567c3e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 15, 2024
@bors bors merged commit 9567c3e into rust-lang:master Jan 15, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 15, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9567c3e): 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

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

Binary size

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

Bootstrap: 668.845s -> 666.737s (-0.32%)
Artifact size: 308.21 MiB -> 308.19 MiB (-0.01%)

@Nadrieril Nadrieril deleted the detangle-arena branch January 15, 2024 11:17
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Apr 7, 2024
…iler-errors

Exhaustiveness: use an `Option` instead of allocating fictitious patterns

In the process of exhaustiveness checking, `Matrix` stores a 2D array of patterns. Those are subpatterns of the patterns we were provided as input, _except_ sometimes we allocate some extra wildcard patterns to fill a hole during specialization.

Morally though, we could store `Option<&'p DeconstructedPat>` in the matrix, where `None` signifies a wildcard. That way we'd only have "real" patterns in the matrix and we wouldn't need the arena to allocate these wildcards. This is what this PR does.

This is part of me splitting up rust-lang/rust#119581 for ease of review.

r? `@compiler-errors`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
…iler-errors

Exhaustiveness: use an `Option` instead of allocating fictitious patterns

In the process of exhaustiveness checking, `Matrix` stores a 2D array of patterns. Those are subpatterns of the patterns we were provided as input, _except_ sometimes we allocate some extra wildcard patterns to fill a hole during specialization.

Morally though, we could store `Option<&'p DeconstructedPat>` in the matrix, where `None` signifies a wildcard. That way we'd only have "real" patterns in the matrix and we wouldn't need the arena to allocate these wildcards. This is what this PR does.

This is part of me splitting up rust-lang/rust#119581 for ease of review.

r? `@compiler-errors`
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) 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.

None yet

6 participants