[GHC] #9520: Running an action twice uses much more memory than running it once

GHC ghc-devs at haskell.org
Thu Aug 28 14:03:22 UTC 2014


#9520: Running an action twice uses much more memory than running it once
-------------------------------------+-------------------------------------
              Reporter:  snoyberg    |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Compiler    |          Version:  7.8.3
            Resolution:              |         Keywords:
      Operating System:  Linux       |     Architecture:  x86_64 (amd64)
       Type of failure:  Runtime     |       Difficulty:  Unknown
  performance bug                    |       Blocked By:
             Test Case:              |  Related Tickets:
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Well I don't understand `conduit`. But looking at `bad.core` I see:

  * `main3` is called twice (in the RHS of `main1`).  This corresponds to
 the two calls of `action`.

  * So I wonder if there are any values shared between call calls of
 `main3`. These will be top-level CAFs.

  * Aha yes!  `main5` is shared.  But it's fine: it is simply `Done ()`.

  * Aha again! We see
 {{{
 main6 :: Data.Conduit.Internal.Pipe
            Data.ByteString.Internal.ByteString
            Data.ByteString.Internal.ByteString
            Data.Void.Void
            ()
            IO
            Int
 main6 = main9 main8 (main7 `cast` ...)
 }}}
  So if `main6` generates a big data structure, it will be retained across
 both calls.

 Back to you

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


More information about the ghc-tickets mailing list