-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seemingly pathological behavior in typechecking, item collecting, and trans #33594
Comments
Yes, that definitely looks excessive. Thanks for the report! |
Reduced test case: extern crate futures;
use futures::*;
fn main() {
let a: Box<Future<Item=i32, Error=()>> = loop {};
a
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t)
.map(|t| t);
} |
I believe this is the same issue as in #22204 and #31849. @nikomatsakis did an attempt at adding a cache for projections in #32287 but there were some issues with higher ranked lifetimes. |
@dotdash that test case seems to stress the pathological performance in "item-bodies checking", but it didn't seem to reproduce the massive amount of time in trans (particularly the item collector). Perhaps that's same as #22204 which @Marwes points out, but there may be something else lurking? @Marwes yeah I'd believe that the typechecking performance cliff is related to that, but that's only about 15% of the original test's compile time, the remaining parts were all in trans. |
@alexcrichton I think that the difference is just that trans hits the bad code path less often with this variant, not that there's actually a problem in trans. The profile you provided kind of supports that idea as well. |
@alexcrichton Hmm, I think I got the times of the chained iterator example mixed up with the times I get for compiling the parser for embed_lang which definitely is slow due to the lack of cached projection types.
|
wat! |
@michaelwoerister Sorry I wasn't clear enough! That was for compiling embed_lang's parser ( |
So for reference I tried Alex's future stuff with my projection cache and it made type-checking basically free, as well as lowering the cost of everything else substantially -- but trans and friends remained fairly expensive. I don't have the measurements anymore unfortunately. I hope to be landing the projection cache soon-ish, have to close up the unsoundness that the cache revealed first. |
@nikomatsakis - if you want I can also try it in the crates timing thing I was working on with Alex. |
Note that the projection cache landed. So type-checking should be faster, if not the backend. More work is needed there -- this may be because the projection cache is tied to an inference context, and we make a fresh one each time in trans, but there may be other factors. |
I think this is the same issue as #38528, so closing in favor of that. |
In working on a prototype futures library I've played around a bit with a small example program. Unfortunately this 20-line function has a 12 second compile time in debug mode. Looking at
-Z time-passes
, the worst offenders are:Some interesting data points
FWIW, the
perf record
of this compile looks like the hottest functions are (those above 1%):We seem to be hashing... a lot!
The text was updated successfully, but these errors were encountered: