-
Notifications
You must be signed in to change notification settings - Fork 13k
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: use an Option
instead of allocating fictitious patterns
#119688
Conversation
It's incorrect because `CtorSet::split` returns a non-present constructor into `present` in one specific case: variable-length slices of an empty type. That's because empty constructors of arity 0 break the algorithm. This is a tricky corner case that's hard to do cleanly. The assert wasn't adding much anyway.
50ff730
to
8ff893f
Compare
8ff893f
to
1a3edc1
Compare
We should get the same perf issue that #119581 got. It all comes from the commit that introduces the enum but I'm not sure exactly why. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…s, r=<try> 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`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (c27d914): comparison URL. Overall result: ❌✅ regressions and improvements - 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.
CyclesResultsThis 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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 665.982s -> 665.909s (-0.01%) |
Sadly the perf regression isn't quite compensated by the improvement in #119667. Once again wishing match-stress was less sensitive. |
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.
could questions
|
||
fn is_empty(&self) -> bool { | ||
self.patterns.is_empty() | ||
fn expand_and_push(&mut self, pat: PatOrWild<'p, RustcMatchCheckCtxt<'p, 'tcx>>) { |
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.
kind of a shame this is duplicated w/ fn expand_and_push
on Matrix
.
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.
They do have a common shape, but I don't see how to unify them more...
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.
(this one pushes individual patterns and skips wildcards, the Matrix
one pushes rows and doesn't skip wildcards)
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.
oh; then it extra sucks that they are named identically. it would be nice if these methods had more doc comments, lol
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.
Sure
some qeustions @rustbot author |
26eff91
to
4a1889e
Compare
@rustbot ready |
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
Ty! @bors r=compiler-errors |
☀️ Test successful - checks-actions |
Finished benchmarking commit (0a89233): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression 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: 667.319s -> 667.616s (0.04%) |
…-errors Exhaustiveness: remove the need for arena-allocation within the algorithm After rust-lang#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 label: +perf-regression-triaged |
Exhaustiveness: remove the need for arena-allocation within the algorithm After rust-lang/rust#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`
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, whereNone
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 #119581 for ease of review.
r? @compiler-errors