[commit: ghc] wip/T13633, wip/non-det-ci: Include closure header size in StgLamLift's estimations (b85068f)

git at git.haskell.org git at git.haskell.org
Sun Feb 24 20:55:04 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branches: wip/T13633,wip/non-det-ci
Link       : http://ghc.haskell.org/trac/ghc/changeset/b85068f6843eb0b16ff898e0dfa811fede8e1ca1/ghc

>---------------------------------------------------------------

commit b85068f6843eb0b16ff898e0dfa811fede8e1ca1
Author: Sebastian Graf <sebastian.graf at kit.edu>
Date:   Thu Feb 21 16:02:38 2019 +0100

    Include closure header size in StgLamLift's estimations
    
    While playing around with late lambda lifting, I realised that
    StgLamLift.Analysis doesn't consider the removed closure header in its
    allocation estimations.
    
    That's because contrary to what I thought, the total word count returned
    by `mkVirtHeapOffsets` doesn't include the size of the closure header.
    
    We just add the header size manually now.


>---------------------------------------------------------------

b85068f6843eb0b16ff898e0dfa811fede8e1ca1
 compiler/simplStg/StgLiftLams/Analysis.hs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/compiler/simplStg/StgLiftLams/Analysis.hs b/compiler/simplStg/StgLiftLams/Analysis.hs
index 7fb60df..3cdbfcb 100644
--- a/compiler/simplStg/StgLiftLams/Analysis.hs
+++ b/compiler/simplStg/StgLiftLams/Analysis.hs
@@ -484,13 +484,12 @@ rhsLambdaBndrs (StgRhsClosure _ _ _ bndrs _) = map binderInfoBndr bndrs
 -- | The size in words of a function closure closing over the given 'Id's,
 -- including the header.
 closureSize :: DynFlags -> [Id] -> WordOff
-closureSize dflags ids = words
+closureSize dflags ids = words + sTD_HDR_SIZE dflags
+  -- We go through sTD_HDR_SIZE rather than fixedHdrSizeW so that we don't
+  -- optimise differently when profiling is enabled.
   where
     (words, _, _)
       -- Functions have a StdHeader (as opposed to ThunkHeader).
-      -- Note that mkVirtHeadOffsets will account for profiling headers, so
-      -- lifting decisions vary if we begin to profile stuff. Maybe we shouldn't
-      -- do this or deactivate profiling in @dflags@?
       = StgCmmLayout.mkVirtHeapOffsets dflags StgCmmLayout.StdHeader
       . StgCmmClosure.addIdReps
       . StgCmmClosure.nonVoidIds



More information about the ghc-commits mailing list