[GHC] #14928: TH eats 50 GB memory when creating ADT with multiple constructors

GHC ghc-devs at haskell.org
Sat Jun 9 13:12:02 UTC 2018


#14928: TH eats 50 GB memory when creating ADT with multiple constructors
-------------------------------------+-------------------------------------
        Reporter:  YitzGale          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Template Haskell  |              Version:  8.2.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  performance bug                    |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by bgamari):

 The biggest allocator while compiling this program with `-O0` appears to
 be CodeGen:
 {{{
 !!! Renamer/typechecker [Foundation]: finished in 22503.88 milliseconds,
 allocated 2682.425 megabytes
 !!! Desugar [Foundation]: finished in 396.31 milliseconds, allocated
 647.120 megabytes
 !!! Simplifier [Foundation]: finished in 485.76 milliseconds, allocated
 675.006 megabytes
 !!! CoreTidy [Foundation]: finished in 45.90 milliseconds, allocated
 88.678 megabytes
 !!! CorePrep [Foundation]: finished in 168.78 milliseconds, allocated
 252.445 megabytes
 !!! CodeGen [Foundation]: finished in 17228.95 milliseconds, allocated
 24917.560 megabytes
 }}}

 In particular, we spend a significant amount of time in register
 allocation and producing assembler.
 {{{
 COST CENTRE         MODULE      SRC
 %time %alloc

 hscCompileCoreExpr' HscMain
 compiler/main/HscMain.hs:(1805,1)-(1827,24)          63.6    0.1
 pprNativeCode       AsmCodeGen
 compiler/nativeGen/AsmCodeGen.hs:(529,37)-(530,65)    5.5   18.5
 RegAlloc-linear     AsmCodeGen
 compiler/nativeGen/AsmCodeGen.hs:(658,27)-(660,55)    4.2   12.5
 regLiveness         AsmCodeGen
 compiler/nativeGen/AsmCodeGen.hs:(591,17)-(593,52)    3.5   10.1
 tc_rn_src_decls     TcRnDriver
 compiler/typecheck/TcRnDriver.hs:(491,4)-(555,7)      2.8    8.0
 StgCmm              HscMain
 compiler/main/HscMain.hs:(1463,13)-(1464,62)          2.7    7.8
 genMachCode         AsmCodeGen
 compiler/nativeGen/AsmCodeGen.hs:(580,17)-(582,62)    2.4    6.6
 NativeCodeGen       CodeOutput  compiler/main/CodeOutput.hs:166:18-78
 1.8    4.0
 layoutStack         CmmPipeline
 compiler/cmm/CmmPipeline.hs:(98,13)-(100,40)          1.6    4.3
 fixStgRegisters     AsmCodeGen  compiler/nativeGen/AsmCodeGen.hs:566:17-42
 1.3    1.2
 cmmToCmm            AsmCodeGen  compiler/nativeGen/AsmCodeGen.hs:571:17-50
 1.0    2.4
 sequenceBlocks      AsmCodeGen  compiler/nativeGen/AsmCodeGen.hs:699:17-49
 0.8    1.7
 doSRTs              CmmPipeline compiler/cmm/CmmPipeline.hs:47:46-71
 0.6    1.1
 Digraph.scc         Digraph     compiler/utils/Digraph.hs:277:44-67
 0.5    2.2
 cmmCfgOpts(1)       CmmPipeline compiler/cmm/CmmPipeline.hs:64:13-62
 0.5    1.6
 revPostorder        CmmUtils    compiler/cmm/CmmUtils.hs:561:5-47
 0.5    1.0
 deSugar             HscMain     compiler/main/HscMain.hs:544:7-44
 0.4    1.4
 simplExprF1-App     Simplify
 compiler/simplCore/Simplify.hs:(866,34)-(883,62)      0.3    1.3
 occAnalBind.assoc   OccurAnal   compiler/simplCore/OccurAnal.hs:819:13-60
 0.3    1.1
 }}}

 Compiling with `-O1` tells a very similar story; each simplifier pass only
 allocates a gigabyte or two, with codegen allocating several tens of GB.

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


More information about the ghc-tickets mailing list