Skip to content

Conversation

@nnethercote
Copy link
Contributor

QueryDispatcher is a trait that existed purely because rustc_query_system had code that didn't have access to TyCtxt. That is no longer the case, so the trait can be removed.

r? @Zalathar

Query keys must be stably hashable. Currently this requirement is
expressed as a where-clause on `impl QueryDispatcher for
SemiDynamicQueryDispatcher` and a where-clause on
`create_deferred_query_stack_frame`.

This commit removes those where-clause bounds and adds a single bound to
`QueryCache::Key`, which already has some other bounds. I.e. it
consolidates the bounds. It also gives them a name (`QueryCacheKey`) to
avoid repeating them. There is also a related `Key` trait in
`rustc_middle`; it should probably be merged with `QueryCacheKey` in the
future, but not today.

This cleanup helps with the next two commits, which do bigger
rearrangements, and where the where-clauses caused me some difficulties.
It's always `SemiDynamicQueryDispatcher`, so we can just use that type
directly. (This requires adding some explicit generic params to
`QueryDispatcherUnerased`.) Less indirection makes the code clearer, and
this is a prerequisite for the next commit, which is a much bigger
simplification.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 9, 2026
@nnethercote
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 9, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 9, 2026
@nnethercote
Copy link
Contributor Author

Best reviewed one commit at a time.

This code uses generics and trait bounds heavily and getting everything compiling took some effort. The changes I made make sense to me but there might be better ways of doing things.

self.vtable.will_cache_on_disk_for_key_fn.map_or(false, |f| f(tcx, key))
}

// Don't use this method to access query results, instead use the methods on TyCtxt.
Copy link
Member

Choose a reason for hiding this comment

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

Note for future reference: These are existing comments, being migrated over from QueryDispatcher.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

☀️ Try build successful (CI)
Build commit: a7cede3 (a7cede3634626a3af8d24e7a615fb2390494a786, parent: 1c316d34610a3cd31831d2ae8e5dd454f26de430)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a7cede3): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -4.3%, secondary -4.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.3% [-4.3%, -4.3%] 1
Improvements ✅
(secondary)
-4.4% [-4.9%, -4.0%] 3
All ❌✅ (primary) -4.3% [-4.3%, -4.3%] 1

Cycles

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

Binary size

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

Bootstrap: 475.432s -> 478.527s (0.65%)
Artifact size: 397.82 MiB -> 397.89 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 9, 2026
It takes an `is_anon` argument, but it's now generic over `QueryFlags`,
which contains the same `is_anon` field. So the argument is no longer
necessary.
It existed only to bridge the divide between `rustc_query_system` and
`rustc_query_impl`. But enough pieces have been moved from the former to
the latter that the trait is no longer needed. Less indirection and
abstraction makes the code easier to understand.
It's the only thing left in `rustc_query_system::query::dispatcher`.
@Zalathar
Copy link
Member

Zalathar commented Feb 9, 2026

@bors r+ rollup=maybe

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

📌 Commit f995804 has been approved by Zalathar

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 9, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 9, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

☀️ Test successful - CI
Approved by: Zalathar
Duration: 3h 40m 19s
Pushing c6936c3 to main...

@rust-bors rust-bors bot merged commit c6936c3 into rust-lang:main Feb 9, 2026
12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 4cd4c18 (parent) -> c6936c3 (this PR)

Test differences

Show 4 test diffs

4 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard c6936c309add33a7008747866aee081ff5289946 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. aarch64-apple: 2h 15m -> 3h 32m (+56.7%)
  2. dist-apple-various: 1h 5m -> 1h 31m (+39.6%)
  3. dist-aarch64-linux: 2h 43m -> 1h 48m (-33.3%)
  4. dist-aarch64-msvc: 1h 30m -> 1h 42m (+13.1%)
  5. dist-i586-gnu-i586-i686-musl: 1h 36m -> 1h 25m (-11.8%)
  6. i686-gnu-nopt-1: 2h 18m -> 2h 5m (-9.5%)
  7. arm-android: 1h 46m -> 1h 37m (-8.8%)
  8. aarch64-gnu-debug: 1h 17m -> 1h 10m (-8.3%)
  9. dist-aarch64-apple: 1h 52m -> 2h (+6.9%)
  10. i686-msvc-1: 2h 58m -> 2h 45m (-6.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c6936c3): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (secondary 4.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.8% [4.8%, 4.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary 4.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.8% [4.8%, 4.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 15
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 20
All ❌✅ (primary) -0.0% [-0.1%, -0.0%] 15

Bootstrap: 473.075s -> 474.574s (0.32%)
Artifact size: 397.90 MiB -> 397.79 MiB (-0.03%)

@nnethercote nnethercote deleted the rm-QueryDispatcher branch February 10, 2026 01:20
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. 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.

5 participants