summaryrefslogtreecommitdiff
path: root/compiler/GHC.hs
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2021-10-15 10:38:23 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-19 03:30:52 -0400
commit7271bf78a9ffd865e590f1ce3f3ae975f5dc1a49 (patch)
tree4c1eb9dbf7c3698f4462ae9fa7d7ac13ef89eb9e /compiler/GHC.hs
parent753b921da52c0b7da21856c5fe0bf4604505c7b3 (diff)
downloadhaskell-7271bf78a9ffd865e590f1ce3f3ae975f5dc1a49.tar.gz
InteractiveContext: Smarter caching when rebuilding the ic_rn_gbl_env
The GlobalRdrEnv of a GHCI session changes in odd ways: New bindings are not just added "to the end", but also "in the middle", namely when changing the set of imports: These are treated as if they happened before all bindings from the prompt, even those that happened earlier. Previously, this meant that the `ic_rn_gbl_env` is recalculated from the `ic_tythings`. But this wasteful if `ic_tythings` has many entries that define the same unqualified name. By separately keeping track of a `GlobalRdrEnv` of all the locally defined things we can speed this operation up significantly. This change improves `T14052Type` by 60% (It used to be 70%, but it looks that !6723 already reaped some of the rewards). But more importantly, it hopefully unblocks #20455, becaues with this smarter caching, the change needed to fix that issue will no longer make `T14052` explode. I hope. It does regress `T14052` by 30%; caching isn’t free. Oh well. Metric Decrease: T14052Type Metric Increase: T14052
Diffstat (limited to 'compiler/GHC.hs')
-rw-r--r--compiler/GHC.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs
index ad584905a4..2074cd1054 100644
--- a/compiler/GHC.hs
+++ b/compiler/GHC.hs
@@ -1469,7 +1469,7 @@ findGlobalAnns deserialize target = withSession $ \hsc_env -> do
-- | get the GlobalRdrEnv for a session
getGRE :: GhcMonad m => m GlobalRdrEnv
-getGRE = withSession $ \hsc_env-> return $ ic_rn_gbl_env (hsc_IC hsc_env)
+getGRE = withSession $ \hsc_env-> return $ icReaderEnv (hsc_IC hsc_env)
-- | Retrieve all type and family instances in the environment, indexed
-- by 'Name'. Each name's lists will contain every instance in which that name