[GHC] #8763: forM_ [1..N] does not get fused (allocates 50% more)

GHC ghc-devs at haskell.org
Fri Aug 31 11:59:59 UTC 2018


#8763: forM_ [1..N] does not get fused (allocates 50% more)
-------------------------------------+-------------------------------------
        Reporter:  nh2               |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  7.6.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Runtime           |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #7206             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by sgraf):

 Thanks for the curation, George!

 Now that I spent some time with late lambda lifting and have an
 implementation at hand, I revisited this issue.

 Indeed, the original `$wg` binding from comment:44 gets lifted to top-
 level, but there is no reduction in allocation to be had (it's just
 swapping each mention of the local binding in closures for its single free
 variable, after all) and instructions executed are roughly the same.
 That's because part of the original problem persists: The hot loop `go_up`
 is still not a join point.

 I still think the implementation from comment:60 is the way to go. With
 the improvements to constant folding in Phab:D4605, the mentioned increase
 in closure size should be constant-folded away in the majority of cases.
 I'll conduct some benchmarks next week.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8763#comment:69>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list