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

Populate effective visibilities in 'rustc_resolve' #102026

Merged
merged 1 commit into from
Oct 16, 2022

Conversation

Bryanskiy
Copy link
Contributor

Next part of RFC #48054.
previous: #101713

@rustbot author
r? @petrochenkov

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 19, 2022
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 19, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 19, 2022
@petrochenkov
Copy link
Contributor

@rustbot author

This doesn't seem to work correctly if posted in the PR description.
@rustbot author

@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 19, 2022
@Bryanskiy
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 Sep 20, 2022
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_span/src/def_id.rs Outdated Show resolved Hide resolved
compiler/rustc_span/src/def_id.rs Outdated Show resolved Hide resolved
src/test/ui/privacy/access_levels.rs Outdated Show resolved Hide resolved
src/test/ui/privacy/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
@petrochenkov petrochenkov 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 Sep 20, 2022
@petrochenkov
Copy link
Contributor

Could you also refactor fn set_bindings_access_level into something like this - petrochenkov@155cb7e?
I already suggested it in the initial PR - #100147 (comment).

@bors

This comment was marked as resolved.

@Bryanskiy
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 Sep 26, 2022
src/test/ui/privacy/access_levels.rs Show resolved Hide resolved
compiler/rustc_privacy/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_privacy/src/lib.rs Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

Also #102026 (comment) wasn't addressed yet.

compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/middle/privacy.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/access_levels.rs Outdated Show resolved Hide resolved
@petrochenkov petrochenkov 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 Oct 6, 2022
@Bryanskiy
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 Oct 9, 2022
@Bryanskiy
Copy link
Contributor Author

@rustbot author

@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 Oct 9, 2022
@bors
Copy link
Contributor

bors commented Oct 16, 2022

⌛ Testing commit 496ccd9 with merge b8b5cae...

@bors
Copy link
Contributor

bors commented Oct 16, 2022

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing b8b5cae to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 16, 2022
@bors bors merged commit b8b5cae into rust-lang:master Oct 16, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 16, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b8b5cae): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
1.1% [0.2%, 5.6%] 65
Regressions ❌
(secondary)
0.9% [0.2%, 3.7%] 32
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.1% [0.2%, 5.6%] 65

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.6% [-1.6%, -1.6%] 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.

mean1 range count2
Regressions ❌
(primary)
2.8% [2.1%, 3.9%] 9
Regressions ❌
(secondary)
2.9% [2.2%, 3.9%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [2.1%, 3.9%] 9

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added the perf-regression Performance regression. label Oct 17, 2022
@nnethercote
Copy link
Contributor

Ouch, there are some significant performance regressions caused by this. They are bad enough that I think we should consider reverting this PR.

@Bryanskiy: did you consider compile times while working on this? Are there possibilities for optimizing the new code?

@petrochenkov
Copy link
Contributor

This PR implements new functionality, i.e. the compiler has to do more work, so a slight regression would be expected, but probably not this much. We certainly need to check what exactly is a hotspot here.

Perhaps fully private items are visited too much and that can be avoided by pruning them early, or perhaps it's something else.

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2022
Perf improvements for effective visibility calculating

related to rust-lang#102026
r? `@petrochenkov`
@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 29, 2022

#103158, #103496 and #103688 recover some of the performance here, and I will do some more work on this pass in the next few days which may help with performance too.

@nnethercote
Copy link
Contributor

Great news!

RalfJung pushed a commit to RalfJung/miri that referenced this pull request Oct 30, 2022
Perf improvements for effective visibility calculating

related to rust-lang/rust#102026
r? `@petrochenkov`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 30, 2022
…omez

rustdoc: Simplify modifications of effective visibility table

It is now obvious that rustdoc only calls `set_access_level` with foreign def ids and `AccessLevel::Public`.

The second commit makes one more step and separates effective visibilities coming from rustc from similar data collected by rustdoc for extern `DefId`s.
The original table is no longer modified and now only contains local def ids as populated by rustc.

cc rust-lang#102026 `@Bryanskiy`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 1, 2022
rustc_metadata: Encode even less doc comments

The fact that `def_id` is in the `tcx.privacy_access_levels(())` table is not very meaningful, especially after rust-lang#102026, `is_exported` (or `is_reachable` in the worst case) is what you need.

Follow up to rust-lang#98450.
r? `@GuillaumeGomez` `@lqd`
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Nov 5, 2022
rustdoc: Simplify modifications of effective visibility table

It is now obvious that rustdoc only calls `set_access_level` with foreign def ids and `AccessLevel::Public`.

The second commit makes one more step and separates effective visibilities coming from rustc from similar data collected by rustdoc for extern `DefId`s.
The original table is no longer modified and now only contains local def ids as populated by rustc.

cc rust-lang/rust#102026 `@Bryanskiy`
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Nov 5, 2022
rustc_metadata: Encode even less doc comments

The fact that `def_id` is in the `tcx.privacy_access_levels(())` table is not very meaningful, especially after rust-lang/rust#102026, `is_exported` (or `is_reachable` in the worst case) is what you need.

Follow up to rust-lang/rust#98450.
r? `@GuillaumeGomez` `@lqd`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2022
resolve: More detailed effective visibility tracking for imports

Per-`DefId` tracking is not enough, due to glob imports in particular, which have a single `DefId` for the whole glob import item.
We need to track this stuff per every introduced name (`NameBinding`).

Also drop `extern` blocks from the effective visibility table, they are nominally private and it doesn't make sense to keep them there.

Later commits add some debug-only invariant checking and optimiaztions to mitigate regressions in rust-lang#103965 (comment).

This is a bugfix and continuation of rust-lang#102026.
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…nkov

Populate effective visibilities in 'rustc_resolve'

Next part of RFC rust-lang#48054.
previous: rust-lang#101713

`@rustbot` author
r? `@petrochenkov`
@Bryanskiy Bryanskiy deleted the resolve_update branch May 17, 2023 13:36
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. perf-regression Performance regression. 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.

9 participants