[GHC] #9344: takeWhile does not participate in list fusion

GHC ghc-devs at haskell.org
Tue Jul 22 07:29:49 UTC 2014


#9344: takeWhile does not participate in list fusion
-------------------------------------+-------------------------------------
              Reporter:  dfeuer      |             Owner:
                  Type:  bug         |            Status:  new
              Priority:  normal      |         Milestone:
             Component:              |           Version:  7.8.3
  libraries/base                     |          Keywords:
            Resolution:              |  Operating System:  Unknown/Multiple
Differential Revisions:              |   Type of failure:  Runtime
          Architecture:              |  performance bug
  Unknown/Multiple                   |         Test Case:
            Difficulty:  Unknown     |          Blocking:
            Blocked By:              |
       Related Tickets:              |
-------------------------------------+-------------------------------------

Comment (by dfeuer):

 I wouldn't call it "failing" so much as "incomplete success". I haven't
 investigated in detail, and may not be good enough with Core to figure it
 out anyway. The simple example
 {{{
 #!haskell
 print $ length $ takeWhileFB (<10000000) [1..20000000]
 }}}
 allocates virtually nothing. The more complex example
 {{{
 #!haskell
 print $ length $ filter (\x->x `rem` 3 == 0) $
   takeWhileFB (<10000000) $ filter even [1..20000000]
 }}}
 allocates a substantial amount, but only something like a third of what
 `Prelude.takeWhile` does. I haven't attempted any benchmarking, and I'm
 too tired right now to look into those test cases. As for speed, if I'm
 not very much mistaken it takes a lot of slowness and/or a good number of
 mispredicted branches to make up for the cache effects that excessive
 allocation will have when combined with non-trivial code, so I believe
 that should probably be a secondary concern.

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


More information about the ghc-tickets mailing list