-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Extract queries for the trait system operations that are performed in trans #44891
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I'd like to take a shot at this if that's ok. |
@wesleywiser definitely! Feel free to reach out on gitter if you have any questions along the way. You can also leave comments here, but I have a hard time keeping up with GH notifications, so that can sometimes lead to a long lag in getting a reply. =) |
Oh one other thing. There is no reason to do this all at once. In particular, it would be fine to open a PR that just tackles |
Thanks! I'll definitely work on |
I'm working on the first part of creating a query for
(Full error here) |
Copying from gitter to make sure you see it:
|
I would like to work on turning |
I'm working on |
Oh, I #45137 does the |
…tsakis Turn `trans_fulfill_obligation` into a query Part of #44891
Create NormalizeTy query As part of the effort to solve #44891, I've created the normalize_ty query. As outlined in the issue this meant: - renamed `normalize_associated_type()` to `normalize_associated_type_in()` - created the `normalize_ty` query - substituted the use of memoize with the query This PR is not ready. While running tests, one of the incremental ones failed. [This](https://pastebin.com/vGhH6bv6) is the error I got.
I've query-ifed |
Sure, go ahead! Thanks, @BurntPizza! |
Make normalize_and_test_predicates into a query From #44891. I'm not real solid on how `dep_graph` stuff works, but if a node is going to have a key (again, not sure how important that is), then the key needs to be `Copy`. So since `normalize_and_test_predicates` only had one out-of-module use, I changed that call site to use a new function, `substitute_normalize_and_test_predicates` which is the query and enables having the arguments be `Copy`. Hopefully this makes sense. r? @nikomatsakis and/or @michaelwoerister
I feel like this "got done" enough to close this general issue. |
Currently, there are a number of trait system operations that are used by the code in trans. Currently, they are invoked directly, and behind the scenes they use a
DepTrackingMap
to memoize across multiple calls. It would be better for incremental if they were converted into named queries. Effectively the goal is to remove thetrans_trait_caches
field of the tcx. For these particular operations, since they do not work on types that include inference variables, this should be fairly straight-forward:trans_fulfill_obligation
, defined here, which immediately invokes thememoize
function here.The idea would to take the following steps:
trans_fulfill_obligation
.Ty<'tcx>
type is.fn trans_fulfill_obligation
from a method (as it is currently defined) into a free-standing function that serves as a provider. You can just remove the call tomemoize
, which would no longer be needed.specialization_graph_of
query).normalize_associated_type()
tonormalize_associated_type_in()
. This method is defined here. It only has a handful of callers (as you can see with a quickrg \.normalize_associated_type\(
).normalize_ty(Ty<'tcx>) -> Ty<'tcx>
that simply invokesnormalize_associated_types_in
. This is basically that function in query form, but specialized to inputs of typeTy<'tcx>
.memoize()
) with code that just invokes the queryself.tcx.normalize_ty(ty)
.For bonus points, we might consider converting the following functions into queries. It seems like they could benefit from caching:
traits::get_vtable_methods
(definition)traits::normalize_and_test_predicates
trans_normalize
trans_apply_param_substs
It's unclear though if this is a good idea. I'd keep those for a later PR so we can do some experiments with performance and memory use.
The text was updated successfully, but these errors were encountered: