[GHC] #876: Length is not a good consumer

GHC ghc-devs at haskell.org
Sun Dec 11 15:05:09 UTC 2016


#876: Length is not a good consumer
-------------------------------------+-------------------------------------
        Reporter:  ariep@…           |                Owner:
            Type:  bug               |               Status:  new
        Priority:  lowest            |            Milestone:  7.6.2
       Component:  libraries/base    |              Version:  6.5
      Resolution:                    |             Keywords:  length
Operating System:  Linux             |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Runtime           |            Test Case:
  performance bug                    |  perf/should_run/T876
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by nomeata):

 This code, compiled with `-O, does fuse, and allocates nothing (or
 constant amounts)
 {{{#!hs

 module Foo where
 x :: Int -> Int
 x n = length [0..(10^n)::Int]
 }}}

 {{{
 $ ghci -fobject-code -O Foo
 GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Foo              ( Foo.hs, Foo.o )
 Ok, modules loaded: Foo.
 Prelude Foo> :set +s
 Prelude Foo> x 1
 11
 (0.03 secs, 14,976,744 bytes)
 Prelude Foo> x 7
 10000001
 (0.02 secs, 0 bytes)
 Prelude Foo> x 8
 100000001
 (0.04 secs, 0 bytes)
 }}}

 (almost) HEAD:
 {{{
 GHCi, version 8.1.20161117: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Foo              (.hs -> .o)
 WARNING: file compiler/simplCore/SimplCore.hs, line 663
   Simplifier bailing out after 4 iterations [58, 14, 2, 2]
     Size = {terms: 96, types: 32, coercions: 0}
 Ok, modules loaded: Foo (Foo.o).
 Prelude Foo> :set +s
 Prelude Foo> x 1
 11
 (0.19 secs, 94,792 bytes)
 Prelude Foo> x 2
 101
 (0.01 secs, 94,648 bytes)
 Prelude Foo> x 7
 10000001
 (0.01 secs, 98,568 bytes)
 Prelude Foo> x 8
 100000001
 (0.05 secs, 98,448 bytes)
 }}}

 Testing this in with interpreted code is not sufficient, as the optimizer
 does less in that case. So so far, everything seems as expected to me.

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


More information about the ghc-tickets mailing list