-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
That's got a high potential of perf impact. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
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`
This comment has been minimized.
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> { |
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.
Can you replace MatchCtxt<'a, Cx>
with &'a Cx
in all of its usages?
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.
No, there are other things I'll need to put in there later
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.
Like what?
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.
Currently planning:
- the
overlapping_range_endpoints
Vec I introduce in Exhaustiveness: track overlapping ranges precisely #119396 - some kind of step counter to gracefully abort on exponential cases (requested by r-a Add fuel to match checking rust-analyzer#9528)
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (da5b704): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 670.05s -> 669.832s (-0.03%) |
044ff22
to
59f105b
Compare
The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging. |
(I'm actually removing a third-party dependency (which I added quite recently (oh well))) |
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. |
…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`
…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`
☔ The latest upstream changes (presumably #119837) made this pull request unmergeable. Please resolve the merge conflicts. |
521a823
to
d2d41da
Compare
@rustbot ready |
This comment was marked as outdated.
This comment was marked as outdated.
d2d41da
to
db36304
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (9567c3e): 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)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 668.845s -> 666.737s (-0.32%) |
…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`
…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`
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