[GHC] #12629: Worse performance with -O1 or -O2 due to GC cost

GHC ghc-devs at haskell.org
Tue Sep 27 02:35:44 UTC 2016


#12629: Worse performance with -O1 or -O2 due to GC cost
-------------------------------------+-------------------------------------
        Reporter:  onex              |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by onex:

@@ -2,0 +2,2 @@
+ n = 11
+
@@ -8,1 +10,1 @@
-     print $ length $ f [1..12]
+     print $ length $ f [1..n]

New description:

 {{{#!hs
 n = 11

 g a = replicate (n-a) (a+1)

 f [x] = [[x]]
 f list = [ a:b | a <- list, b <- f $ g a]

 main = do
     print $ length $ f [1..n]
 }}}

 The function ''g'' can be replaced by any ''a -> [a]'' function.

 Without optimization:
 {{{
   94,885,791,728 bytes allocated in the heap
      280,050,384 bytes copied during GC
           62,432 bytes maximum residency (18 sample(s))
           27,144 bytes maximum slop
                2 MB total memory in use (0 MB lost due to fragmentation)

                                      Tot time (elapsed)  Avg pause  Max
 pause
   Gen  0     182071 colls,     0 par    0.437s   0.442s     0.0000s
 0.0004s
   Gen  1        18 colls,     0 par    0.000s   0.002s     0.0001s
 0.0004s

   INIT    time    0.000s  (  0.002s elapsed)
   MUT     time   14.992s  ( 15.188s elapsed)
   GC      time    0.437s  (  0.444s elapsed)
   RP      time    0.000s  (  0.000s elapsed)
   PROF    time    0.000s  (  0.000s elapsed)
   EXIT    time    0.000s  (  0.000s elapsed)
   Total   time   15.428s  ( 15.634s elapsed)

   %GC     time       2.8%  (2.8% elapsed)

   Alloc rate    6,329,223,264 bytes per MUT second

   Productivity  97.2% of total user, 95.9% of total elapsed
 }}}

 With -O2:
 {{{
   86,218,852,592 bytes allocated in the heap
   13,323,597,456 bytes copied during GC
           62,712 bytes maximum residency (12895 sample(s))
           47,104 bytes maximum slop
                2 MB total memory in use (0 MB lost due to fragmentation)

                                      Tot time (elapsed)  Avg pause  Max
 pause
   Gen  0     154129 colls,     0 par    6.724s   6.685s     0.0000s
 0.0015s
   Gen  1     12895 colls,     0 par    0.484s   0.479s     0.0000s
 0.0004s

   INIT    time    0.000s  (  0.001s elapsed)
   MUT     time   12.714s  ( 13.002s elapsed)
   GC      time    7.207s  (  7.164s elapsed)
   RP      time    0.000s  (  0.000s elapsed)
   PROF    time    0.000s  (  0.000s elapsed)
   EXIT    time    0.000s  (  0.000s elapsed)
   Total   time   19.921s  ( 20.167s elapsed)

   %GC     time      36.2%  (35.5% elapsed)

   Alloc rate    6,781,366,989 bytes per MUT second

   Productivity  63.8% of total user, 63.0% of total elapsed
 }}}

 System:Windows/macOS
 Compiler:8.0.1/7.10.3

--

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


More information about the ghc-tickets mailing list