[commit: ghc] master: rts: Correct the nursery size in the gen 1 growth computation (7d116e5)

git at git.haskell.org git at git.haskell.org
Thu Feb 23 22:27:24 UTC 2017


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

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

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

commit 7d116e553f0b44723e279ae5affa744e6aefc3c0
Author: John C. Carey <jcarey at awakenetworks.com>
Date:   Thu Feb 23 13:45:22 2017 -0500

    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


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

7d116e553f0b44723e279ae5affa744e6aefc3c0
 rts/sm/GC.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index c41c979..358700e 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%).



More information about the ghc-commits mailing list