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

Simplify the define_query macro #100943

Merged
merged 7 commits into from
Sep 2, 2022
Merged

Simplify the define_query macro #100943

merged 7 commits into from
Sep 2, 2022

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Aug 24, 2022

This moves a bunch of control flow out of the macro into generic functions, leaving the macro just to call the function with a new generic parameter for each query.

It may be possible to improve compile-times / icache by instantiating the generic functions only with the query key, not the query type itself, but I'm going to leave that for a follow-up PR.

Helps with #96524.

r? @cjgillot

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 24, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2022
@jyn514 jyn514 added the A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) label Aug 24, 2022
@jyn514
Copy link
Member Author

jyn514 commented Aug 24, 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 Aug 24, 2022
@bors
Copy link
Contributor

bors commented Aug 24, 2022

⌛ Trying commit 61d9559b5b175227be74f1610ee8dbc8778b8038 with merge 2c96ac25c27d7e95c062ec4bf1bd937ad27dd441...

@bors
Copy link
Contributor

bors commented Aug 24, 2022

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

@rust-timer
Copy link
Collaborator

Queued 2c96ac25c27d7e95c062ec4bf1bd937ad27dd441 with parent 25ea5a3, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2c96ac25c27d7e95c062ec4bf1bd937ad27dd441): comparison URL.

Overall result: ✅ improvements - no action needed

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

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
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.2%] 3
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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)
3.0% [2.1%, 4.6%] 4
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-4.7% [-4.7%, -4.7%] 1
All ❌✅ (primary) -2.6% [-2.6%, -2.6%] 1

Cycles

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

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 24, 2022
@jyn514
Copy link
Member Author

jyn514 commented Aug 24, 2022

it's hard to tell because this contains other changes, but this PR is actually a regression; #100436 had significant improvements that are gone now. I'll rerun perf once that's merged and we can get a less noisy benchmark.

@@ -300,6 +301,27 @@ pub(crate) fn try_load_from_on_disk_cache<'tcx, K, V>(
}
}

pub(crate) fn force_from_dep_node<'tcx, Q>(
tcx: TyCtxt<'tcx>,
// dep_node: rustc_query_system::dep_graph::DepNode<CTX::DepKind>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Stray comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is removed in a later commit; I can try and fix the history if you like.

compiler/rustc_query_impl/src/plumbing.rs Outdated Show resolved Hide resolved
compiler/rustc_query_impl/src/plumbing.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 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 Aug 29, 2022
@jyn514 jyn514 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 Aug 29, 2022
@jyn514
Copy link
Member Author

jyn514 commented Aug 29, 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 Aug 29, 2022
@bors
Copy link
Contributor

bors commented Aug 29, 2022

⌛ Trying commit 5d8015516034c48d59a9c32de04ad3244999ba1c with merge d51cf6c3170ba41ec8eaa42298d63f17bf40dd00...

@bors
Copy link
Contributor

bors commented Aug 29, 2022

💔 Test failed - checks-actions

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 29, 2022
- Parameterize DepKindStruct over `'tcx`

    This allows passing in an invariant function pointer in `query_callback`,
    rather than having to try and make it work for any lifetime.

- Add a new `execute_query` function to `QueryDescription` so we can call `tcx.$name` without needing to be in a macro context
@jyn514
Copy link
Member Author

jyn514 commented Sep 1, 2022

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Sep 1, 2022

📌 Commit 4e09a13 has been approved by cjgillot

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 1, 2022
@bors
Copy link
Contributor

bors commented Sep 2, 2022

⌛ Testing commit 4e09a13 with merge e21d771...

@bors
Copy link
Contributor

bors commented Sep 2, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 2, 2022
@bors bors merged commit e21d771 into rust-lang:master Sep 2, 2022
@rustbot rustbot added this to the 1.65.0 milestone Sep 2, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e21d771): comparison URL.

Overall result: ❌✅ regressions and 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.8% [0.8%, 0.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@jyn514 jyn514 deleted the query-system-2 branch September 2, 2022 13:01
@jyn514
Copy link
Member Author

jyn514 commented Sep 2, 2022

Bootstrap times are noisy as usual, but looks like this cut down a second of compile time for rustc_middle :)

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Sep 7, 2022
…r=cjgillot

Make `HandleCycleError` an enum instead of a macro-generated closure

Helps with rust-lang#96524. Based on rust-lang#100943 to avoid merge conflicts, so it looks larger than it is (only the last commit is relevant).

cc https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/Moving.20.60Value.60.20to.20rustc_query_system.20.2396524

r? `@cjgillot`
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 8, 2022
…cjgillot

Make `HandleCycleError` an enum instead of a macro-generated closure

Helps with rust-lang#96524. Based on rust-lang#100943 to avoid merge conflicts, so it looks larger than it is (only the last commit is relevant).

cc https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/Moving.20.60Value.60.20to.20rustc_query_system.20.2396524

r? `@cjgillot`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 20, 2024
Make `HandleCycleError` an enum instead of a macro-generated closure

Helps with rust-lang/rust#96524. Based on rust-lang/rust#100943 to avoid merge conflicts, so it looks larger than it is (only the last commit is relevant).

cc https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/Moving.20.60Value.60.20to.20rustc_query_system.20.2396524

r? `@cjgillot`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
Make `HandleCycleError` an enum instead of a macro-generated closure

Helps with rust-lang/rust#96524. Based on rust-lang/rust#100943 to avoid merge conflicts, so it looks larger than it is (only the last commit is relevant).

cc https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/Moving.20.60Value.60.20to.20rustc_query_system.20.2396524

r? `@cjgillot`
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) 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