Subject: Re: Hoopl profiling
From: David Terei <[email-masked]>
To: Simon Peyton Jones <[email-masked]>
Cc: "Edward Z. Yang" <[email-masked]>, Simon Marlow <[email-masked]>
Date: Fri, 18 Mar 2011 23:20:03 +0000

Hmmm my brain has mostly emptied of this stuff but I think there were
two main issues I was looking at:

 - Call conventions use stack passing too much. There was some issue
where the new code gen would basically unify any entry points to
functions by passing the args on the stack. So you'd get some really
bad code where lots of function had extra entry point functions for
them that would copy from the registers to the stack to call the main
function (kind of like slow entry points but unnecessary ones).
Sometimes you'd get really bad call graphs were arguments would be
copied from stack to registers and back to stack or vice-versa. I
think we fixed up some of these issues by implementing the specialised
GC calls but the underlying problem with how calling conventions are
handled remains.

(the above description is probably pretty wrong as its from memory but
should be enough to point Edward in the right direction).

- Death to proc point splitting. We also discussed and I briefly
looked at (but never really had time to make progress on) pushing the
proc point splitting pass down the chain so that it was only done for
the C backend. The NCG would then have much larger functions that
would hopefully be nicer to optimise. What the LLVM backend would do
here is a little tricky. It has basically the same limitations as the
C backend so kind of needs proc point splitting. However the main
benefit of removing proc point splitting is to give LLVM larger
optimisation opportunities so unless a good way alternate way of
handling proc points for the LLVM backend is found I don't know how
useful this work would be. The NCG would probably get no performance
benefit.

I've attached some notes I wrote up while working/thinking about the
proc point splitting stuff. Always been meaning to add them to the
wiki, they're mostly complete and probably mostly already stuff you
know Edward but explain proc point splitting and why it'd be nice to
remove.

One thing in the backend I've been wanting to do but have no time is
to carry around the live stg register information in the Cmm
representation. If I knew when generating LLVM code which stg
registers were live on function entry, function exit and across calls
then I think I could generate significantly better code in many
situation. At some point we should defiantly do this.

Cheers,
David.

On 18 March 2011 04:05, Simon Peyton-Jones <[email-masked]> wrote:
> Edward,
>
> There are three things we need before switching to the new codegen pipeline:
> a) compiled programs work
> b) they run as fast as with the old codegen pipeline
> c) the compiler runs as fast (or nearly so)
>
> I think you have more or less cracked (a).  You are now thinking about (c).  But (b) is important too, perhaps more so than (c).  Just compare the ultimate C-- produced by the old pipeline with that produced by the new one.  David Terei did some of this and found some egregious worsening.  Fixing these will make the new path generate better code.
>
> David: did you put all your work into the tree, or do you have leftover patches?   Do you have any pointers for what you planned to tackle next?
>
> Simon
>
> |  -----Original Message-----
> |  From: Edward Z. Yang [mailto:[email-masked]]
> |  Sent: 17 March 2011 17:54
> |  To: Simon Peyton-Jones
> |  Cc: Simon Marlow
> |  Subject: RE: Hoopl profiling
> |
> |  Thanks!
> |
> |  My current plan of attack is to reduce some of the performance pains seen
> |  in real GHC code into something that I can put into the Hoopl test suite:
> |  right now arfGraph doesn't even show up in the top cost-centers, and it looks
> |  like it's a very specific kind of code that tickles this behavior.
> |
> |  Cheers,
> |  Edward
> |
> |  Excerpts from Simon Peyton-Jones's message of Wed Mar 16 12:38:21 -0400 2011:
> |  > You're more than welcome to hang out here -- but I won't have many cycles that's
> |  all.
> |  >
> |  > S
> |  >
> |  > | -----Original Message-----
> |  > | From: Edward Z. Yang [mailto:[email-masked]]
> |  > | Sent: 16 March 2011 15:40
> |  > | To: Simon Peyton-Jones
> |  > | Cc: Simon Marlow
> |  > | Subject: RE: Hoopl profiling
> |  > |
> |  > | Sure. I can also continue working quasi-independently (as I've been doing
> |  > | during
> |  > | term), which hopefully doesn't take up too much time.
> |  > |
> |  > | Edward
> |  > |
> |  > | Excerpts from Simon Peyton-Jones's message of Wed Mar 16 06:24:40 -0400 2011:
> |  > | > URGH. that's a maximally busy week -- ICFP deadline on 24th, many
> |  > | interviews.  Is there any possibiliity of deferring?
> |  > | >
> |  > | > Simon will be less tied up than me though
> |  > | >
> |  > | > S
> |  > | >
> |  > | > | -----Original Message-----
> |  > | > | From: Edward Z. Yang [mailto:[email-masked]]
> |  > | > | Sent: 16 March 2011 09:47
> |  > | > | To: Simon Peyton-Jones
> |  > | > | Cc: Simon Marlow
> |  > | > | Subject: RE: Hoopl profiling
> |  > | > |
> |  > | > | Excerpts from Simon Peyton-Jones's message of Wed Mar 16 05:24:04 -0400
> |  > | 2011:
> |  > | > | > Can you remind me when you plan to be over here during the vac?  I'm
> |  > | > | totally
> |  > | > | > maxed out with ICFP submissions, and will be until 25th.  Then things
> |  > | ease
> |  > | > | > off -- slightly!
> |  > | > |
> |  > | > | I'm planning on coming in next week (21st). Does that work?
> |  > | > |
> |  > | > | Edward
>
>