[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Stop retaining old ModGuts throughout subsequent simplifier phases

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Jan 17 12:45:00 UTC 2024



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
f950f023 by Matthew Pickering at 2024-01-17T07:44:52-05:00
Stop retaining old ModGuts throughout subsequent simplifier phases

Each phase of the simplifier typically rewrites the majority of ModGuts,
so we want to be able to release the old ModGuts as soon as possible.

`name_ppr_ctxt` lives throught the whole optimiser phase and it was
retaining a reference to `ModGuts`, so we were failing to release the
old `ModGuts` until the end of the phase (potentially doubling peak
memory usage for that particular phase).

This was discovered using eras profiling (#24332)

Fixes #24328

- - - - -
9978886d by Matthew Pickering at 2024-01-17T07:44:52-05:00
Update nofib submodule

- - - - -


2 changed files:

- compiler/GHC/Core/Opt/Pipeline.hs
- nofib


Changes:

=====================================
compiler/GHC/Core/Opt/Pipeline.hs
=====================================
@@ -463,11 +463,16 @@ doCorePass pass guts = do
   let fam_envs = (p_fam_env, mg_fam_inst_env guts)
   let updateBinds  f = return $ guts { mg_binds = f (mg_binds guts) }
   let updateBindsM f = f (mg_binds guts) >>= \b' -> return $ guts { mg_binds = b' }
+  -- Important to force this now as name_ppr_ctx lives through an entire phase in
+  -- the optimiser and if it's not forced then the entire previous `ModGuts` will
+  -- be retained until the end of the phase. (See #24328 for more analysis)
+  let !rdr_env = mg_rdr_env guts
   let name_ppr_ctx =
         mkNamePprCtx
           (initPromotionTickContext dflags)
           (hsc_unit_env hsc_env)
-          (mg_rdr_env guts)
+          rdr_env
+
 
   case pass of
     CoreDoSimplify opts       -> {-# SCC "Simplify" #-}


=====================================
nofib
=====================================
@@ -1 +1 @@
-Subproject commit f8213d27fa2aa2a70dca86ae35e3d1e7c5517033
+Subproject commit da7eed00e494aba1da9f51cb92089ca10e2454e7



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/37d6d91d272a2f94fbe65bd7f52fe8e069ca303e...9978886d8236375ab42db8f72847e07e88ec3c55

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/37d6d91d272a2f94fbe65bd7f52fe8e069ca303e...9978886d8236375ab42db8f72847e07e88ec3c55
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240117/422ccc23/attachment-0001.html>


More information about the ghc-commits mailing list