Skip to content

InteractiveContext: Smarter caching when rebuilding the ic_rn_gbl_env

Joachim Breitner requested to merge wip/joachim/cache-ic-env into master

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 (merged) already reaped some of the rewards). But more importantly, it hopefully unblocks #20455 (closed), 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

Edited by Joachim Breitner

Merge request reports