< prev index next >

src/hotspot/share/gc/parallel/parallelArguments.cpp

Print this page
rev 57719 : imported patch 8235860-remove-serial-old-gc
rev 57720 : imported patch 8235860-kbarrett-review
   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


  27 #include "gc/parallel/parallelArguments.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/shared/adaptiveSizePolicy.hpp"
  30 #include "gc/shared/gcArguments.hpp"
  31 #include "gc/shared/genArguments.hpp"
  32 #include "gc/shared/workerPolicy.hpp"
  33 #include "logging/log.hpp"
  34 #include "runtime/globals.hpp"
  35 #include "runtime/globals_extension.hpp"
  36 #include "runtime/java.hpp"
  37 #include "utilities/defaultStream.hpp"
  38 
  39 static const double MaxRamFractionForYoung = 0.8;
  40 
  41 size_t ParallelArguments::conservative_max_heap_alignment() {
  42   return compute_heap_alignment();
  43 }
  44 
  45 void ParallelArguments::initialize() {
  46   GCArguments::initialize();
  47   assert(UseParallelGC || UseParallelOldGC, "Error");
  48   // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
  49   if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
  50     FLAG_SET_DEFAULT(UseParallelOldGC, true);
  51   }
  52   FLAG_SET_DEFAULT(UseParallelGC, true);
  53 
  54   // If no heap maximum was requested explicitly, use some reasonable fraction
  55   // of the physical memory, up to a maximum of 1GB.
  56   FLAG_SET_DEFAULT(ParallelGCThreads,
  57                    WorkerPolicy::parallel_worker_threads());
  58   if (ParallelGCThreads == 0) {
  59     jio_fprintf(defaultStream::error_stream(),
  60         "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
  61     vm_exit(1);
  62   }
  63 
  64   if (UseAdaptiveSizePolicy) {
  65     // We don't want to limit adaptive heap sizing's freedom to adjust the heap
  66     // unless the user actually sets these flags.
  67     if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
  68       FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
  69     }
  70     if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
  71       FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
  72     }
  73   }
  74 
  75   // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
  76   // SurvivorRatio has been set, reset their default values to SurvivorRatio +
  77   // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.
  78   // See CR 6362902 for details.
  79   if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
  80     if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
  81        FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
  82     }
  83     if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
  84       FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
  85     }
  86   }
  87 
  88   if (UseParallelOldGC) {
  89     // Par compact uses lower default values since they are treated as
  90     // minimums.  These are different defaults because of the different
  91     // interpretation and are not ergonomically set.
  92     if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
  93       FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
  94     }
  95   }
  96 }
  97 
  98 // The alignment used for boundary between young gen and old gen
  99 static size_t default_gen_alignment() {
 100   return 64 * K * HeapWordSize;
 101 }
 102 
 103 void ParallelArguments::initialize_alignments() {
 104   SpaceAlignment = GenAlignment = default_gen_alignment();
 105   HeapAlignment = compute_heap_alignment();
 106 }
 107 
 108 void ParallelArguments::initialize_heap_flags_and_sizes_one_pass() {
 109   // Do basic sizing work
 110   GenArguments::initialize_heap_flags_and_sizes();
 111 
 112   // The survivor ratio's are calculated "raw", unlike the
 113   // default gc, which adds 2 to the ratio value. We need to
 114   // make sure the values are valid before using them.


   1 /*
   2  * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


  27 #include "gc/parallel/parallelArguments.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/shared/adaptiveSizePolicy.hpp"
  30 #include "gc/shared/gcArguments.hpp"
  31 #include "gc/shared/genArguments.hpp"
  32 #include "gc/shared/workerPolicy.hpp"
  33 #include "logging/log.hpp"
  34 #include "runtime/globals.hpp"
  35 #include "runtime/globals_extension.hpp"
  36 #include "runtime/java.hpp"
  37 #include "utilities/defaultStream.hpp"
  38 
  39 static const double MaxRamFractionForYoung = 0.8;
  40 
  41 size_t ParallelArguments::conservative_max_heap_alignment() {
  42   return compute_heap_alignment();
  43 }
  44 
  45 void ParallelArguments::initialize() {
  46   GCArguments::initialize();
  47   assert(UseParallelGC, "Error");





  48 
  49   // If no heap maximum was requested explicitly, use some reasonable fraction
  50   // of the physical memory, up to a maximum of 1GB.
  51   FLAG_SET_DEFAULT(ParallelGCThreads,
  52                    WorkerPolicy::parallel_worker_threads());
  53   if (ParallelGCThreads == 0) {
  54     jio_fprintf(defaultStream::error_stream(),
  55         "The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
  56     vm_exit(1);
  57   }
  58 
  59   if (UseAdaptiveSizePolicy) {
  60     // We don't want to limit adaptive heap sizing's freedom to adjust the heap
  61     // unless the user actually sets these flags.
  62     if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
  63       FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
  64     }
  65     if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
  66       FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
  67     }
  68   }
  69 
  70   // If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
  71   // SurvivorRatio has been set, reset their default values to SurvivorRatio +
  72   // 2.  By doing this we make SurvivorRatio also work for Parallel Scavenger.
  73   // See CR 6362902 for details.
  74   if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
  75     if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
  76        FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
  77     }
  78     if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
  79       FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
  80     }
  81   }
  82 

  83   // Par compact uses lower default values since they are treated as
  84   // minimums.  These are different defaults because of the different
  85   // interpretation and are not ergonomically set.
  86   if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
  87     FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);

  88   }
  89 }
  90 
  91 // The alignment used for boundary between young gen and old gen
  92 static size_t default_gen_alignment() {
  93   return 64 * K * HeapWordSize;
  94 }
  95 
  96 void ParallelArguments::initialize_alignments() {
  97   SpaceAlignment = GenAlignment = default_gen_alignment();
  98   HeapAlignment = compute_heap_alignment();
  99 }
 100 
 101 void ParallelArguments::initialize_heap_flags_and_sizes_one_pass() {
 102   // Do basic sizing work
 103   GenArguments::initialize_heap_flags_and_sizes();
 104 
 105   // The survivor ratio's are calculated "raw", unlike the
 106   // default gc, which adds 2 to the ratio value. We need to
 107   // make sure the values are valid before using them.


< prev index next >