Skip to content

Remove duplication of `IfaceTyConInfo` when writing bytecode to .hi files

In heap analysis, we noticed there is a high amount of duplication of IfaceTyConInfo constructors when we persist mi_extra_decls to the respective ModIface. Note, this duplication only occurs when you write mi_extra_decls to the interface files.

On the agda codebase, with a ghc compiled with --flavour=perf+ipe, we gathered the following numbers with ghc-debug (census2LevelClosureType):

key; total; count; max; avg
ghc-9.9-inplace:GHC.Iface.Type:IfaceTyCon[ghc-9.9-inplace:GHC.Types.Name:Name,ghc-9.9-inplace:GHC.Iface.Type:IfaceTyConInfo]:206635176:8609799:24:24.0
ghc-9.9-inplace:GHC.Iface.Type:IfaceTyConInfo[ghc-9.9-inplace:Language.Haskell.Syntax.Type:NotPromoted,ghc-9.9-inplace:GHC.Iface.Type:IfaceNormalTyCon];141466584;5894441;24;24.0
ghc-9.9-inplace:GHC.Iface.Type:IfaceTyConInfo[ghc-9.9-inplace:Language.Haskell.Syntax.Type:IsPromoted,ghc-9.9-inplace:GHC.Iface.Type:IfaceNormalTyCon];64949568;2706232;24;24.0

We omitted several other lines to focus on the duplication of IfaceTyConInfo.

There are 5894441 occurrences of IfaceTyConInfo NotPromoted IfaceNormalTyCon and 2706232 instances of IfaceTyConInfo IsPromoted IfaceNormalTyCon, resulting in an 200MB overhead.

Note, this duplication does not occur if the mi_extra_decls are read from ModIface. However, in #24516 (closed), we identify a different issue with IfaceTyConInfo.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information