Previous iteration of simplifier kept alive throughout next iteration
If we consult this eras profile, which is zoomed in to show one iteration of the simplifier, we can see that the brown band (result of previous iteration), is retained throughout the whole of the next simplifier iteration.
After inspecting this in ghc-debug
this is because the name_ppr_ctx
which is bound at the start of do_core_pass
contains a reference to
the ModGuts
of the previous iteration. Forcing this field access before commencing the iteration leads to an improvement in memory behaviour.
let updateBindsM f = f (mg_binds guts) >>= \b' -> return $ guts { mg_binds = b' }
+ !rdr_env = mg_rdr_env guts
let name_ppr_ctx =
mkNamePprCtx
(initPromotionTickContext dflags)
(hsc_unit_env hsc_env)
- (mg_rdr_env guts)
+ rdr_env
After the change, see the yellow band, is released half-way through the phase.