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

rustc_metadata: Do not encode unnecessary module children #95899

Merged
merged 1 commit into from
Apr 17, 2022

Conversation

petrochenkov
Copy link
Contributor

This should remove the syntax context shift and the special case for ExternCrate in decoder in #95880.

This PR also shifts some work from decoding to encoding, which is typically useful for performance (but probably not much in this case).
r? @cjgillot

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 10, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2022
@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
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 Apr 10, 2022
@bors
Copy link
Contributor

bors commented Apr 10, 2022

⌛ Trying commit 36ba6536d5fe584045342593906442662c178063 with merge ab97670d6b187ca5c79ef1f034cb0cf847d414a0...

@bors
Copy link
Contributor

bors commented Apr 10, 2022

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

@rust-timer
Copy link
Collaborator

Queued ab97670d6b187ca5c79ef1f034cb0cf847d414a0 with parent 027a232, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ab97670d6b187ca5c79ef1f034cb0cf847d414a0): comparison url.

Summary:

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvements found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 0 14 0
mean2 N/A N/A N/A -0.6% N/A
max N/A N/A N/A -1.4% N/A

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

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.

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

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 11, 2022
@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
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 Apr 11, 2022
@bors
Copy link
Contributor

bors commented Apr 11, 2022

⌛ Trying commit 2500d5ef21981b32ddd0c07426622466ed9a88f7 with merge 375662f24f455afd30df0f92c7fe92d4c168bbb8...

@bors
Copy link
Contributor

bors commented Apr 11, 2022

☀️ Try build successful - checks-actions
Build commit: 375662f24f455afd30df0f92c7fe92d4c168bbb8 (375662f24f455afd30df0f92c7fe92d4c168bbb8)

@rust-timer
Copy link
Collaborator

Queued 375662f24f455afd30df0f92c7fe92d4c168bbb8 with parent 90ca447, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (375662f24f455afd30df0f92c7fe92d4c168bbb8): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: 🎉 relevant improvements found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 3 13 31 13
mean2 N/A 0.6% -0.3% -0.5% -0.3%
max N/A 0.6% -0.6% -1.5% -0.6%

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

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.

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

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 12, 2022
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.

This feels so much cleaner!
Should we use the same iter_from_generator to make for_each_module_child return an iterator?

compiler/rustc_data_structures/src/lib.rs Show resolved Hide resolved
}

/// An adapter for turning a generator closure into an iterator, similar to `iter::from_fn`.
pub fn iter_from_generator<G: Generator + Unpin>(generator: G) -> impl Iterator<Item = G::Yield> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I almost feel this should be in std.

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'll make separate PR to add this to libcore, not sure whether it will be merged and how much time it may take.
I don't know why this functionality wasn't added yet, maybe there are reasons - the body of work produced by async-wg is vast, but I didn't read any of it.

@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 Apr 12, 2022
@petrochenkov
Copy link
Contributor Author

Should we use the same iter_from_generator to make for_each_module_child return an iterator?

I'll try to do it a bit later in a separate PR.
The previous attempt to do it with iterator combinators wasn't very successfull.

FWIW, I also tried to move insertion of struct/variant constructors to module children lists from decoding to encoding, but encountered some ICE in rustc_mir_transform for generators (petrochenkov@813575f). Probably need to minimize it somehow and report as an issue.

@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 Apr 12, 2022
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 15, 2022

📌 Commit 233fa65 has been approved by cjgillot

@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 Apr 15, 2022
@bors
Copy link
Contributor

bors commented Apr 16, 2022

⌛ Testing commit 233fa65 with merge 563ef23...

@bors
Copy link
Contributor

bors commented Apr 17, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 17, 2022
@bors bors merged commit 563ef23 into rust-lang:master Apr 17, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 17, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (563ef23): comparison url.

Summary:

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 4 0 10 0
mean2 N/A 0.9% N/A -0.7% N/A
max N/A 1.1% N/A -1.4% N/A

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

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

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

@rustbot rustbot added the perf-regression Performance regression. label Apr 17, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 27, 2022
rustc_metadata: Add struct and variant constructors to module children at encoding time

instead of decoding time.

Continuation of rust-lang#95899.
The last time it caused some ICEs from generator use, but not everything seems ok.
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.

6 participants