[commit: ghc] master: Allocate less in plus_mod_dep (f00ddea)

git at git.haskell.org git at git.haskell.org
Tue Jan 23 22:57:15 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/f00ddea96cc856654ac90fcf7d29556a758d6648/ghc

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

commit f00ddea96cc856654ac90fcf7d29556a758d6648
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Sun Jan 21 17:16:33 2018 +0000

    Allocate less in plus_mod_dep
    
    This gives a 10% allocation improvement on MultiLayerModules.
    The idea is to reuse existing tuples, instead of constantly
    constructing new ones.
    
    Test Plan: ./validate
    
    Reviewers: simonpj, bgamari
    
    Reviewed By: simonpj, bgamari
    
    Subscribers: rwbarton, thomie, simonmar, carter
    
    Differential Revision: https://phabricator.haskell.org/D4332


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

f00ddea96cc856654ac90fcf7d29556a758d6648
 compiler/typecheck/TcRnTypes.hs     | 11 +++++++----
 testsuite/tests/perf/compiler/all.T |  3 ++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs
index 00927d7..aa14b3b 100644
--- a/compiler/typecheck/TcRnTypes.hs
+++ b/compiler/typecheck/TcRnTypes.hs
@@ -1397,10 +1397,13 @@ plusImportAvails
                    imp_orphs         = orphs1 `unionLists` orphs2,
                    imp_finsts        = finsts1 `unionLists` finsts2 }
   where
-    plus_mod_dep (m1, boot1) (m2, boot2)
-        = WARN( not (m1 == m2), (ppr m1 <+> ppr m2) $$ (ppr boot1 <+> ppr boot2) )
-                -- Check mod-names match
-          (m1, boot1 && boot2) -- If either side can "see" a non-hi-boot interface, use that
+    plus_mod_dep r1@(m1, boot1) r2@(m2, boot2)
+      | ASSERT2( m1 == m2, (ppr m1 <+> ppr m2) $$ (ppr boot1 <+> ppr boot2) )
+        boot1 = r2
+      | otherwise = r1
+      -- If either side can "see" a non-hi-boot interface, use that
+      -- Reusing existing tuples saves 10% of allocations on test
+      -- perf/compiler/MultiLayerModules
 
 {-
 ************************************************************************
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index 51dc6e8..431b288 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -1143,10 +1143,11 @@ test('T13379',
 
 test('MultiLayerModules',
      [ compiler_stats_num_field('bytes allocated',
-          [(wordsize(64), 6294813000, 10),
+          [(wordsize(64), 5619893176, 10),
           # initial:    12139116496
           # 2017-05-12: 6956533312   Revert "Use a deterministic map for imp_dep_mods"
           # 2017-05-31: 6294813000   Faster checkFamInstConsistency
+          # 2018-01-21: 5619893176   Allocate less in plus_mod_dep
           ]),
        pre_cmd('./genMultiLayerModules'),
        extra_files(['genMultiLayerModules']),



More information about the ghc-commits mailing list