summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorJohn C. Carey <jcarey@awakenetworks.com>2017-02-23 13:45:22 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-23 17:26:44 -0500
commit7d116e553f0b44723e279ae5affa744e6aefc3c0 (patch)
tree0123733767370dce29e4ebbfa557fd991700e651 /rts
parent48a967ccf75145b7ffb5bf70d447bc533d17ade4 (diff)
downloadhaskell-7d116e553f0b44723e279ae5affa744e6aefc3c0.tar.gz
rts: Correct the nursery size in the gen 1 growth computation
Fixes trac issue #13288. Reviewers: austin, bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: mutjida, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3143
Diffstat (limited to 'rts')
-rw-r--r--rts/sm/GC.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index c41c9791dc..358700e499 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -742,6 +742,17 @@ GarbageCollect (uint32_t collect_gen,
require (F+1)*need. We leave (F+2)*need in order to reduce
repeated deallocation and reallocation. */
need = (RtsFlags.GcFlags.oldGenFactor + 2) * need;
+ /* But with a large nursery, the above estimate might exceed
+ * maxHeapSize. A large resident set size might make the OS
+ * kill this process, or swap unnecessarily. Therefore we
+ * ensure that our estimate does not exceed maxHeapSize.
+ */
+ if (RtsFlags.GcFlags.maxHeapSize != 0) {
+ W_ max = BLOCKS_TO_MBLOCKS(RtsFlags.GcFlags.maxHeapSize);
+ if (need > max) {
+ need = max;
+ }
+ }
if (got > need) {
returnMemoryToOS(got - need);
}
@@ -1524,7 +1535,8 @@ resize_generations (void)
// minimum size for generation zero
min_alloc = stg_max((RtsFlags.GcFlags.pcFreeHeap * max) / 200,
- RtsFlags.GcFlags.minAllocAreaSize);
+ RtsFlags.GcFlags.minAllocAreaSize
+ * (W_)n_capabilities);
// Auto-enable compaction when the residency reaches a
// certain percentage of the maximum heap size (default: 30%).