[commit: ghc] wip/rwbarton-D3164: Use half as much memory when reading interfaces (9989485)

git at git.haskell.org git at git.haskell.org
Wed Feb 22 18:26:19 UTC 2017


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

On branch  : wip/rwbarton-D3164
Link       : http://ghc.haskell.org/trac/ghc/changeset/99894850e71c9fc8f8e5f5531f4a643dbff081c0/ghc

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

commit 99894850e71c9fc8f8e5f5531f4a643dbff081c0
Author: Reid Barton <rwbarton at gmail.com>
Date:   Sun Feb 19 20:05:06 2017 -0500

    Use half as much memory when reading interfaces
    
    Summary:
    I don't see any reason for the (filesize*2), and experimentally
    allocationsn do go down slightly after this change.
    
    Test Plan: validate
    
    Reviewers: simonmar, austin, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D3164


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

99894850e71c9fc8f8e5f5531f4a643dbff081c0
 compiler/utils/Binary.hs               | 2 +-
 testsuite/tests/perf/space_leaks/all.T | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
index b10ab1d..a1ccee3 100644
--- a/compiler/utils/Binary.hs
+++ b/compiler/utils/Binary.hs
@@ -207,7 +207,7 @@ readBinMem filename = do
   h <- openBinaryFile filename ReadMode
   filesize' <- hFileSize h
   let filesize = fromIntegral filesize'
-  arr <- mallocForeignPtrBytes (filesize*2)
+  arr <- mallocForeignPtrBytes filesize
   count <- withForeignPtr arr $ \p -> hGetBuf h p filesize
   when (count /= filesize) $
        error ("Binary.readBinMem: only read " ++ show count ++ " bytes")
diff --git a/testsuite/tests/perf/space_leaks/all.T b/testsuite/tests/perf/space_leaks/all.T
index 76ad7a7..a9afd28 100644
--- a/testsuite/tests/perf/space_leaks/all.T
+++ b/testsuite/tests/perf/space_leaks/all.T
@@ -58,14 +58,15 @@ test('T4018',
 
 test('T4029',
      [stats_num_field('peak_megabytes_allocated',
-          [(wordsize(64), 80, 10)]),
+          [(wordsize(64), 76, 10)]),
             # 2016-02-26: 66 (amd64/Linux)           INITIAL
             # 2016-05-23: 82 (amd64/Linux)           Use -G1
             # 2016-07-13: 92 (amd64/Linux)           Changes to tidyType
             # 2016-09-01: 71 (amd64/Linux)           Restore w/w limit (#11565)
             # 2017-02-12: 80 (amd64/Linux)           Type-indexed Typeable
+            # 2017-02-20: 76 (amd64/Linux)           Better reading of iface files
       stats_num_field('max_bytes_used',
-          [(wordsize(64), 24151096, 5)]),
+          [(wordsize(64), 22016200, 5)]),
             # 2016-02-26: 24071720 (amd64/Linux)     INITIAL
             # 2016-04-21: 25542832 (amd64/Linux)
             # 2016-05-23: 25247216 (amd64/Linux)     Use -G1
@@ -77,6 +78,7 @@ test('T4029',
             # 2017-01-18: 21670448 (amd64/Linux)     Float string literals to toplevel
             # 2017-02-07: 22770352 (amd64/Linux)     It is unclear
             # 2017-02-12: 24151096 (amd64/Linux)     Type-indexed Typeable
+            # 2017-02-20: 22016200 (amd64/Linux)     Better reading of iface files
       extra_hc_opts('+RTS -G1 -RTS' ),
       ],
      ghci_script,



More information about the ghc-commits mailing list