Add a TaggedQueryKey to identify a query instance#153492
Add a TaggedQueryKey to identify a query instance#153492rust-bors[bot] merged 1 commit intorust-lang:mainfrom
TaggedQueryKey to identify a query instance#153492Conversation
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
If we can get rid of a lot of the QueryStackFrame complexity by just storing the query key in an enum, that seems great. The name |
Yeah, |
This comment has been minimized.
This comment has been minimized.
|
This looks great! I hate the deferred/extra split, this seems like a really clean way to eliminate it. @Zoxc: can you expand the first paragraph of the PR description to explain (a) the current situation, and (b) how this PR changes that situation? I've skimmed the changes and they look good, but I will need to look again more closely on Monday to get my head fully around how the new cc @zetanumbers |
I was thinking of something like I think it's easier to say “this is a key that also indicates what query it came from” than to try to come up with an intuitive name for query+key. Or we could go for something like |
|
|
|
Just a little more work required to get this into shape. @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
QueryKeyId to identify a query instanceTaggedQueryKey to identify a query instance
This comment has been minimized.
This comment has been minimized.
| } | ||
| match self { | ||
| $( | ||
| TaggedQueryKey::$name(key) => inner(key, tcx), |
There was a problem hiding this comment.
Why have inner? Why not just call key.key_as_def_id()... here?
There was a problem hiding this comment.
It reduces code generation as inner can be reused for shared key types.
There was a problem hiding this comment.
Can you add a comment explaining this?
| pub info: I, | ||
|
|
||
| pub struct QueryStackFrame<'tcx> { | ||
| pub id: TaggedQueryKey<'tcx>, |
There was a problem hiding this comment.
This field needs renaming. Maybe tagged_key?
There was a problem hiding this comment.
It is used as an identifier though?
There was a problem hiding this comment.
In the compiler, an “id” is usually an opaque or mostly-opaque integer that indexes into some other table, so I don’t understand the motivation behind calling this value an id.
| query: &'tcx QueryVTable<'tcx, C>, | ||
| tcx: TyCtxt<'tcx>, | ||
| require_complete: bool, | ||
| make_id: fn(C::Key) -> TaggedQueryKey<'tcx>, |
There was a problem hiding this comment.
This parameter needs renaming. Maybe mk_tagged_key?
| vtable: &'tcx QueryVTable<'tcx, C>, | ||
| key: C::Key, | ||
| ) -> QueryStackFrame<QueryStackDeferred<'tcx>> | ||
| make_id: fn(C::Key) -> TaggedQueryKey<'tcx>, |
|
#153685 conflicts a bit as |
|
Would it work to add the enum constructor as a function in QueryVTable? |
|
I think so, but I'd probably prefer reverting the use of |
Add a `TaggedQueryKey` to identify a query instance
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (dfc9e7a): comparison URL. Overall result: no relevant changes - no action neededBenchmarking 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 Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 481.658s -> 479.781s (-0.39%) |
|
Restoring rollup status since perf is neutral. |
|
I'm very close to giving r+, I just want an answer about the reduced queries check, thanks. |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Hooray for getting rid of the deferred/extra frame split! @bors r+ rollup=maybe |
This comment has been minimized.
This comment has been minimized.
Add a `TaggedQueryKey` to identify a query instance This adds back a `TaggedQueryKey` enum which represents a query kind and the associated key. This is used to replace `QueryStackDeferred` and `QueryStackFrameExtra` and the associated lifting operation for cycle errors This approach has a couple of benefits: - We only run description queries when printing the query stack trace in the panic handler - The unsafe code for `QueryStackDeferred` is removed - Cycle handles have access to query keys, which may be handy Some further work could be replacing `QueryStackFrame` with `TaggedQueryKey` as the extra information can be derived from it.
|
💔 Test for 398abb9 failed: CI. Failed job:
|
|
@bors retry |
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
View all comments
This adds back a
TaggedQueryKeyenum which represents a query kind and the associated key. This is used to replaceQueryStackDeferredandQueryStackFrameExtraand the associated lifting operation for cycle errorsThis approach has a couple of benefits:
QueryStackDeferredis removedSome further work could be replacing
QueryStackFramewithTaggedQueryKeyas the extra information can be derived from it.