Streamline QueryVTableUnerased into QueryVTableGetter#152841
Streamline QueryVTableUnerased into QueryVTableGetter#152841Zalathar wants to merge 1 commit intorust-lang:mainfrom
QueryVTableUnerased into QueryVTableGetter#152841Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Streamline `QueryVTableUnerased` into `QueryVTableGetter`
|
| /// Marker type that implements [`QueryVTableGetter`] for this query. | ||
| pub(crate) enum VTableGetter {} | ||
|
|
||
| impl<'tcx> QueryVTableGetter<'tcx, FLAGS> for VTableGetter { |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
... or SemiStatic, because it's still mostly dynamic :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (b46d288): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking 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 @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary 2.2%, secondary 9.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 481.318s -> 480.997s (-0.07%) |
QueryDispatcherUnerasedis 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
QueryVTableGettertrait to slightly simplify two of the functions inDepKindVTable.