Quite slow compiler for minimalistic megaparsec program
Summary
Running the attached program takes 50 seconds and generates the following (excerpt) output:
*** Simplifier [Parser]:
Result size of Simplifier iteration=1
= {terms: 6,437, types: 9,533, coercions: 2,406, joins: 155/156}
Result size of Simplifier
= {terms: 6,437, types: 9,533, coercions: 2,406, joins: 155/156}
!!! Simplifier [Parser]: finished in 62.17 milliseconds, allocated 64.436 megabytes
*** SpecConstr [Parser]:
Result size of SpecConstr
= {terms: 4,983,174,
types: 7,695,406,
coercions: 516,358,
joins: 148,738/148,739}
!!! SpecConstr [Parser]: finished in 12639.92 milliseconds, allocated 10112.995 megabytes
*** Common sub-expression [Parser]:
Result size of Common sub-expression
= {terms: 4,983,166,
types: 7,695,406,
coercions: 516,358,
joins: 148,738/148,739}
!!! Common sub-expression [Parser]: finished in 8047.22 milliseconds, allocated 5435.298 megabytes
*** Simplifier [Parser]:
Result size of Simplifier iteration=1
= {terms: 4,972,599,
types: 7,677,397,
coercions: 516,358,
joins: 146,810/146,811}
Result size of Simplifier iteration=2
= {terms: 6,479, types: 9,613, coercions: 2,406, joins: 154/155}
Result size of Simplifier
= {terms: 6,479, types: 9,613, coercions: 2,406, joins: 154/155}
!!! Simplifier [Parser]: finished in 28179.37 milliseconds, allocated 24669.036 megabytes
*** Demand analysis [Parser]:
The justification for such a code style is having some large data Enum = EA | EB | EC ...
and then some enum = asum [ EA <$ string "a", EB <$ string "b", EC <$ string "c" ...]
Steps to reproduce
Install megaparsec Compile provided program
The length of the list to asum appears to be relevant to the performance. If you increase the length of the list by one, compiler performance goes back to normal, and if you decrease the length of the list it roughly linearly improves compiler performance.
Environment
- GHC version used: 8.6.4
Optional:
- Operating System: nixos
- System Architecture: x86_64