author | mgronlun |
Wed, 30 Oct 2019 19:43:52 +0100 | |
changeset 58863 | c16ac7a2eba4 |
parent 54983 | 81becad91321 |
child 58980 | 47c20fc6a517 |
permissions | -rw-r--r-- |
37041 | 1 |
/* |
53985
0da5c17f5e43
8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents:
53116
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
37041 | 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 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#include "precompiled.hpp" |
|
54678
93f09ca4a7f8
8198505: Remove CollectorPolicy and its subclasses
stefank
parents:
54466
diff
changeset
|
26 |
#include "gc/g1/g1Arguments.hpp" |
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
27 |
#include "gc/g1/g1HeterogeneousHeapYoungGenSizer.hpp" |
37041 | 28 |
#include "gc/g1/g1YoungGenSizer.hpp" |
29 |
#include "gc/g1/heapRegion.hpp" |
|
37493
5da80e1490de
8154051: Change G1YoungGenSizer to use UL log_warning instead of warning
sjohanss
parents:
37041
diff
changeset
|
30 |
#include "logging/log.hpp" |
37041 | 31 |
|
51332 | 32 |
G1YoungGenSizer::G1YoungGenSizer() : _sizer_kind(SizerDefaults), |
54466
58751415d5f8
8222105: Add "use_" prefix to G1Policy::adaptive_young_list_length
tschatzl
parents:
53987
diff
changeset
|
33 |
_use_adaptive_sizing(true), _min_desired_young_length(0), _max_desired_young_length(0) { |
51332 | 34 |
|
37041 | 35 |
if (FLAG_IS_CMDLINE(NewRatio)) { |
36 |
if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) { |
|
37493
5da80e1490de
8154051: Change G1YoungGenSizer to use UL log_warning instead of warning
sjohanss
parents:
37041
diff
changeset
|
37 |
log_warning(gc, ergo)("-XX:NewSize and -XX:MaxNewSize override -XX:NewRatio"); |
37041 | 38 |
} else { |
39 |
_sizer_kind = SizerNewRatio; |
|
54466
58751415d5f8
8222105: Add "use_" prefix to G1Policy::adaptive_young_list_length
tschatzl
parents:
53987
diff
changeset
|
40 |
_use_adaptive_sizing = false; |
37041 | 41 |
return; |
42 |
} |
|
43 |
} |
|
44 |
||
45 |
if (NewSize > MaxNewSize) { |
|
46 |
if (FLAG_IS_CMDLINE(MaxNewSize)) { |
|
37493
5da80e1490de
8154051: Change G1YoungGenSizer to use UL log_warning instead of warning
sjohanss
parents:
37041
diff
changeset
|
47 |
log_warning(gc, ergo)("NewSize (" SIZE_FORMAT "k) is greater than the MaxNewSize (" SIZE_FORMAT "k). " |
5da80e1490de
8154051: Change G1YoungGenSizer to use UL log_warning instead of warning
sjohanss
parents:
37041
diff
changeset
|
48 |
"A new max generation size of " SIZE_FORMAT "k will be used.", |
5da80e1490de
8154051: Change G1YoungGenSizer to use UL log_warning instead of warning
sjohanss
parents:
37041
diff
changeset
|
49 |
NewSize/K, MaxNewSize/K, NewSize/K); |
37041 | 50 |
} |
54983
81becad91321
8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents:
54678
diff
changeset
|
51 |
FLAG_SET_ERGO(MaxNewSize, NewSize); |
37041 | 52 |
} |
53 |
||
54 |
if (FLAG_IS_CMDLINE(NewSize)) { |
|
55 |
_min_desired_young_length = MAX2((uint) (NewSize / HeapRegion::GrainBytes), |
|
56 |
1U); |
|
57 |
if (FLAG_IS_CMDLINE(MaxNewSize)) { |
|
58 |
_max_desired_young_length = |
|
59 |
MAX2((uint) (MaxNewSize / HeapRegion::GrainBytes), |
|
60 |
1U); |
|
61 |
_sizer_kind = SizerMaxAndNewSize; |
|
54466
58751415d5f8
8222105: Add "use_" prefix to G1Policy::adaptive_young_list_length
tschatzl
parents:
53987
diff
changeset
|
62 |
_use_adaptive_sizing = _min_desired_young_length != _max_desired_young_length; |
37041 | 63 |
} else { |
64 |
_sizer_kind = SizerNewSizeOnly; |
|
65 |
} |
|
66 |
} else if (FLAG_IS_CMDLINE(MaxNewSize)) { |
|
67 |
_max_desired_young_length = |
|
68 |
MAX2((uint) (MaxNewSize / HeapRegion::GrainBytes), |
|
69 |
1U); |
|
70 |
_sizer_kind = SizerMaxNewSizeOnly; |
|
71 |
} |
|
72 |
} |
|
73 |
||
74 |
uint G1YoungGenSizer::calculate_default_min_length(uint new_number_of_heap_regions) { |
|
75 |
uint default_value = (new_number_of_heap_regions * G1NewSizePercent) / 100; |
|
76 |
return MAX2(1U, default_value); |
|
77 |
} |
|
78 |
||
79 |
uint G1YoungGenSizer::calculate_default_max_length(uint new_number_of_heap_regions) { |
|
80 |
uint default_value = (new_number_of_heap_regions * G1MaxNewSizePercent) / 100; |
|
81 |
return MAX2(1U, default_value); |
|
82 |
} |
|
83 |
||
84 |
void G1YoungGenSizer::recalculate_min_max_young_length(uint number_of_heap_regions, uint* min_young_length, uint* max_young_length) { |
|
85 |
assert(number_of_heap_regions > 0, "Heap must be initialized"); |
|
86 |
||
87 |
switch (_sizer_kind) { |
|
88 |
case SizerDefaults: |
|
89 |
*min_young_length = calculate_default_min_length(number_of_heap_regions); |
|
90 |
*max_young_length = calculate_default_max_length(number_of_heap_regions); |
|
91 |
break; |
|
92 |
case SizerNewSizeOnly: |
|
93 |
*max_young_length = calculate_default_max_length(number_of_heap_regions); |
|
94 |
*max_young_length = MAX2(*min_young_length, *max_young_length); |
|
95 |
break; |
|
96 |
case SizerMaxNewSizeOnly: |
|
97 |
*min_young_length = calculate_default_min_length(number_of_heap_regions); |
|
98 |
*min_young_length = MIN2(*min_young_length, *max_young_length); |
|
99 |
break; |
|
100 |
case SizerMaxAndNewSize: |
|
101 |
// Do nothing. Values set on the command line, don't update them at runtime. |
|
102 |
break; |
|
103 |
case SizerNewRatio: |
|
104 |
*min_young_length = number_of_heap_regions / (NewRatio + 1); |
|
105 |
*max_young_length = *min_young_length; |
|
106 |
break; |
|
107 |
default: |
|
108 |
ShouldNotReachHere(); |
|
109 |
} |
|
110 |
||
111 |
assert(*min_young_length <= *max_young_length, "Invalid min/max young gen size values"); |
|
112 |
} |
|
113 |
||
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37493
diff
changeset
|
114 |
void G1YoungGenSizer::adjust_max_new_size(uint number_of_heap_regions) { |
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37493
diff
changeset
|
115 |
|
37041 | 116 |
// We need to pass the desired values because recalculation may not update these |
117 |
// values in some cases. |
|
118 |
uint temp = _min_desired_young_length; |
|
119 |
uint result = _max_desired_young_length; |
|
120 |
recalculate_min_max_young_length(number_of_heap_regions, &temp, &result); |
|
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37493
diff
changeset
|
121 |
|
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37493
diff
changeset
|
122 |
size_t max_young_size = result * HeapRegion::GrainBytes; |
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37493
diff
changeset
|
123 |
if (max_young_size != MaxNewSize) { |
54983
81becad91321
8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents:
54678
diff
changeset
|
124 |
FLAG_SET_ERGO(MaxNewSize, max_young_size); |
37985
539c597ee0fa
8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents:
37493
diff
changeset
|
125 |
} |
37041 | 126 |
} |
127 |
||
128 |
void G1YoungGenSizer::heap_size_changed(uint new_number_of_heap_regions) { |
|
129 |
recalculate_min_max_young_length(new_number_of_heap_regions, &_min_desired_young_length, |
|
130 |
&_max_desired_young_length); |
|
131 |
} |
|
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
132 |
|
54678
93f09ca4a7f8
8198505: Remove CollectorPolicy and its subclasses
stefank
parents:
54466
diff
changeset
|
133 |
G1YoungGenSizer* G1YoungGenSizer::create_gen_sizer() { |
93f09ca4a7f8
8198505: Remove CollectorPolicy and its subclasses
stefank
parents:
54466
diff
changeset
|
134 |
if (G1Arguments::is_heterogeneous_heap()) { |
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
135 |
return new G1HeterogeneousHeapYoungGenSizer(); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
136 |
} else { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
137 |
return new G1YoungGenSizer(); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
138 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
51332
diff
changeset
|
139 |
} |