author | rbackman |
Tue, 26 Apr 2016 10:28:51 +0200 | |
changeset 38133 | 78b95467b9f1 |
parent 37985 | 539c597ee0fa |
child 38010 | 51fe205359f8 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
35927
58bbbbb4a8c7
8148944: CollectorPolicy methods for memory allocations are specific to GenCollectorPolicy
mgerdin
parents:
35909
diff
changeset
|
2 |
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5350
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
37134
9dd3975ca940
8151711: Move G1 number sequences out of the G1 collector policy
mgerdin
parents:
37080
diff
changeset
|
26 |
#include "gc/g1/g1Analytics.hpp" |
30764 | 27 |
#include "gc/g1/g1CollectorPolicy.hpp" |
37041 | 28 |
#include "gc/g1/g1YoungGenSizer.hpp" |
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
29 |
#include "gc/g1/heapRegion.hpp" |
30764 | 30 |
#include "gc/g1/heapRegionRemSet.hpp" |
31 |
#include "gc/shared/gcPolicyCounters.hpp" |
|
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
32 |
#include "runtime/globals.hpp" |
7397 | 33 |
#include "utilities/debug.hpp" |
1374 | 34 |
|
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37262
diff
changeset
|
35 |
G1CollectorPolicy::G1CollectorPolicy() { |
28483
76dc30e48a6e
8068739: G1CollectoryPolicy uses uninitialized field '_sigma' in the constructor
tschatzl
parents:
28213
diff
changeset
|
36 |
|
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3691
diff
changeset
|
37 |
// Set up the region size and associated fields. Given that the |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3691
diff
changeset
|
38 |
// policy is created before the heap, we have to set this up here, |
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3691
diff
changeset
|
39 |
// so it's done as soon as possible. |
19728
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
40 |
|
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
41 |
// It would have been natural to pass initial_heap_byte_size() and |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
42 |
// max_heap_byte_size() to setup_heap_region_size() but those have |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
43 |
// not been set up at this point since they should be aligned with |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
44 |
// the region size. So, there is a circular dependency here. We base |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
45 |
// the region size on the heap size, but the heap size should be |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
46 |
// aligned with the region size. To get around this we use the |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
47 |
// unaligned values for the heap. |
9e1556506d2d
8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents:
19546
diff
changeset
|
48 |
HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize); |
4902
991aaddb5165
6923991: G1: improve scalability of RSet scanning
iveresov
parents:
4481
diff
changeset
|
49 |
HeapRegionRemSet::setup_remset_size(); |
3697
ea9211aa02f5
6819085: G1: use larger and/or user settable region size
tonyp
parents:
3691
diff
changeset
|
50 |
|
5890
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
51 |
// Below, we might need to calculate the pause time target based on |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
52 |
// the pause interval. When we do so we are going to give G1 maximum |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
53 |
// flexibility and allow it to do pauses when it needs to. So, we'll |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
54 |
// arrange that the pause interval to be pause time target + 1 to |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
55 |
// ensure that a) the pause time target is maximized with respect to |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
56 |
// the pause interval and b) we maintain the invariant that pause |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
57 |
// time target < pause interval. If the user does not want this |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
58 |
// maximum flexibility, they will have to set the pause interval |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
59 |
// explicitly. |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
60 |
|
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
61 |
// First make sure that, if either parameter is set, its value is |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
62 |
// reasonable. |
37080
6f33de00485c
8151604: Rely on options range checking rather than explict checks
brutisso
parents:
37070
diff
changeset
|
63 |
guarantee(MaxGCPauseMillis >= 1, "Range checking for MaxGCPauseMillis should guarantee that value is >= 1"); |
5890
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
64 |
|
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
65 |
// Then, if the pause time target parameter was not set, set it to |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
66 |
// the default value. |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
67 |
if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
68 |
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
69 |
// The default pause time target in G1 is 200ms |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
70 |
FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
71 |
} else { |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
72 |
// We do not allow the pause interval to be set without the |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
73 |
// pause time target |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
74 |
vm_exit_during_initialization("GCPauseIntervalMillis cannot be set " |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
75 |
"without setting MaxGCPauseMillis"); |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
76 |
} |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
77 |
} |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
78 |
|
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
79 |
// Then, if the interval parameter was not set, set it according to |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
80 |
// the pause time target (this will also deal with the case when the |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
81 |
// pause time target is the default value). |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
82 |
if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
83 |
FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); |
5766abbf8789
6949307: G1: raise a vm error, do not core dump, if target pause time and target interval are inconsistent
tonyp
parents:
5702
diff
changeset
|
84 |
} |
37080
6f33de00485c
8151604: Rely on options range checking rather than explict checks
brutisso
parents:
37070
diff
changeset
|
85 |
guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1"); |
6f33de00485c
8151604: Rely on options range checking rather than explict checks
brutisso
parents:
37070
diff
changeset
|
86 |
guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis"); |
34298
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34134
diff
changeset
|
87 |
} |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
34134
diff
changeset
|
88 |
|
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21558
diff
changeset
|
89 |
void G1CollectorPolicy::initialize_alignments() { |
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21558
diff
changeset
|
90 |
_space_alignment = HeapRegion::GrainBytes; |
33212 | 91 |
size_t card_table_alignment = CardTableRS::ct_max_alignment_constraint(); |
21561
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21558
diff
changeset
|
92 |
size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); |
c619b1cb4554
8016309: assert(eden_size > 0 && survivor_size > 0) failed: just checking
jwilhelm
parents:
21558
diff
changeset
|
93 |
_heap_alignment = MAX3(card_table_alignment, _space_alignment, page_size); |
1374 | 94 |
} |
95 |
||
36102
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
36090
diff
changeset
|
96 |
void G1CollectorPolicy::initialize_flags() { |
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
36090
diff
changeset
|
97 |
if (G1HeapRegionSize != HeapRegion::GrainBytes) { |
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
36090
diff
changeset
|
98 |
FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes); |
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
36090
diff
changeset
|
99 |
} |
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
36090
diff
changeset
|
100 |
|
37080
6f33de00485c
8151604: Rely on options range checking rather than explict checks
brutisso
parents:
37070
diff
changeset
|
101 |
guarantee(SurvivorRatio >= 1, "Range checking for SurvivorRatio should guarantee that value is >= 1"); |
6f33de00485c
8151604: Rely on options range checking rather than explict checks
brutisso
parents:
37070
diff
changeset
|
102 |
|
36102
84546518799d
8149820: Move G1YoungGenSizer to g1CollectorPolicy.cpp
ehelin
parents:
36090
diff
changeset
|
103 |
CollectorPolicy::initialize_flags(); |
33739 | 104 |
} |
105 |
||
2009 | 106 |
// Create the jstat counters for the policy. |
10528
06fab03478df
7084509: G1: fix inconsistencies and mistakes in the young list target length calculations
tonyp
parents:
10523
diff
changeset
|
107 |
void G1CollectorPolicy::initialize_gc_policy_counters() { |
10280
3463715b5ef7
6814390: G1: remove the concept of non-generational G1
brutisso
parents:
10243
diff
changeset
|
108 |
_gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3); |
2009 | 109 |
} |