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

Perf improvements for effective visibility calculating #103158

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

Bryanskiy
Copy link
Contributor

related to #102026
r? @petrochenkov

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 17, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 17, 2022
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

If the update operation is a hotspot you need to get rid of all the helper methods it calls and reimplemented it from scratch as a single operation.

What I don't like right now:

  • Two nested loops over levels, the logic should go over the previous and parent effective visibilities once and do the minimal number of comparisons.
  • EffectiveVisibility::update is only called once from AccessLevels::update and can be inlined/removed.
  • Double search in the map self.get_effective_vis(id) + self.map.insert(id, ...), you could use self.map.entry(...) instead.

It may also be useful to go back to using Option<Visibility>es in EffectiveVisibility, in that case fully private visibilities (None) can be compared without is_at_least.
All of this needs benchmarking though.

Also, as I said in #102026 (comment) it's possible that update itself is not the main reason for the slowdown, it's possible that the reason is that we call it for items for which we shouldn't call it at all.
@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 18, 2022
@Bryanskiy Bryanskiy force-pushed the resolve_perf branch 2 times, most recently from 23f8a02 to da872f1 Compare October 19, 2022 14:52
@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Oct 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 Oct 19, 2022
@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 19, 2022
@Bryanskiy Bryanskiy force-pushed the resolve_perf branch 2 times, most recently from d31d83c to f162be9 Compare October 23, 2022 11:45
@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 23, 2022
@bors

This comment was marked as resolved.

@petrochenkov
Copy link
Contributor

I cannot start a perf run until this PR is rebased.
@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 23, 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 24, 2022
@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 Oct 24, 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 25, 2022
@petrochenkov petrochenkov changed the title [WIP] perf improvements for effective visibility calculating Perf improvements for effective visibility calculating Oct 25, 2022
@petrochenkov
Copy link
Contributor

r=me after squashing commits.
@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 25, 2022
@rust-log-analyzer

This comment has been minimized.

@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 25, 2022
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Oct 25, 2022

📌 Commit a9447bb has been approved by petrochenkov

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

bors commented Oct 26, 2022

⌛ Testing commit a9447bb with merge a5406fe...

@bors
Copy link
Contributor

bors commented Oct 26, 2022

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

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

Finished benchmarking commit (a5406fe): 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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.5%, -0.3%] 6
Improvements ✅
(secondary)
-0.6% [-2.0%, -0.2%] 22
All ❌✅ (primary) -0.4% [-0.5%, -0.3%] 6

Max RSS (memory usage)

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

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

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
Perf improvements for effective visibility calculating

related to rust-lang#102026
r? `@petrochenkov`
pietroalbini added a commit to ferrocene/sphinx-shared-resources that referenced this pull request Mar 22, 2023
@Bryanskiy Bryanskiy deleted the resolve_perf 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
A-testsuite Area: The testsuite used to check the correctness of rustc 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