summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2017-02-23 13:54:36 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-23 17:26:44 -0500
commit12e21d35ee1b77f5f2bb8bd747848f07a32d592f (patch)
treee9e05af3e3f0557fb74fe27694520c20aa3940e1
parentbb1c660f3e0f1b471eb74cbb02275b97db3fa8b4 (diff)
downloadhaskell-12e21d35ee1b77f5f2bb8bd747848f07a32d592f.tar.gz
Use half as much memory when reading interfaces
I don't see any reason for the (filesize*2), and experimentally allocations do go down slightly after this change. Test Plan: validate Reviewers: simonmar, austin, bgamari, trofi Reviewed By: bgamari, trofi Subscribers: trofi, thomie Differential Revision: https://phabricator.haskell.org/D3164
-rw-r--r--compiler/utils/Binary.hs2
-rw-r--r--testsuite/tests/perf/space_leaks/all.T6
2 files changed, 5 insertions, 3 deletions
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
index b10ab1d5f2..a1ccee3ae7 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 76ad7a7606..a9afd285f2 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,