poor performance when compiling modules with many Text literals at -O1
(Spawned from #9370; see there for original discussion)
Unpack the xmlhtml package and edit src/Text/XmlHtml/HTML/Meta.hs
and remove the OPTIONS_GHC
line at the top of the file that disables optimizations and build with cabal buidl
. Then GHC takes ~1.5GB and over a minute to build this single module.
Preliminary investigation indicates that Text's fromString and its constituent parts is being inlined repeatedly:
Inlining done: Data.String.fromString
Inlining done: Data.Text.$fIsStringText
Inlining done: Data.Text.pack
Inlining done: Data.Text.Internal.Fusion.unstream
Inlining done: Data.Text.Internal.Fusion.Common.map
Inlining done: Data.Text.Internal.Fusion.Common.streamList
Inlining done: Data.Text.Internal.safe
Inlining done: Data.Bits.$fBitsInt_$c.&.
Inlining done: Data.Text.Internal.Fusion.Types.$WYield
[ repeats ~4000 times ]
resulting in a very large intermediate program:
[ 1 of 10] Compiling Text.XmlHtml.HTML.Meta ( src/Text/XmlHtml/HTML/Meta.hs, dist/build/Text/XmlHtml/HTML/Meta.o )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
Result size of Desugar (after optimization)
= {terms: 26,806, types: 14,467, coercions: 0}
*** Simplifier:
Result size of Simplifier iteration=1
= {terms: 31,052, types: 20,719, coercions: 0}
Result size of Simplifier
= {terms: 31,052, types: 20,719, coercions: 0}
*** Specialise:
Result size of Specialise
= {terms: 32,254, types: 22,696, coercions: 448}
*** Float out(FOS {Lam = Just 0, Consts = True, PAPs = False}):
Result size of Float out(FOS {Lam = Just 0,
Consts = True,
PAPs = False})
= {terms: 63,022, types: 59,045, coercions: 448}
*** Float inwards:
Result size of Float inwards
= {terms: 63,022, types: 59,045, coercions: 448}
*** Simplifier:
Result size of Simplifier iteration=1
= {terms: 28,537, types: 18,902, coercions: 654}
Result size of Simplifier iteration=2
= {terms: 28,157, types: 18,257, coercions: 152}
Result size of Simplifier iteration=3
= {terms: 28,074, types: 18,128, coercions: 140}
Result size of Simplifier iteration=4
= {terms: 28,068, types: 18,096, coercions: 61}
Result size of Simplifier
= {terms: 28,068, types: 18,096, coercions: 61}
*** Simplifier:
Result size of Simplifier iteration=1
= {terms: 43,941, types: 38,325, coercions: 61}
Result size of Simplifier
= {terms: 43,941, types: 38,325, coercions: 61}
*** Simplifier:
Result size of Simplifier iteration=1
= {terms: 689,670, types: 461,960, coercions: 146,725}
...
[Edited: old output was not actually for -O1
as described, but rather for the sequence described in #9370 of building with -O0
after building another module with -O1
.]