Skip to content

Privacy: try use queue instead of fixed-point iteration#156228

Open
Bryanskiy wants to merge 1 commit into
rust-lang:mainfrom
Bryanskiy:eff_vis_iter_late
Open

Privacy: try use queue instead of fixed-point iteration#156228
Bryanskiy wants to merge 1 commit into
rust-lang:mainfrom
Bryanskiy:eff_vis_iter_late

Conversation

@Bryanskiy
Copy link
Copy Markdown
Contributor

@Bryanskiy Bryanskiy commented May 6, 2026

View all comments

Earlier: iterate until updates of EffectiveVisibility occur.

Now: if an update occurs, then we put in the queue those items that may be affected by this update. Iterate until there are items in the queue.

r? @petrochenkov

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 6, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

@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 May 6, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 6, 2026
Privacy: try use queue instead of fixed-point iteration
@rust-log-analyzer

This comment has been minimized.

@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from 70befe0 to c39f8a6 Compare May 6, 2026 10:57
@rust-log-analyzer

This comment has been minimized.

@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from c39f8a6 to fc8f4b1 Compare May 6, 2026 11:15
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 6, 2026

☀️ Try build successful (CI)
Build commit: cf797a3 (cf797a383bca844619c7f399ee6940b7723eab30, parent: e95e73209faf6ead2bc5c7636e45e589a751b79b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (cf797a3): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-5.3%, -0.1%] 101
Improvements ✅
(secondary)
-0.3% [-1.0%, -0.1%] 17
All ❌✅ (primary) -0.8% [-5.3%, -0.1%] 101

Max RSS (memory usage)

Results (primary -1.9%, secondary -0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.0% [2.6%, 3.3%] 2
Improvements ✅
(primary)
-1.9% [-1.9%, -1.9%] 1
Improvements ✅
(secondary)
-1.9% [-2.5%, -0.4%] 5
All ❌✅ (primary) -1.9% [-1.9%, -1.9%] 1

Cycles

Results (primary -0.1%, secondary -0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
1.8% [0.4%, 5.0%] 4
Improvements ✅
(primary)
-3.0% [-3.0%, -3.0%] 1
Improvements ✅
(secondary)
-1.9% [-4.5%, -0.4%] 5
All ❌✅ (primary) -0.1% [-3.0%, 2.8%] 2

Binary size

Results (primary 0.1%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 31
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 21
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.1%] 31

Bootstrap: 493.455s -> 502.405s (1.81%)
Artifact size: 394.43 MiB -> 394.45 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 6, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

Blocked on #156500.
@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 12, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 13, 2026
Privacy: move macros handling to early stage

The patch moves effective visibility computation for macros from `rustc_privacy` to `rustc_resolve`. It will enable this optimization: rust-lang#156228.

However, I found some problems with macro handling while I was doing this. The current implementation was written ~6 years ago and checks the reachability of a definition from a macro by nominal visibility. In general this is incorrect.

For example, in the current implementation modules are not traversed if their nominal visibility is less then the nominal visibility of a module defining macro: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L618-L626

As a result, in order to compile code like  `tests/ui/definition-reachable/auxiliary/field-method-macro.rs`. we have to additionally traverse types of adt fields: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L628-L638

This is a hack and the proper solution would be to check definitions with `EffectiveVisibilities::is_reachable`. I haven’t done this yet, as it would start to trigger many lints as more items become reachable. I think it’s better to leave the change to another commit.

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 13, 2026
Privacy: move macros handling to early stage

The patch moves effective visibility computation for macros from `rustc_privacy` to `rustc_resolve`. It will enable this optimization: rust-lang#156228.

However, I found some problems with macro handling while I was doing this. The current implementation was written ~6 years ago and checks the reachability of a definition from a macro by nominal visibility. In general this is incorrect.

For example, in the current implementation modules are not traversed if their nominal visibility is less then the nominal visibility of a module defining macro: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L618-L626

As a result, in order to compile code like  `tests/ui/definition-reachable/auxiliary/field-method-macro.rs`. we have to additionally traverse types of adt fields: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L628-L638

This is a hack and the proper solution would be to check definitions with `EffectiveVisibilities::is_reachable`. I haven’t done this yet, as it would start to trigger many lints as more items become reachable. I think it’s better to leave the change to another commit.

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 13, 2026
Privacy: move macros handling to early stage

The patch moves effective visibility computation for macros from `rustc_privacy` to `rustc_resolve`. It will enable this optimization: rust-lang#156228.

However, I found some problems with macro handling while I was doing this. The current implementation was written ~6 years ago and checks the reachability of a definition from a macro by nominal visibility. In general this is incorrect.

For example, in the current implementation modules are not traversed if their nominal visibility is less then the nominal visibility of a module defining macro: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L618-L626

As a result, in order to compile code like  `tests/ui/definition-reachable/auxiliary/field-method-macro.rs`. we have to additionally traverse types of adt fields: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L628-L638

This is a hack and the proper solution would be to check definitions with `EffectiveVisibilities::is_reachable`. I haven’t done this yet, as it would start to trigger many lints as more items become reachable. I think it’s better to leave the change to another commit.

r? @petrochenkov
rust-timer added a commit that referenced this pull request May 14, 2026
Rollup merge of #156500 - Bryanskiy:macros_vis, r=petrochenkov

Privacy: move macros handling to early stage

The patch moves effective visibility computation for macros from `rustc_privacy` to `rustc_resolve`. It will enable this optimization: #156228.

However, I found some problems with macro handling while I was doing this. The current implementation was written ~6 years ago and checks the reachability of a definition from a macro by nominal visibility. In general this is incorrect.

For example, in the current implementation modules are not traversed if their nominal visibility is less then the nominal visibility of a module defining macro: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L618-L626

As a result, in order to compile code like  `tests/ui/definition-reachable/auxiliary/field-method-macro.rs`. we have to additionally traverse types of adt fields: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L628-L638

This is a hack and the proper solution would be to check definitions with `EffectiveVisibilities::is_reachable`. I haven’t done this yet, as it would start to trigger many lints as more items become reachable. I think it’s better to leave the change to another commit.

r? @petrochenkov
@rust-bors

This comment has been minimized.

@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from fc8f4b1 to 624d2b2 Compare May 14, 2026 09:02
@Bryanskiy Bryanskiy marked this pull request as ready for review May 14, 2026 09:14
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 14, 2026
@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from 624d2b2 to cfcb2b8 Compare May 14, 2026 09:21
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
@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 May 14, 2026
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from cfcb2b8 to 26fbfe9 Compare May 17, 2026 13:23
@Bryanskiy
Copy link
Copy Markdown
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 May 18, 2026
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
@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 May 18, 2026
@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch 2 times, most recently from baf96a7 to 9b608f5 Compare May 18, 2026 15:47
@Bryanskiy
Copy link
Copy Markdown
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 May 18, 2026
Comment thread compiler/rustc_privacy/src/lib.rs
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
Comment thread compiler/rustc_privacy/src/lib.rs Outdated
@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 May 18, 2026
@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from 9b608f5 to 64722b1 Compare May 18, 2026 17:41
@Bryanskiy Bryanskiy force-pushed the eff_vis_iter_late branch from 64722b1 to 6615424 Compare May 18, 2026 17:45
@Bryanskiy
Copy link
Copy Markdown
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 May 18, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer
Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 18, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 18, 2026

⌛ Trying commit 6615424 with merge 635d2f6

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/26057407778

rust-bors Bot pushed a commit that referenced this pull request May 18, 2026
Privacy: try use queue instead of fixed-point iteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-perf Status: Waiting on a perf run to be completed. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants