Commit e13419c5 authored by rwbarton's avatar rwbarton Committed by Ben Gamari

Fix space leaks in simplifier (#13426)

The Join points commit (8d5cf8bf) introduced a space leak
somewhere in the simplifier. The extra strictness added in this commit
fixes the leak. Unfortunately I don't really understand the details.

Unfortunately, the extra strictness appears to result in more overall
allocations in some cases, even while the peak heap size decreases in others.

Test Plan: harbormaster

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3399
parent 6575f4b6
......@@ -2251,7 +2251,10 @@ reallyRebuildCase env scrut case_bndr alts cont
; dflags <- getDynFlags
; let alts_ty' = contResultType dup_cont
; case_expr <- mkCase dflags scrut' case_bndr' alts_ty' alts'
-- The seqType below is needed to avoid a space leak (#13426)
-- but I don't know why.
; case_expr <- seqType alts_ty' `seq`
mkCase dflags scrut' case_bndr' alts_ty' alts'
-- Notice that rebuild gets the in-scope set from env', not alt_env
-- (which in any case is only build in simplAlts)
......
......@@ -39,7 +39,7 @@ test('T1969',
# 2013-11-13 17 (x86/Windows, 64bit machine)
# 2015-07-11 21 (x86/Linux, 64bit machine) use +RTS -G1
# 2016-04-06 30 (x86/Linux, 64bit machine)
(wordsize(64), 83, 20)]),
(wordsize(64), 61, 20)]),
# 28 (amd64/Linux)
# 34 (amd64/Linux)
# 2012-09-20 23 (amd64/Linux)
......@@ -54,6 +54,7 @@ test('T1969',
# 2016-10-20 68, (amd64/Linux) allow top-level string literals
# See the comment 16 on #8472.
# 2017-02-17 83 (amd64/Linux) Type-indexed Typeable
# 2017-03-31 61 (amd64/Linux) Fix memory leak in simplifier
compiler_stats_num_field('max_bytes_used',
[(platform('i386-unknown-mingw32'), 5719436, 20),
# 2010-05-17 5717704 (x86/Windows)
......@@ -70,7 +71,7 @@ test('T1969',
# 2016-04-06 9093608 (x86/Linux, 64bit machine)
# 2017-03-24 9261052 (x86/Linux, 64-bit machine)
(wordsize(64), 19924328, 15)]),
(wordsize(64), 16679176, 15)]),
# 2014-09-10 10463640, 10 # post-AMP-update (somewhat stabelish)
# looks like the peak is around ~10M, but we're
# unlikely to GC exactly on the peak.
......@@ -84,6 +85,7 @@ test('T1969',
# 2016-10-12 17285216 (amd64/Linux) it's not entirely clear why
# 2017-02-01 19924328 (amd64/Linux) Join points (#12988)
# 2017-02-14 16393848 Early inline patch
# 2017-03-31 16679176 Fix memory leak in simplifier
compiler_stats_num_field('bytes allocated',
[(platform('i386-unknown-mingw32'), 301784492, 5),
......@@ -325,7 +327,7 @@ test('T3064',
# 2016-04-06: 153261024 (x86/Linux) probably wildcard refactor
# 2017-03-24: 134044092 (x86/Linux, 64-bit machine) Update
(wordsize(64), 259815560, 5)]),
(wordsize(64), 265950920, 5)]),
# (amd64/Linux) (2011-06-28): 73259544
# (amd64/Linux) (2013-02-07): 224798696
# (amd64/Linux) (2013-08-02): 236404384, increase from roles
......@@ -350,6 +352,7 @@ test('T3064',
# of zonkTcType (Trac #11882)
# (amd64/Darwin) (2017-01-23): 306222424 Presumably creep from recent changes (Typeable?)
# (amd64/Linux) (2017-02-14): 259815560 Early inline patch: 9% improvement
# (amd64/Linux) (2017-03-31): 265950920 Fix memory leak in simplifier
###################################
# deactivated for now, as this metric became too volatile recently
......@@ -434,7 +437,7 @@ test('T5631',
# 2014-04-04: 346389856 (x86 Windows, 64 bit machine)
# 2014-12-01: 390199244 (Windows laptop)
# 2016-04-06: 570137436 (amd64/Linux) many reasons
(wordsize(64), 1065147968, 5)]),
(wordsize(64), 1037482512, 5)]),
# expected value: 774595008 (amd64/Linux):
# expected value: 735486328 (amd64/Linux) 2012/12/12:
# expected value: 690742040 (amd64/Linux) Call Arity improvements
......@@ -448,6 +451,7 @@ test('T5631',
# 2016-11-10: 1077429456 (amd64/Linux) Stop -dno-debug-output suppressing -ddump-tc-trace
# 2017-02-17: 1517484488 (amd64/Linux) Type-indexed Typeable
# 2017-03-03: 1065147968 (amd64/Linux) Share Typeable KindReps
# 2017-03-31: 1037482512 (amd64/Linux) Fix memory leak in simplifier
only_ways(['normal'])
],
compile,
......@@ -713,7 +717,7 @@ test('T9020',
# Original: 381360728
# 2014-07-31: 343005716 (Windows) (general round of updates)
# 2017-03-24: 249904136 (x86/Linux, 64-bit machine)
(wordsize(64), 500707080, 10)])
(wordsize(64), 493596312, 10)])
# prev: 795469104
# 2014-07-17: 728263536 (general round of updates)
# 2014-09-10: 785871680 post-AMP-cleanup
......@@ -725,6 +729,7 @@ test('T9020',
# 2017-02-03: 764866144 Join points
# 2017-02-14: 500707080 Early inline patch; 35% decrease!
# Program size collapses in first simplification
# 2017-03-31: 493596312 Fix memory leak in simplifier
],
compile,[''])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment