[Git][ghc/ghc][master] javascript: Read fields of ObjectBlock lazily
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon Oct 7 17:19:53 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
bf9c9566 by Matthew Pickering at 2024-10-07T13:19:30-04:00
javascript: Read fields of ObjectBlock lazily
When linking a module with a large dependency footprint too much of the
object files were forced during linking. This lead to a large amount of
memory taken up by thunks which would never be forced
On the PartialDownsweep test this halves the memory required (from 25G
to 13G).
Towards #25324
-------------------------
Metric Increase:
size_hello_obj
-------------------------
- - - - -
2 changed files:
- compiler/GHC/StgToJS/Object.hs
- compiler/GHC/StgToJS/Types.hs
Changes:
=====================================
compiler/GHC/StgToJS/Object.hs
=====================================
@@ -255,23 +255,23 @@ instance Outputable ExportedFun where
-- index
putObjBlock :: WriteBinHandle -> ObjBlock -> IO ()
putObjBlock bh (ObjBlock _syms b c d e f g) = do
- put_ bh b
- put_ bh c
+ lazyPut bh b
+ lazyPut bh c
lazyPut bh d
- put_ bh e
- put_ bh f
- put_ bh g
+ lazyPut bh e
+ lazyPut bh f
+ lazyPut bh g
-- | Read an ObjBlock and associate it to the given symbols (that must have been
-- read from the index)
getObjBlock :: [FastString] -> ReadBinHandle -> IO ObjBlock
getObjBlock syms bh = do
- b <- get bh
- c <- get bh
+ b <- lazyGet bh
+ c <- lazyGet bh
d <- lazyGet bh
- e <- get bh
- f <- get bh
- g <- get bh
+ e <- lazyGet bh
+ f <- lazyGet bh
+ g <- lazyGet bh
pure $ ObjBlock
{ oiSymbols = syms
, oiClInfo = b
=====================================
compiler/GHC/StgToJS/Types.hs
=====================================
@@ -312,13 +312,13 @@ data LinkableUnit = LinkableUnit
-- | one toplevel block in the object file
data ObjBlock = ObjBlock
- { oiSymbols :: ![FastString] -- ^ toplevel symbols (stored in index)
- , oiClInfo :: ![ClosureInfo] -- ^ closure information of all closures in block
- , oiStatic :: ![StaticInfo] -- ^ static closure data
+ { oiSymbols :: [FastString] -- ^ toplevel symbols (stored in index)
+ , oiClInfo :: [ClosureInfo] -- ^ closure information of all closures in block
+ , oiStatic :: [StaticInfo] -- ^ static closure data
, oiStat :: Sat.JStat -- ^ the code
- , oiRaw :: !BS.ByteString -- ^ raw JS code
- , oiFExports :: ![ExpFun]
- , oiFImports :: ![ForeignJSRef]
+ , oiRaw :: BS.ByteString -- ^ raw JS code
+ , oiFExports :: [ExpFun]
+ , oiFImports :: [ForeignJSRef]
}
data ExpFun = ExpFun
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf9c9566f258d9a6e5287bd0561fafa5ce26074e
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bf9c9566f258d9a6e5287bd0561fafa5ce26074e
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/20241007/bbc4f303/attachment-0001.html>
More information about the ghc-commits
mailing list