Skip to content

Generated Core size blows up from seemingly small change

See main ticket #8095

With the two attached modules (Types.hs Plan.hs)

compiling to Core finishes quickly and the total Core size is reasonable:

$ time ./_build/stage1/bin/ghc -fforce-recomp -fno-code -iinput Memory.Plan -ddump-ds |wc -l
6368

real	0m2.218s
user	0m2.040s
sys	0m0.201s

However, if I change mergeGroup just slightly by uncommenting its alternate definition, i.e. by wrapping the result type in Field:

mergeGroup :: Rel '[CExposureIndex, CSameExposure] -> Field ("BAR" ::: Rel (("TRADESINGROUP" ::: Rel SameExposure_) : AffinityGroupInfo))
mergeGroup r = Field sameExps'
  where
    -- rest unchanged

then suddenly the Core size shoots up:

$ time ./_build/stage1/bin/ghc -fforce-recomp -fno-code -iinput Memory.Plan -ddump-ds |wc -l
489524

real	0m35.156s
user	0m34.467s
sys	0m2.627s

The 76x increase in Core size is coming from lots and lots (and lots and lots and lots...) of types in casts.

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information