Skip to content

Conversation

kckeiks
Copy link
Contributor

@kckeiks kckeiks commented Jun 17, 2022

Issue #96341

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 17, 2022
@rust-highfive
Copy link
Contributor

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 17, 2022
@kckeiks
Copy link
Contributor Author

kckeiks commented Jun 17, 2022

r? @cjgillot

@rust-highfive rust-highfive assigned cjgillot and unassigned nagisa Jun 17, 2022
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about this?

Suggested change
if self.tcx.hir().is_body_owner(item.def_id) {
if associated_body(Node::Item(item)).is_some() {

@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch 2 times, most recently from 0366bfc to 327a469 Compare June 17, 2022 21:58
@rust-log-analyzer

This comment has been minimized.

@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch 2 times, most recently from 8343258 to b535db3 Compare June 17, 2022 23:02
@rust-log-analyzer

This comment has been minimized.

@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch from b535db3 to 1160496 Compare June 17, 2022 23:29
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

Choose a reason for hiding this comment

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

We want to record the LocalDefId of the closure. hir_id.owner is the one of the closure's surrounding item-like (that we have already recorded in visit_*item).

Suggested change
self.body_owners.push(ex.hir_id.owner);
self.body_owners.push(self.tcx.hir().local_def_id(ex.hir_id));

Likewise for anon consts.

Copy link
Contributor

Choose a reason for hiding this comment

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

This probably pushes the same LocalDefId twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that was the problem.

@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 Jun 21, 2022
@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch 3 times, most recently from bbc27a9 to 17734a6 Compare June 24, 2022 16:39
@kckeiks kckeiks marked this pull request as ready for review June 24, 2022 17:19
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.

Sorry for the delay @kckeiks, I had not realized you were waiting for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is always true.

Copy link
Contributor

Choose a reason for hiding this comment

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

associated_body(...).is_some() is always true on closures.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is always false.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you inline the definition of associated_body here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you inline the definition of associated_body here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you inline the definition of associated_body here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can merge this visitor and the one for hir_module_items using some flag to switch behaviour.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I forgot to remove this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This case is possibly wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

This one too.

kckeiks added 3 commits July 6, 2022 19:17
Signed-off-by: Miguel Guarniz <[email protected]>
Signed-off-by: Miguel Guarniz <[email protected]>
Signed-off-by: Miguel Guarniz <[email protected]>
@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch from 4d38f6e to 75ffbb0 Compare July 6, 2022 23:17
@cjgillot
Copy link
Contributor

@bors retry

@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 Jul 13, 2022
@bors
Copy link
Collaborator

bors commented Jul 13, 2022

⌛ Testing commit 75ffbb021cc96d6032fe5cad46153e401dc51802 with merge adc213b9b01134a4bcfc3efdac1e293946e6ab2d...

@bors
Copy link
Collaborator

bors commented Jul 13, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 13, 2022
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
par_iter(self.tcx.hir_crate_items(()).body_owners.to_vec()).for_each(|def_id| f(def_id));
par_iter(&self.tcx.hir_crate_items(()).body_owners[..]).for_each(|&def_id| f(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.

This will insert a module as its own submodule. We should probably handle all ItemKind::Mod in visit_item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the if-else in visit_item would prevent that from happening? visit_mod gets called only by walk_item.

        if !self.crate_collector && let ItemKind::Mod(..) = item.kind {
            // If this declares another module, do not recurse inside it.
            self.submodules.push(item.def_id);
        } else {
            intravisit::walk_item(self, item)
        }

Copy link
Contributor

Choose a reason for hiding this comment

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

visit_mod is the entry point called by hir_module_items.

kckeiks added 3 commits July 13, 2022 12:22
Signed-off-by: Miguel Guarniz <[email protected]>
Signed-off-by: Miguel Guarniz <[email protected]>
@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch from 75ffbb0 to ad76362 Compare July 13, 2022 17:26
@kckeiks kckeiks force-pushed the gather-body-owners-in-hir-item-queries branch from ad76362 to 2d265b6 Compare July 13, 2022 17:55
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 14, 2022

📌 Commit 2d265b6 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 Jul 14, 2022
@bors
Copy link
Collaborator

bors commented Jul 15, 2022

⌛ Testing commit 2d265b6 with merge 30243dd...

@bors
Copy link
Collaborator

bors commented Jul 15, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 15, 2022
@bors bors merged commit 30243dd into rust-lang:master Jul 15, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 15, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (30243dd): comparison url.

Instruction count

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
0.6% 0.6% 1
Improvements 🎉
(primary)
-0.4% -0.7% 30
Improvements 🎉
(secondary)
-0.5% -0.8% 18
All 😿🎉 (primary) -0.4% -0.7% 30

Max RSS (memory usage)

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-2.7% -2.7% 1
Improvements 🎉
(secondary)
-3.2% -4.3% 4
All 😿🎉 (primary) -2.7% -2.7% 1

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.0% 2.0% 1
Improvements 🎉
(primary)
-1.2% -1.2% 1
Improvements 🎉
(secondary)
-2.9% -2.9% 1
All 😿🎉 (primary) -1.2% -1.2% 1

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

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.

8 participants