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

pattern_analysis: track usefulness without interior mutability #120324

Merged
merged 4 commits into from Feb 13, 2024

Conversation

Nadrieril
Copy link
Member

@Nadrieril Nadrieril commented Jan 24, 2024

Because of or-patterns, exhaustiveness needs to be able to lint if a sub-pattern is redundant, e.g. in Some(_) | Some(true). So far the only sane solution I had found was interior mutability. This is a bit of an abstraction leak, and would become a footgun if we ever reused the same DeconstructedPat. This PR replaces interior mutability with an address-indexed hashmap, which is logically equivalent.

@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2024

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@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 24, 2024
@Nadrieril
Copy link
Member Author

r? @ghost

@rustbot
Copy link
Collaborator

rustbot commented Jan 24, 2024

Failed to set assignee to ghost: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@Nadrieril
Copy link
Member Author

@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 24, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 24, 2024
…, r=<try>

Experiment: track usefulness without interior mutability

This would remove a potential footgun in r-a. Just wanna see if this kills perf
@bors
Copy link
Contributor

bors commented Jan 24, 2024

⌛ Trying commit 8f04a1e with merge 09d4a12...

@bors
Copy link
Contributor

bors commented Jan 25, 2024

☀️ Try build successful - checks-actions
Build commit: 09d4a12 (09d4a121c582c90b8bff6f6018482f56ef291895)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (09d4a12): comparison URL.

Overall result: no relevant changes - no 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.

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

Instruction count

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

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.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.8%, -2.7%] 2
All ❌✅ (primary) - - 0

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

Binary size

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

Bootstrap: 664.789s -> 665.467s (0.10%)
Artifact size: 308.40 MiB -> 308.41 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 25, 2024
@Nadrieril Nadrieril changed the title Experiment: track usefulness without interior mutability pattern_analysis: track usefulness without interior mutability Jan 30, 2024
@Nadrieril Nadrieril marked this pull request as ready for review February 3, 2024 23:58
@Nadrieril
Copy link
Member Author

r? @compiler-errors
@rustbot ready

@bors

This comment was marked as resolved.

@Nadrieril Nadrieril force-pushed the remove-interior-mutability branch 2 times, most recently from 560e150 to 5747965 Compare February 7, 2024 03:41
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

Hmm... I have mixed feelings about using address-based indexing here :|

Is there any way we could give some other kind of unique ID to all the DeconstructedPats for use in tracking this state instead?

@rustbot rustbot 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 Feb 7, 2024
@Nadrieril
Copy link
Member Author

We could store a AtomicUsize-generated id in DeconstructedPat, like I do for Constructor::Opaque. Using the spans is tempting but fails in the presence of macros. Would you prefer that?

@compiler-errors
Copy link
Member

Yeah, spans are a no-go. They're not unique. I would prefer a real dedicated ID. Why does it need to be atomic? We don't expect it to be modified after the DeconstructedPat is created, right?

@Nadrieril
Copy link
Member Author

Nadrieril commented Feb 7, 2024

Oh indeed, I meant storing a usize, but made globally unique by incrementing a static AtomicUsize

@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 Feb 7, 2024
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 12, 2024

📌 Commit be29cd1 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 Feb 12, 2024
@bors
Copy link
Contributor

bors commented Feb 12, 2024

⌛ Testing commit be29cd1 with merge 74c3f5a...

@bors
Copy link
Contributor

bors commented Feb 13, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 13, 2024
@bors bors merged commit 74c3f5a into rust-lang:master Feb 13, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 13, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (74c3f5a): 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: 664.301s -> 664.029s (-0.04%)
Artifact size: 308.35 MiB -> 308.34 MiB (-0.01%)

@Nadrieril Nadrieril deleted the remove-interior-mutability branch February 13, 2024 03:32
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. 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.

None yet

6 participants