-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Compilation time blows up with huge, numerous and nested enums #42747
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
Comments
First, if you have a big nested series of However, that should not cause any blowups in item-types checking! item-types checking should not be aware of the layout of your types, so that certainly looks like a bug I was not able to reproduce the bug - the code you linked to seems to have the boxes in place already, and I was not able to cause slowness by removing boxes myself. Could you post a version of the code that exhibits the bug? |
@arielb1 it happens to me with this version https://github.com/phaazon/glsl/blob/77686623da59895e82083955957dfdc0ae11f130/src/syntax.rs |
I had a quick look with Instruments on macOS and it seems that most of the time is spend in a somewhat deeply nested call to |
I've seen that function hot on the rustc profiles too. Now that I have an excuse, let's go around fixing it. |
Yep, the version linked by @lqd is the one to blame (I fixed my code with boxes and forgot I didn’t provide a link via the commit hash – sorry!). |
I could have made representability a cached query, but that would have been added complexity for not much benefit - outside of the exponential worst-case, this pass is fast enough already. Fixes rust-lang#42747.
Uh oh!
There was an error while loading. Please reload this page.
I’m building a GLSL parser and hence have a very specific need for numerous, deeply nested enums. I added all the grammar symbols / tokens, and now the compilation takes more 20 minutes on my rustc 1.19.0-nightly (78d8416 2017-06-17), Mac OSX. The compilation passes point at the
item-types checking
pass – it takes roughly 5 minutes here – as being the bottleneck. The code can be found here.Important note: I think that the problem is linked to all the numerous recursive enums. I guess rustc struggles to identify the size or whatever about the enums because it tries to see whether recursions are terminal? Thing is: I tried to box almost all variants, and the result is there: I reduced the compilation time from 20 minutes to a few seconds.
The text was updated successfully, but these errors were encountered: