Re: Where do I start if I would like help improve GHC compilation times?
after reading a bit and crosschecking what Ben said, it seems the masterplan should be this (happy path scenario):
1. Switch away from a String-centric representation for a Doc (to be abstracted, in theory, via typeclasses). This would ensure we can “jack-in” things like FastString or ByteString into pretty, without breaking encapsulation.
2. (Orthogonal) Remove accidental quadratic complexity in pretty by leveraging special case for infinite band-width case. If I understood correctly this is the scenario we are in when we do the ASM CodeGen phase, where performance matters.
3. We switch from “GHC Pretty” to “Pretty”, making sure nothing is broken in the process. I know there were some patches which were reverted because they caused a memory regression in the compiler. AFAIK the culprit is unclear. Another complication which is unclear to me is what has been mentioned about “diverging laws”. Looks like there was an ambiguous invariant rule and pretty choose one path, GHC.Pretty the other. Reconciliation is unclear to me in this scenario. Something else unclear is how to reconcile the fact TextDetails in GHC.Pretty contains stuff which is performance and GHC-specific. Maybe we should abstract over TextDetails after all, so that we could jack in a TextDetails representation in a Doc. I don’t know if this path has been attempted yet, probably it was. Does anybody have any experience report?
I’m currently (mostly for fun, to quote Edward Kmett “I reserve the right to get bored and do something else which makes money :P :P) trying to tackle 1., but I have seen valiant knights tried this before being killed by the dragon. Oh dear, I guess I will be the next?
Last but not least, sorry for hijacking the original spirit of this email (although it’s always perf-related), but throwing my ramblining into those already-packed GHC trac tickets seemed overkill. I have the feeling (not just a feeling) that this has been discussed and explained over and over to new freshmen trying to venture into GHC outlands, so it must be frustrating for you guys to write that down for the 1000+1 time. A big THANK YOU to put up with yet another young apprentice ;)