Skip to content

Streamline QueryVTableUnerased into QueryVTableGetter#152841

Draft
Zalathar wants to merge 1 commit intorust-lang:mainfrom
Zalathar:unerased
Draft

Streamline QueryVTableUnerased into QueryVTableGetter#152841
Zalathar wants to merge 1 commit intorust-lang:mainfrom
Zalathar:unerased

Conversation

@Zalathar
Copy link
Member

QueryDispatcherUnerased is an awkward name for an awkward trait.

We can make it a bit more straightforward by removing its responsibility for erasing query values, and by observing that its only real responsibility beyond that is to know how to obtain the vtable for a particlar query from tcx (in the form of a SemiDynamicQueryDispatcher).

Along the way, this PR also uses the newly-renamed QueryVTableGetter trait to slightly simplify two of the functions in DepKindVTable.

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2026
@Zalathar
Copy link
Member 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 19, 2026
Streamline `QueryVTableUnerased` into `QueryVTableGetter`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 19, 2026
@Zalathar
Copy link
Member Author

/// Marker type that implements [`QueryVTableGetter`] for this query.
pub(crate) enum VTableGetter {}

impl<'tcx> QueryVTableGetter<'tcx, FLAGS> for VTableGetter {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a trait with a single implementer (per query).
Would it be hard to refactor it into a free (per query) function somehow?
(Similarly to how restore_val was removed from the trait's interface.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Using a free function seems tricky, because the generics needed per callee would get more complicated, and that's something I'm trying to cut down on.

fn query_dispatcher(tcx: TyCtxt<'tcx>) -> SemiDynamicQueryDispatcher<'tcx, C, FLAGS>;

fn restore_val(value: C::Value) -> Self::UnerasedValue;
fn query_dispatcher(tcx: TyCtxt<'tcx>) -> SemiDynamicQueryDispatcher<'tcx, Self::Cache, FLAGS>;
Copy link
Contributor

Choose a reason for hiding this comment

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

If the trait method produces a query dispatcher, then I'd call the trait GetQueryDispatcher, so both say what it does and follow trait naming conventions.

Or keep "vtable", but rename SemiDynamicQueryDispatcher to SemiDynamicQueryVTable because that's also what it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

... or SemiStatic, because it's still mostly dynamic :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The name SemiDynamicQueryDispatcher is a relic from before the QueryDispatcher trait was removed, so for consistent naming I'd prefer to move away from “dispatcher” and towards ”vtable”.

I have some ideas for how to rename SemiDynamicQueryDispatcher, and possibly reduce the number of explicit FLAGS parameters everywhere, but that needs some more experimentation while I figure out what things should look like.

Copy link
Member Author

Choose a reason for hiding this comment

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

One of the candidates I have in mind for SemiDynamicQueryDispatcher is QueryVTableWithFlags, but I was also thinking about using that name for a trait that hides the flags in an associated constant, so that callees would accept impl QueryVTableWithFlags and not have to have a const FLAGS generic at all.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 19, 2026

☀️ Try build successful (CI)
Build commit: b46d288 (b46d288105b795d2d5f97fe4d4e7edc8076a0796, parent: fbd6934114e905d3cc61adbbd7e4a355eac5d0d7)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b46d288): comparison URL.

Overall result: ❌ regressions - please read the text below

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.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.3% [0.2%, 0.4%] 9
Regressions ❌
(secondary)
0.3% [0.1%, 0.5%] 35
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.4%] 9

Max RSS (memory usage)

Results (secondary 1.0%)

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

Cycles

Results (primary 2.2%, secondary 9.1%)

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

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

Binary size

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

Bootstrap: 481.318s -> 480.997s (-0.07%)
Artifact size: 397.87 MiB -> 397.77 MiB (-0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 19, 2026
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) perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants

Comments