annotate src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @ 3285:49a67202bc67

7011855: G1: non-product flag to artificially grow the heap Summary: It introduces non-product cmd line parameter G1DummyRegionsPerGC which indicates how many "dummy" regions to allocate at the end of each GC. This allows the G1 heap to grow artificially and makes concurrent marking cycles more frequent irrespective of what the application that is running is doing. The dummy regions will be found totally empty during cleanup so this parameter can also be used to stress the concurrent cleanup operation. Reviewed-by: brutisso, johnc
author tonyp
date Tue, 19 Apr 2011 15:46:59 -0400
parents f95d63e2154a
children f08d439fab8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
26 #include "gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
27 #include "gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
28 #include "gc_implementation/concurrentMarkSweep/cmsGCAdaptivePolicyCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
29 #include "gc_implementation/parNew/parNewGeneration.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
30 #include "gc_implementation/shared/gcPolicyCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
31 #include "gc_implementation/shared/vmGCOperations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
32 #include "memory/cardTableRS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
33 #include "memory/collectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
34 #include "memory/gcLocker.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
35 #include "memory/genCollectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
36 #include "memory/generationSpec.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
37 #include "memory/space.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
38 #include "memory/universe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
39 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
40 #include "runtime/globals_extension.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
41 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
42 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
43 #include "runtime/vmThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
44 #ifdef TARGET_OS_FAMILY_linux
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
45 # include "thread_linux.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
46 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
47 #ifdef TARGET_OS_FAMILY_solaris
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
48 # include "thread_solaris.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
49 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
50 #ifdef TARGET_OS_FAMILY_windows
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
51 # include "thread_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1833
diff changeset
52 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 //
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // ConcurrentMarkSweepPolicy methods
a61af66fc99e Initial load
duke
parents:
diff changeset
56 //
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 ConcurrentMarkSweepPolicy::ConcurrentMarkSweepPolicy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 initialize_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 void ConcurrentMarkSweepPolicy::initialize_generations() {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 initialize_perm_generation(PermGen::ConcurrentMarkSweep);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _generations = new GenerationSpecPtr[number_of_generations()];
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if (_generations == NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
66 vm_exit_during_initialization("Unable to allocate gen spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
67
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
68 if (ParNewGeneration::in_use()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if (UseAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _generations[0] = new GenerationSpec(Generation::ASParNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _generations[0] = new GenerationSpec(Generation::ParNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _generations[0] = new GenerationSpec(Generation::DefNew,
a61af66fc99e Initial load
duke
parents:
diff changeset
78 _initial_gen0_size, _max_gen0_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (UseAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep,
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _initial_gen1_size, _max_gen1_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep,
a61af66fc99e Initial load
duke
parents:
diff changeset
85 _initial_gen1_size, _max_gen1_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if (_generations[0] == NULL || _generations[1] == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 vm_exit_during_initialization("Unable to allocate gen spec");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 size_t init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 size_t init_survivor_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 double max_gc_minor_pause_sec = ((double) MaxGCMinorPauseMillis)/1000.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 double max_gc_pause_sec = ((double) MaxGCPauseMillis)/1000.0;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _size_policy = new CMSAdaptiveSizePolicy(init_eden_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
99 init_promo_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 init_survivor_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 max_gc_minor_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 max_gc_pause_sec,
a61af66fc99e Initial load
duke
parents:
diff changeset
103 GCTimeRatio);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void ConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // initialize the policy counters - 2 collectors, 3 generations
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
108 if (ParNewGeneration::in_use()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _gc_policy_counters = new GCPolicyCounters("ParNew:CMS", 2, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _gc_policy_counters = new GCPolicyCounters("Copy:CMS", 2, 3);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Returns true if the incremental mode is enabled.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 bool ConcurrentMarkSweepPolicy::has_soft_ended_eden()
a61af66fc99e Initial load
duke
parents:
diff changeset
118 {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return CMSIncrementalMode;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 //
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // ASConcurrentMarkSweepPolicy methods
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void ASConcurrentMarkSweepPolicy::initialize_gc_policy_counters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 assert(size_policy() != NULL, "A size policy is required");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // initialize the policy counters - 2 collectors, 3 generations
1833
8b10f48633dc 6984287: Regularize how GC parallel workers are specified.
jmasa
parents: 1552
diff changeset
131 if (ParNewGeneration::in_use()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
132 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("ParNew:CMS", 2, 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
133 size_policy());
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _gc_policy_counters = new CMSGCAdaptivePolicyCounters("Copy:CMS", 2, 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 size_policy());
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }