summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-09-14 15:23:51 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-17 09:44:53 -0400
commit9eff805a622db499be1fda304e11bb3e6c8d37f0 (patch)
tree2e8a604a67cde28ef97dc7bcd87629107560cb19
parent053a5c2c644993274e7779b446170e96e49ab491 (diff)
downloadhaskell-9eff805a622db499be1fda304e11bb3e6c8d37f0.tar.gz
Code Gen: Use strict map rather than lazy map in loop analysis
We were ending up with a big 1GB thunk spike as the `fmap` operation did not force the key values promptly. This fixes the high maximum memory consumption when compiling the mmark package. Compilation is still slow and allocates a lot more than previous releases. Related to #19471
-rw-r--r--compiler/GHC/CmmToAsm/CFG.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/GHC/CmmToAsm/CFG.hs b/compiler/GHC/CmmToAsm/CFG.hs
index 21e35afafe..43c0764bad 100644
--- a/compiler/GHC/CmmToAsm/CFG.hs
+++ b/compiler/GHC/CmmToAsm/CFG.hs
@@ -305,7 +305,9 @@ shortcutWeightMap cuts cfg =
applyMapping m (from, Just to) =
let updatedMap :: CFG
updatedMap
- = fmap (shortcutEdge (from,to)) $
+ -- Careful here to use a strict mapping function, the derived
+ -- Functor instance is lazy and leads to a large thunk build-up. #19471/!6523
+ = mapMap (shortcutEdge (from,to)) $
(mapDelete from m :: CFG )
--Sometimes we can shortcut multiple blocks like so:
-- A -> B -> C -> D -> E => A -> E