author | coleenp |
Thu, 10 Jan 2019 15:13:51 -0500 | |
changeset 53244 | 9807daeb47c4 |
parent 53116 | bb03098c4dde |
child 53985 | 0da5c17f5e43 |
permissions | -rw-r--r-- |
53116
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
1 |
/* |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
4 |
* |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
8 |
* |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
13 |
* accompanied this code). |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
14 |
* |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
18 |
* |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
21 |
* questions. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
22 |
* |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
23 |
*/ |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
24 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
26 |
#include "gc/g1/g1HeterogeneousCollectorPolicy.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
27 |
#include "logging/log.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
28 |
#include "runtime/globals_extension.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
29 |
#include "runtime/os.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
30 |
#include "utilities/formatBuffer.hpp" |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
31 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
32 |
const double G1HeterogeneousCollectorPolicy::MaxRamFractionForYoung = 0.8; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
33 |
size_t G1HeterogeneousCollectorPolicy::MaxMemoryForYoung; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
34 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
35 |
static size_t calculate_reasonable_max_memory_for_young(FormatBuffer<100> &calc_str, double max_ram_fraction_for_young) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
36 |
julong phys_mem; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
37 |
// If MaxRam is specified, we use that as maximum physical memory available. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
38 |
if (FLAG_IS_DEFAULT(MaxRAM)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
39 |
phys_mem = os::physical_memory(); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
40 |
calc_str.append("Physical_Memory"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
41 |
} else { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
42 |
phys_mem = (julong)MaxRAM; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
43 |
calc_str.append("MaxRAM"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
44 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
45 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
46 |
julong reasonable_max = phys_mem; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
47 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
48 |
// If either MaxRAMFraction or MaxRAMPercentage is specified, we use them to calculate |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
49 |
// reasonable max size of young generation. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
50 |
if (!FLAG_IS_DEFAULT(MaxRAMFraction)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
51 |
reasonable_max = (julong)(phys_mem / MaxRAMFraction); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
52 |
calc_str.append(" / MaxRAMFraction"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
53 |
} else if (!FLAG_IS_DEFAULT(MaxRAMPercentage)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
54 |
reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
55 |
calc_str.append(" * MaxRAMPercentage / 100"); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
56 |
} else { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
57 |
// We use our own fraction to calculate max size of young generation. |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
58 |
reasonable_max = phys_mem * max_ram_fraction_for_young; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
59 |
calc_str.append(" * %0.2f", max_ram_fraction_for_young); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
60 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
61 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
62 |
return (size_t)reasonable_max; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
63 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
64 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
65 |
void G1HeterogeneousCollectorPolicy::initialize_flags() { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
66 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
67 |
FormatBuffer<100> calc_str(""); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
68 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
69 |
MaxMemoryForYoung = calculate_reasonable_max_memory_for_young(calc_str, MaxRamFractionForYoung); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
70 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
71 |
if (MaxNewSize > MaxMemoryForYoung) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
72 |
if (FLAG_IS_CMDLINE(MaxNewSize)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
73 |
log_warning(gc, ergo)("Setting MaxNewSize to " SIZE_FORMAT " based on dram available (calculation = align(%s))", |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
74 |
MaxMemoryForYoung, calc_str.buffer()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
75 |
} else { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
76 |
log_info(gc, ergo)("Setting MaxNewSize to " SIZE_FORMAT " based on dram available (calculation = align(%s)). " |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
77 |
"Dram usage can be lowered by setting MaxNewSize to a lower value", MaxMemoryForYoung, calc_str.buffer()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
78 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
79 |
MaxNewSize = MaxMemoryForYoung; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
80 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
81 |
if (NewSize > MaxMemoryForYoung) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
82 |
if (FLAG_IS_CMDLINE(NewSize)) { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
83 |
log_warning(gc, ergo)("Setting NewSize to " SIZE_FORMAT " based on dram available (calculation = align(%s))", |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
84 |
MaxMemoryForYoung, calc_str.buffer()); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
85 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
86 |
NewSize = MaxMemoryForYoung; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
87 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
88 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
89 |
// After setting new size flags, call base class initialize_flags() |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
90 |
G1CollectorPolicy::initialize_flags(); |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
91 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
92 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
93 |
size_t G1HeterogeneousCollectorPolicy::reasonable_max_memory_for_young() { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
94 |
return MaxMemoryForYoung; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
95 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
96 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
97 |
size_t G1HeterogeneousCollectorPolicy::heap_reserved_size_bytes() const { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
98 |
return 2 * _max_heap_byte_size; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
99 |
} |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
100 |
|
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
101 |
bool G1HeterogeneousCollectorPolicy::is_hetero_heap() const { |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
102 |
return true; |
bb03098c4dde
8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents:
diff
changeset
|
103 |
} |