[Haskell-cafe] Where do I start if I would like help improve GHC compilation times?

Alfredo Di Napoli alfredo.dinapoli at gmail.com
Wed Apr 19 06:53:41 UTC 2017


Hey all,

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?

4. Profit?

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 ;)

Alfredo

On 18 April 2017 at 20:14, Johannes Waldmann <
johannes.waldmann at htwk-leipzig.de> wrote:

> > it would be quite helpful if `pretty`
> > gained a special-case for the infinite band-width case
>
> Absolutely +1 this.
>
> Not "pretty" but similar:
> https://github.com/jwaldmann/wl-pprint-text/commit/
> 7843d96db57ab01c0be336a5be0d7bca61902005
>
> - J.W.
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170419/d1b31dfe/attachment.html>


More information about the Haskell-Cafe mailing list