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

resolve: Querify most cstore access methods (subset) #108992

Merged
merged 8 commits into from
Mar 14, 2023

Conversation

petrochenkov
Copy link
Contributor

A subset of #108346 that is not on a hot path in any way.

@rustbot
Copy link
Collaborator

rustbot commented Mar 10, 2023

r? @wesleywiser

(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 Mar 10, 2023
@petrochenkov
Copy link
Contributor 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 Mar 10, 2023
@bors
Copy link
Contributor

bors commented Mar 10, 2023

⌛ Trying commit 609146135ed161149f162055ff123870fd593b26 with merge 09e4d7a44bc9c01eb4c5317d4aa7b60877e4aa78...

@bors
Copy link
Contributor

bors commented Mar 10, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Mar 10, 2023

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

@rust-timer

This comment has been minimized.

@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 10, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (09e4d7a44bc9c01eb4c5317d4aa7b60877e4aa78): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.6%, -0.2%] 6
Improvements ✅
(secondary)
-1.8% [-1.8%, -1.8%] 1
All ❌✅ (primary) -0.2% [-0.6%, 0.5%] 7

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.7% [-0.8%, -0.7%] 2
Improvements ✅
(secondary)
-3.8% [-6.0%, -2.0%] 4
All ❌✅ (primary) -0.7% [-0.8%, -0.7%] 2

Cycles

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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 10, 2023
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 10, 2023
@petrochenkov
Copy link
Contributor Author

r? @cjgillot
@rustbot ready

@rustbot rustbot assigned cjgillot and unassigned wesleywiser Mar 11, 2023
@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 Mar 11, 2023
Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

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

What a cleanup!

fn associated_item_def_ids(&self, def_id: DefId) -> Option<&'tcx [DefId]> {
match def_id.as_local() {
Some(def_id) => self.associated_item_def_ids.get(&def_id).copied(),
None => Some(self.tcx.associated_item_def_ids(def_id)),
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming here is off.

The associated_item_def_ids query is only supposed to work on traits and impl blocks, to return the def-ids of the contained items. Using it to access an ADT's fields is a quirk of metadata decoding, which stores both information in the same children table and does not validate the parent before answering.

The "proper" way to access the information would use the tcx.adt_def query.

In the same idea, this method and the field in the first branch would be better named field_def_ids, as that's what they are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The associated_item_def_ids query is only supposed to work on traits and impl blocks, to return the def-ids of the contained items.

I'd say that fields are close enough to bless this use.
Previously associated_item_def_ids was certainly used for fields in rustdoc (until #94857 nuked all the relevant code) and maybe in rustc too.

The "proper" way to access the information would use the tcx.adt_def query.

adt_def query cannot be used in resolve because it create cycles (it needs lang items).
Also it decodes much more information than necessary in our case, but it doesn't matter much because all its uses would be in diagnostics (but in general associated_item_def_ids relates to the adt_def query in the same way as to associated_item, i.e. minimizing decoding and dependencies).

In the same idea, this method and the field in the first branch would be better named field_def_ids, as that's what they are.

Yeah, I'll rename.
I used the current naming to maybe extend it to other associated items in the future, but now I agree that it only brings confusion.

LL | XE::XEmpty5(/* fields */) => (),
| ~~~~~~~~~~~~~~~~~~~~~~~~~
LL | XE::XEmpty5() => (),
| ~~~~~~~~~~~~~
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does the diagnostic change come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previosly insert_field_names_extern wasn't called for enum variant fields, but now fields for extern variants are successfully retrieved, this is a correct fix.

@cjgillot cjgillot 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 Mar 11, 2023
@petrochenkov
Copy link
Contributor 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 Mar 13, 2023
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 13, 2023

📌 Commit 4a61922 has been approved by cjgillot

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 Mar 13, 2023
@bors
Copy link
Contributor

bors commented Mar 14, 2023

⌛ Testing commit 4a61922 with merge bd43458...

@bors
Copy link
Contributor

bors commented Mar 14, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing bd43458 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 14, 2023
@bors bors merged commit bd43458 into rust-lang:master Mar 14, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 14, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bd43458): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-1.2%, -0.2%] 15
Improvements ✅
(secondary)
-1.6% [-2.1%, -1.1%] 2
All ❌✅ (primary) -0.4% [-1.2%, 0.5%] 16

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)
3.6% [3.1%, 4.3%] 3
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
-5.8% [-8.4%, -3.7%] 3
All ❌✅ (primary) -3.1% [-3.1%, -3.1%] 1

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

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.

6 participants