Skip to content

Extremely slow macro expansion #43704

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

Closed
mikebenfield opened this issue Aug 6, 2017 · 2 comments
Closed

Extremely slow macro expansion #43704

mikebenfield opened this issue Aug 6, 2017 · 2 comments
Labels
I-compilemem Issue: Problems and improvements with respect to memory usage during compilation.

Comments

@mikebenfield
Copy link
Contributor

See this gist.

Here is a chart giving real time output from time rustc main.rs -o out with n of the lines of the form [0xDD, 0xCB, d, 0x00 ] uncommented.

n sec
100 0.561
200 1.457
300 3.042
400 5.474
500 8.061
600 12.364
700 17.520
800 25.105
900 37.410
1000 48.006
1100 72.33

With this gist I've tried to create a fairly minimal example. It's not as minimal as maybe it could be because it's a little tricky to figure out what's causing the slow compiles and I've spent as much time as I can on this right now. It's very sensitive to seemingly irrelevant changes in the code. If I remove the unused count variable, compile times dramatically improve. If I remove the empty for loop, compile times dramatically improve.

On my actual project, I am getting compile times in excess of 20 minutes. To compile a few thousand lines of code.

@arielb1 arielb1 added I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-nominated labels Aug 7, 2017
@arielb1
Copy link
Contributor

arielb1 commented Aug 7, 2017

cc @jseyfried

@arielb1
Copy link
Contributor

arielb1 commented Aug 7, 2017

Umm this is not an expansion problem but rather a borrowck problem - dataflow somehow takes O(n) iterations to converge.

arielb1 added a commit to arielb1/rust that referenced this issue Aug 7, 2017
We used to propagate bits in node-id order, which sometimes caused an
excessive number of iterations, especially when macros were present. As
everyone knows, visiting the CFG in RPO bounds the number of iterators
by 1 plus the depth of the most deeply nested loop (times the height of
the lattice, which is 1).

Fixes rust-lang#43704.
bors added a commit that referenced this issue Aug 7, 2017
rustc::middle::dataflow - visit the CFG in RPO

We used to propagate bits in node-id order, which sometimes caused an
excessive number of iterations, especially when macros were present. As
everyone knows, visiting the CFG in RPO bounds the number of iterators
by 1 plus the depth of the most deeply nested loop (times the height of
the lattice, which is 1).

I have no idea how this affects borrowck perf in the non-worst-case, so it's probably a good idea to not roll this up so we can see the effects.

Fixes #43704.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-compilemem Issue: Problems and improvements with respect to memory usage during compilation.
Projects
None yet
Development

No branches or pull requests

2 participants