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

Make lowering a query #95573

Merged
merged 12 commits into from
Jul 7, 2022
Merged

Make lowering a query #95573

merged 12 commits into from
Jul 7, 2022

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Apr 1, 2022

Split from #88186.

This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query.
In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new NodeIds and so.

Then, the TyCtxt is modified to allow creating new LocalDefIds from inside it. This is done by:

  • enclosing Definitions in a lock, so as to allow modification;
  • creating a query register_def whose purpose is to declare a LocalDefId to the query system.

See TyCtxt::create_def and TyCtxt::iter_local_def_id for more detailed explanations of the design.

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 1, 2022
@cjgillot
Copy link
Contributor Author

cjgillot commented Apr 1, 2022

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

bors commented Apr 1, 2022

⌛ Trying commit 8f3583b024d77e73b2a2c6a05d89404fb2bad707 with merge 7c9d6056d06c28788c27759f69c7722558f629b2...

@bors
Copy link
Contributor

bors commented Apr 1, 2022

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

@rust-timer
Copy link
Collaborator

Queued 7c9d6056d06c28788c27759f69c7722558f629b2 with parent 297a801, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7c9d6056d06c28788c27759f69c7722558f629b2): comparison url.

Summary:

  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 16 26 10 12 26
mean2 0.3% 0.5% -0.4% -0.4% 0.1%
max 0.5% 0.9% -0.5% -0.7% 0.5%

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 led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@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 added perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 2, 2022
@cjgillot cjgillot mentioned this pull request Apr 2, 2022
11 tasks
@cjgillot
Copy link
Contributor Author

cjgillot commented Apr 2, 2022

r? @michaelwoerister

@bors
Copy link
Contributor

bors commented Apr 5, 2022

☔ The latest upstream changes (presumably #95662) made this pull request unmergeable. Please resolve the merge conflicts.

@michaelwoerister
Copy link
Member

I've done a first pass through the commits but I'll need a while to understand what's going on here :)

@cjgillot
Copy link
Contributor Author

The last commit should significantly simplify how the DepGraph understand the creation of new definitions.

@bors
Copy link
Contributor

bors commented Apr 28, 2022

☔ The latest upstream changes (presumably #91557) made this pull request unmergeable. Please resolve the merge conflicts.

@michaelwoerister
Copy link
Member

Sorry for being slow to review this. I blocked off some time on Monday to do it.

@bors
Copy link
Contributor

bors commented Apr 30, 2022

☔ The latest upstream changes (presumably #93803) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@michaelwoerister michaelwoerister left a comment

Choose a reason for hiding this comment

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

OK, I've done another pass over the PR. It looks correct to me and it has many good improvements. Great work!

I'm not entirely happy with how special the handling of Definitions is. But I think that's unavoidable in the short term. Longer term we can hopefully remove it entirely (at least in its current form).

compiler/rustc_middle/src/query/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_ast_lowering/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/context.rs Show resolved Hide resolved
compiler/rustc_query_system/src/dep_graph/graph.rs Outdated Show resolved Hide resolved
compiler/rustc_query_system/src/dep_graph/graph.rs Outdated Show resolved Hide resolved
compiler/rustc_query_system/src/dep_graph/graph.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/context.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/context.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2022

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@michaelwoerister
Copy link
Member

This looks good to me now, @cjgillot. You can r=me if you think it's ready.

@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 7, 2022

@bors r=michaelwoerister

@bors
Copy link
Contributor

bors commented Jul 7, 2022

📌 Commit 32a30ca has been approved by michaelwoerister

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

bors commented Jul 7, 2022

⌛ Testing commit 32a30ca with merge 0f573a0...

@bors
Copy link
Contributor

bors commented Jul 7, 2022

☀️ Test successful - checks-actions
Approved by: michaelwoerister
Pushing 0f573a0 to master...

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

Finished benchmarking commit (0f573a0): comparison url.

Instruction count

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
0.5% 1.1% 76
Regressions 😿
(secondary)
0.8% 2.4% 57
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-0.2% -0.2% 1
All 😿🎉 (primary) 0.5% 1.1% 76

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
1.4% 1.4% 1
Regressions 😿
(secondary)
2.8% 3.9% 8
Improvements 🎉
(primary)
-1.1% -1.1% 1
Improvements 🎉
(secondary)
-3.5% -6.8% 6
All 😿🎉 (primary) 0.1% 1.4% 2

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
3.4% 4.2% 6
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

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. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@Mark-Simulacrum
Copy link
Member

Results here look to be a slight regression, but overall I think are not worth further investigation -- some of the benchmarks are prone to noise over the last week or so (html5ever, tt-muncher in particular), and though other benchmarks are also affected they're not large enough that we should devote time to investigating in my opinion.

@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Jul 12, 2022
@cjgillot cjgillot deleted the lower-query branch July 13, 2022 11:57
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. perf-regression-triaged The performance regression has been triaged. 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