I tried making pipelining more aggressive, by moving metadata generation from after analysis (typeck, borrowck, etc.) to before analysis. This increases the amount of overlap possible. It's basically working (only 3 tests fail in the entire rustc test suite, not sure why yet), but the performance results are disappointing: https://paste.mozilla.org/0qBZWYjv
That shows the effect of the existing pipelining, which has some big speedups like 1.79x, 1.39x, 1.38x, 1.17x.
It also shows the effect of the more aggressive pipelining, which has much smaller speedups like 1.06x, 1.04x, 1.02x (and the 1.02x is probably indistinguishable from noise)
I guess in hindsight it's not that surprising; code generation takes a lot longer than analysis
Also, the more aggressive pipelining slows down some workflows slightly -- the production of type/borrow/other errors is slightly delayed by metadata generation. And that's a common workflow -- think about when you're repeatedly compiling code when working through errors.
So I think it's probably not worthwhile pursuing further, overall.
Did you measure how much time was spent doing analysis after metadata generation? I'd expect metadata generation to basically trigger all of it.
I rearranged things so that metadata generation finished before analysis started. This was non-trivial, given the way the passes are arranged.
I have filed #64112 so others can see the code and results.
@Alex Crichton ^^^ (in case you haven't already seen it)
Hm interesting! It may also be the case that the meteadata generation ends up needing all of the analysis anyway, so moving it back may not actually skip any stages of compilation before it's generated
@nnethercote it may be worth looking into optimizing metadata at some point
IIRC it's pretty quick but still like megabyte big for a kilobyte crate
so we're probably taking too long to emit it and/or storing way too much in there in one form or another
+1 this would also help with distributed builds-- sending metadata elsewhere is slow today
Just FYI, I'd like to remove metadata and just rely on stored queries instead. We currently store a lot of information in both metadata and the query cache, which is not very efficient.
@Alex Crichton I used debugging println statements to verify that metadata generation completes before analysis. It's possible I'm missing some subtlety, but the basic contours seem correct, and the results suggest that things really have changed to some degree.
@Alex Crichton What are the filenames for metadata? .rmeta?
and rustc has tons of caches internally
so the time previously spent in analysis may just be shifted to metadata generation now
and the analysis phase, which happens later, just hits all the caches and doesn't actually do anything
right, that's the subtleties/contours I was referring to
just random guess as to why it may not help much
codegen does take like 10x longer than analysis
heh that too!