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

Refactor query forcing #78780

Merged
merged 13 commits into from
Sep 11, 2021
Merged

Refactor query forcing #78780

merged 13 commits into from
Sep 11, 2021

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Nov 5, 2020

The control flow in those functions was very complex, with several layers of continuations.

I tried to simplify the implementation, while keeping essentially the same logic.
Now, all code paths go through try_execute_query for the actual query execution.
Communication with the dep_graph and the live caches are the only difference between query getting/ensuring/forcing.

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 5, 2020
@jyn514 jyn514 added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 5, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 5, 2020

@cjgillot does this need a perf run?

@cjgillot
Copy link
Contributor Author

cjgillot commented Nov 5, 2020

Should be perf-neutral, but a perf run can't hurt.

@jyn514
Copy link
Member

jyn514 commented Nov 5, 2020

Let's hold off then, it will get a perf run when it's merged and whoever does perf triage will see it if it's significant.

@Mark-Simulacrum
Copy link
Member

Queries are generally quite hot, and it won't hurt - @bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Nov 5, 2020

⌛ Trying commit 7dc39e324baf46e4990667269aa4dacd5655fd5f with merge bfb3e3391674a1abc7127c7552b0afd98fcc000f...

@bors
Copy link
Contributor

bors commented Nov 5, 2020

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

@rust-timer
Copy link
Collaborator

Queued bfb3e3391674a1abc7127c7552b0afd98fcc000f with parent b1d9f31, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (bfb3e3391674a1abc7127c7552b0afd98fcc000f): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-perf

compiler/rustc_query_system/src/query/caches.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/query/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/query/on_disk_cache.rs Outdated Show resolved Hide resolved
@JohnCSimon
Copy link
Member

ping from triage
@bjorn3 - can you address the requested changes from bjorn3? if you already have, can you please mark the change request resolved and alert the reviewer? thank you.

@bjorn3
Copy link
Member

bjorn3 commented Dec 7, 2020

@cjgillot is the PR author, not me. Also all my review comments have been resolved.

@bors
Copy link
Contributor

bors commented Dec 9, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@jyn514
Copy link
Member

jyn514 commented Dec 9, 2020

ping @lcnr - are you a good reviewer for this? If not, can you suggest someone, maybe @wesleywiser?

@lcnr
Copy link
Contributor

lcnr commented Dec 9, 2020

yeah, would prefer to hand this off 😅 this ended up slipping under my radar, sry

r? @wesleywiser feel free to reassign if you also can't review this rn

@rust-highfive rust-highfive assigned wesleywiser and unassigned lcnr Dec 9, 2020
@wesleywiser
Copy link
Member

Apologies, it's been a busy week for me and I haven't had time to look at this. It will probably be a few more days before I can take an in-depth look so if you don't want to wait that long, please feel free to re-assign; I don't want to hold this up 🙂

I do see some regressions in the performance data. Would it be feasible to try to narrow down which changes are causing that?

@bors
Copy link
Contributor

bors commented Dec 22, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2021
@jackh726 jackh726 removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2021
@cjgillot
Copy link
Contributor Author

Last perf run shows no runtime modification, and -8% on rustc_query_impl compile time.
I find the resulting code much simpler, -90 lines.
r? @wesleywiser

@cjgillot cjgillot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. perf-regression Performance regression. labels Aug 25, 2021
@cjgillot cjgillot changed the title [WIP] Refactor query forcing Refactor query forcing Aug 25, 2021
@Mark-Simulacrum
Copy link
Member

Thanks! I looked over each commit, and while the code is definitely still not easily readable I think this is moving us in the right direction for sure, great work. Bootstrap time improvement is also nice to see.

I also think that the perf-regression label can be considered acceptable - the vast majority of benchmarks are showing slight improvements, with only a few of the smaller benchmarks showing regressions (helloworld, await-call-tree), and those are quite small too.

@rustbot label: +perf-regression-triaged

@bors r+

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Sep 11, 2021
@Mark-Simulacrum Mark-Simulacrum added the perf-regression Performance regression. label Sep 11, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+

(I think bors missed my earlier comment...)

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 11, 2021

📌 Commit 31330bf has been approved by Mark-Simulacrum

@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 Sep 11, 2021
@Mark-Simulacrum
Copy link
Member

@bors rollup=never

@bors
Copy link
Contributor

bors commented Sep 11, 2021

⌛ Testing commit 31330bf with merge 8c2b6ea...

@bors
Copy link
Contributor

bors commented Sep 11, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 8c2b6ea to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 11, 2021
@bors bors merged commit 8c2b6ea into rust-lang:master Sep 11, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 11, 2021
@bors bors mentioned this pull request Sep 11, 2021
@cjgillot cjgillot deleted the req branch September 12, 2021 00:02
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8c2b6ea): comparison url.

Summary: This change led to moderate relevant mixed results 🤷 in compiler performance.

  • Moderate improvement in instruction counts (up to -0.9% on incr-full builds of unused-warnings)
  • Small regression in instruction counts (up to 1.3% on incr-patched: println builds of coercions)

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

@Mark-Simulacrum
Copy link
Member

@rustbot label: +perf-regression-triaged

The results are as expected before merging, with the majority being slightly positive, and the negative results limited to coercions-debug (typically noisy, though this may be a real data point) and helloworld (small, not very representative of normal code). Generally speaking, it seems like the improvements in bootstrap time and code quality are sufficient to accept these small regressions (and overall mixed results, given the wide swath of small improvements).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) C-cleanup Category: PRs that clean code up or issues documenting cleanup. 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.

None yet