[Git][ghc/ghc][wip/fendor/iface-sharing] 6 commits: Add deduplication table for `IfaceType`

Hannes Siebenhandl (@fendor) gitlab at gitlab.haskell.org
Mon Apr 15 09:58:30 UTC 2024



Hannes Siebenhandl pushed to branch wip/fendor/iface-sharing at Glasgow Haskell Compiler / GHC


Commits:
03084bcc by Matthew Pickering at 2024-04-15T11:52:42+02:00
Add deduplication table for `IfaceType`

The type `IfaceType` is a highly redundant, tree-like data structure.
While benchmarking, we realised that the high redundancy of `IfaceType`
causes high memory consumption in GHCi sessions.
We fix this by adding a deduplication table to the serialisation of
`ModIface`, similar to how we deduplicate `Name`s and `FastString`s.
When reading the interface file back, the table allows us to automatically
share identical values of `IfaceType`.

This deduplication has the beneficial side effect to additionally reduce
the size of the on-disk interface files tremendously. On the agda code
base, we reduce the size from 28 MB to 16 MB. When `-fwrite-simplified-core`
is enabled, we reduce the size from 112 MB to 22 MB.

We have to add an `Ord` instance to `IfaceType` in order to store it
efficiently for look up operations. This is mostly straightforward, we
change occurrences of `FastString` with `LexicalFastString` and add a
newtype definition for `IfLclName = LexicalFastString`.

We also add IfaceType deduplication table to .hie serialisation and
refactor .hie file serialisation to use the same infrastrucutre as
`putWithTables`.

Bump haddock submodule for `IfLclName` newtype changes.

- - - - -
d64cfe21 by Matthew Pickering at 2024-04-15T11:54:14+02:00
Add some tests to check for size of interface files when serialising
various types

- - - - -
5610aa86 by Matthew Pickering at 2024-04-15T11:54:14+02:00
WIP: TrieMap for IfaceType

Bump haddock submodule

- - - - -
2a19c5c5 by Fendor at 2024-04-15T11:54:15+02:00
WIP: CI results for Data.Map deduplication

- - - - -
292f6f81 by Matthew Pickering at 2024-04-15T11:54:15+02:00
Only share IfaceTyConApp

- - - - -
c5077818 by Fendor at 2024-04-15T11:56:54+02:00
Share duplicated values in ModIface after generation

This helps keeping down the peak memory usage while compiling in
`--make` mode.

- - - - -


30 changed files:

- compiler/GHC/Core/Map/Expr.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Data/TrieMap.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Iface/Binary.hs
- compiler/GHC/Iface/Decl.hs
- compiler/GHC/Iface/Env.hs
- compiler/GHC/Iface/Ext/Binary.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Iface/Make.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Recomp/Binary.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Type.hs
- + compiler/GHC/Iface/Type/Map.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Stg/CSE.hs
- compiler/GHC/StgToJS/Object.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Var.hs
- compiler/GHC/Utils/Binary.hs
- compiler/Language/Haskell/Syntax/Type.hs
- compiler/Language/Haskell/Syntax/Type.hs-boot
- compiler/ghc.cabal.in
- + testsuite/tests/iface/IfaceSharingFastString.hs
- + testsuite/tests/iface/IfaceSharingIfaceType.hs
- + testsuite/tests/iface/IfaceSharingName.hs
- + testsuite/tests/iface/Lib.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f44fa5e4f8e7d98f8192c164a6dc4f24b3f19cdf...c5077818d5893f5ab5e58bd06306faa59b54c1c5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f44fa5e4f8e7d98f8192c164a6dc4f24b3f19cdf...c5077818d5893f5ab5e58bd06306faa59b54c1c5
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/20240415/8f296a54/attachment-0001.html>


More information about the ghc-commits mailing list