-
Notifications
You must be signed in to change notification settings - Fork 37
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
Memory leak when compiling Data.Singletons.Prelude.List with match flattening #96
Comments
As expected, with |
I think something is confused here. It's Data.Singletons.Prelude.List that takes forever, not Data.Promotion.Prelude.List. And, I'm pretty sure it's the high-arity |
(This problem started when I moved a ton of functions from promotion-only to singletonizing, allowed now because of the work on #30.) |
Yes, I meant
My guess was that this is related to #30 but my hypothesis was that this was due to changes in desugaring. But you may be right that this is caused by zips. I'll investigate. |
I have just been bitten by this one again. This time - in conjunction with #10228 - I was unable to compile A not-so-proper solution would be to: a) extract zips into a separate module; b) disable optimisations both for that module and Richard, your thoughts? |
I think the workaround you suggest is appropriate for singletons, but we should also isolate this problem in a way that we can report it to GHC. If the zips are the problem, is it possible to collect statistics based on the arity of the zip? For example, what growth function do you see as you increase the arity of the zip? The fact that optimizations matter tells me that it's not typechecking that's holding us up. What does the core look like (with |
Optimisations matter but even without them the situation does not look too good. For now I extracted zips into a separate module and disabled optimisations - travis build no loner stalls under GHC 7.10. Will investigate further. |
I measured compile times with GHC 7.10 and size of generated Core for
With Sizes of generated Core are at least quadratic, possibly cubic, but they are not exponential:
Clearly much of the fault for long compile times is on our side. But still GHC performs worse than it used to. Next: same measurements using GHC 7.8.4 |
I did the measurements for GHC 7.8.4 and the results are not at all what I expected. Compile times (in seconds):
Core size (in bytes):
Compile times as slightly shorter for GHC 7.8.4. The difference is barely noticeable but seems consistent. Size of generated Core is larger for GHC 7.8.4 but I think the reason is that pretty-printer in 7.10 is less verbose, eg. it prints Not sure what to do next. My hypothesis at the moment is that GHC 7.10 allocates more memory and that causes a noticeable slowdown when compiling our large modules (it might be causing swap usage or increase GC activity). I thought about measuring that by passing
I think we should look at total bytes allocated, total memory in use and time spent in GC. Thoughts? |
Some more numbers:
I can't make any sense of them - it seems that 7.10 is doing better than 7.8... In all cases productivity is very poor. |
As another tests I checked how much call arity analysis affects compilation time. I compiled Zips module using GHC 7.10.1 with |
Now that match flattening is reverted the problem is gone. Closing in favour of #96. |
Just to clarify a few points made above:
I'm going to reopen this ticket to continue to track progress, but only in the version with match flattening. The problem described here is an important part of #113, but not necessarily the only part of #113, so it's worth having a separate ticket. |
I just compiled latest singletons and compiling
Data.Singletons.Prelude.List
allocated 1.5GB of RAM (and took ~20 minutes on my old machine). Did this use to happen?Based on my experience I guess that adding
-O0
will fix the issue. Alternatively, we could try to have smaller splices and see if this changes anything.The text was updated successfully, but these errors were encountered: