author | stefank |
Mon, 25 Nov 2019 12:33:15 +0100 | |
changeset 59252 | 623722a6aeb9 |
parent 59250 | a6deb69743d4 |
child 59290 | 97d13893ec3c |
permissions | -rw-r--r-- |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 |
/* |
53547 | 2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 |
* questions. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 |
*/ |
50193 | 24 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
42650 | 26 |
#include "aot/aotLoader.hpp" |
51959
db0c3952de52
8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents:
51444
diff
changeset
|
27 |
#include "classfile/classLoaderDataGraph.hpp" |
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
50372
diff
changeset
|
28 |
#include "gc/shared/collectedHeap.hpp" |
35061 | 29 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
30 |
#include "logging/logStream.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
#include "memory/filemap.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 |
#include "memory/metaspace.hpp" |
50193 | 33 |
#include "memory/metaspace/chunkManager.hpp" |
34 |
#include "memory/metaspace/metachunk.hpp" |
|
49980 | 35 |
#include "memory/metaspace/metaspaceCommon.hpp" |
50193 | 36 |
#include "memory/metaspace/printCLDMetaspaceInfoClosure.hpp" |
37 |
#include "memory/metaspace/spaceManager.hpp" |
|
38 |
#include "memory/metaspace/virtualSpaceList.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 |
#include "memory/metaspaceShared.hpp" |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
40 |
#include "memory/metaspaceTracer.hpp" |
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
50372
diff
changeset
|
41 |
#include "memory/universe.hpp" |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
42 |
#include "oops/compressedOops.hpp" |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
43 |
#include "runtime/init.hpp" |
50429
83aec1d357d4
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents:
50380
diff
changeset
|
44 |
#include "runtime/orderAccess.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 |
#include "services/memTracker.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 |
#include "utilities/copy.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 |
#include "utilities/debug.hpp" |
50380
bec342339138
8204195: Clean up macroAssembler.inline.hpp and other inline.hpp files included in .hpp files
coleenp
parents:
50372
diff
changeset
|
48 |
#include "utilities/formatBuffer.hpp" |
49980 | 49 |
#include "utilities/globalDefinitions.hpp" |
54842 | 50 |
#include "utilities/vmError.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 |
|
20729 | 52 |
|
50193 | 53 |
using namespace metaspace; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
55 |
MetaWord* last_allocated = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
56 |
|
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
57 |
size_t Metaspace::_compressed_class_space_size; |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
58 |
const MetaspaceTracer* Metaspace::_tracer = NULL; |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
59 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
60 |
DEBUG_ONLY(bool Metaspace::_frozen = false;) |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
61 |
|
49980 | 62 |
static const char* space_type_name(Metaspace::MetaspaceType t) { |
63 |
const char* s = NULL; |
|
64 |
switch (t) { |
|
65 |
case Metaspace::StandardMetaspaceType: s = "Standard"; break; |
|
66 |
case Metaspace::BootMetaspaceType: s = "Boot"; break; |
|
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51334
diff
changeset
|
67 |
case Metaspace::UnsafeAnonymousMetaspaceType: s = "UnsafeAnonymous"; break; |
49980 | 68 |
case Metaspace::ReflectionMetaspaceType: s = "Reflection"; break; |
69 |
default: ShouldNotReachHere(); |
|
70 |
} |
|
71 |
return s; |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
72 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
73 |
|
50119
bf9177eac58d
8189271: Metaspace::_capacity_until_GC should be size_t
aharlap
parents:
50066
diff
changeset
|
74 |
volatile size_t MetaspaceGC::_capacity_until_GC = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 |
uint MetaspaceGC::_shrink_factor = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 |
// BlockFreelist methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
78 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 |
// VirtualSpaceNode methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
80 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 |
// MetaspaceGC methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
// VM_CollectForMetadataAllocation is the vm operation used to GC. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 |
// Within the VM operation after the GC the attempt to allocate the metadata |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 |
// should succeed. If the GC did not free enough space for the metaspace |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 |
// allocation, the HWM is increased so that another virtualspace will be |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 |
// allocated for the metadata. With perm gen the increase in the perm |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 |
// gen had bounds, MinMetaspaceExpansion and MaxMetaspaceExpansion. The |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 |
// metaspace policy uses those as the small and large steps for the HWM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 |
// After the GC the compute_new_size() for MetaspaceGC is called to |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 |
// resize the capacity of the metaspaces. The current implementation |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
93 |
// is based on the flags MinMetaspaceFreeRatio and MaxMetaspaceFreeRatio used |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 |
// to resize the Java heap by some GC's. New flags can be implemented |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
95 |
// if really needed. MinMetaspaceFreeRatio is used to calculate how much |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
96 |
// free space is desirable in the metaspace capacity to decide how much |
15610
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
97 |
// to increase the HWM. MaxMetaspaceFreeRatio is used to decide how much |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
98 |
// free space is desirable in the metaspace capacity before decreasing |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 |
// the HWM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
100 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 |
// Calculate the amount to increase the high water mark (HWM). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 |
// Increase by a minimum amount (MinMetaspaceExpansion) so that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 |
// another expansion is not requested too soon. If that is not |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
104 |
// enough to satisfy the allocation, increase by MaxMetaspaceExpansion. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
105 |
// If that is still not enough, expand by the size of the allocation |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
106 |
// plus some. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
107 |
size_t MetaspaceGC::delta_capacity_until_GC(size_t bytes) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
108 |
size_t min_delta = MinMetaspaceExpansion; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
109 |
size_t max_delta = MaxMetaspaceExpansion; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
110 |
size_t delta = align_up(bytes, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
111 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
112 |
if (delta <= min_delta) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
113 |
delta = min_delta; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
114 |
} else if (delta <= max_delta) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 |
// Don't want to hit the high water mark on the next |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 |
// allocation so make the delta greater than just enough |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 |
// for this allocation. |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
118 |
delta = max_delta; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
119 |
} else { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
120 |
// This allocation is large but the next ones are probably not |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
121 |
// so increase by the minimum. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
122 |
delta = delta + min_delta; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
124 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
125 |
assert_is_aligned(delta, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
126 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
127 |
return delta; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
128 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
129 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
130 |
size_t MetaspaceGC::capacity_until_GC() { |
59247
56bf71d64d51
8234562: Move OrderAccess::release_store*/load_acquire to Atomic
stefank
parents:
59070
diff
changeset
|
131 |
size_t value = Atomic::load_acquire(&_capacity_until_GC); |
27693
3eee985a97e7
8059492: Wrong spelling in assert: "Not initialied properly?"
aharlap
parents:
27683
diff
changeset
|
132 |
assert(value >= MetaspaceSize, "Not initialized properly?"); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
133 |
return value; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
134 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
135 |
|
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
136 |
// Try to increase the _capacity_until_GC limit counter by v bytes. |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
137 |
// Returns true if it succeeded. It may fail if either another thread |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
138 |
// concurrently increased the limit or the new limit would be larger |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
139 |
// than MaxMetaspaceSize. |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
140 |
// On success, optionally returns new and old metaspace capacity in |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
141 |
// new_cap_until_GC and old_cap_until_GC respectively. |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
142 |
// On error, optionally sets can_retry to indicate whether if there is |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
143 |
// actually enough space remaining to satisfy the request. |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
144 |
bool MetaspaceGC::inc_capacity_until_GC(size_t v, size_t* new_cap_until_GC, size_t* old_cap_until_GC, bool* can_retry) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
145 |
assert_is_aligned(v, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
146 |
|
50283
2f9811d99ba8
8203262: Incorrect cmpxchg usage in MetaspaceGC::inc_capacity_until_GC
tschatzl
parents:
50193
diff
changeset
|
147 |
size_t old_capacity_until_GC = _capacity_until_GC; |
2f9811d99ba8
8203262: Incorrect cmpxchg usage in MetaspaceGC::inc_capacity_until_GC
tschatzl
parents:
50193
diff
changeset
|
148 |
size_t new_value = old_capacity_until_GC + v; |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
149 |
|
50283
2f9811d99ba8
8203262: Incorrect cmpxchg usage in MetaspaceGC::inc_capacity_until_GC
tschatzl
parents:
50193
diff
changeset
|
150 |
if (new_value < old_capacity_until_GC) { |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
151 |
// The addition wrapped around, set new_value to aligned max value. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
152 |
new_value = align_down(max_uintx, Metaspace::commit_alignment()); |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
153 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
154 |
|
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
155 |
if (new_value > MaxMetaspaceSize) { |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
156 |
if (can_retry != NULL) { |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
157 |
*can_retry = false; |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
158 |
} |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
159 |
return false; |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
160 |
} |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
161 |
|
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
162 |
if (can_retry != NULL) { |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
163 |
*can_retry = true; |
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
164 |
} |
59252
623722a6aeb9
8234740: Harmonize parameter order in Atomic - cmpxchg
stefank
parents:
59250
diff
changeset
|
165 |
size_t prev_value = Atomic::cmpxchg(&_capacity_until_GC, old_capacity_until_GC, new_value); |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
166 |
|
50283
2f9811d99ba8
8203262: Incorrect cmpxchg usage in MetaspaceGC::inc_capacity_until_GC
tschatzl
parents:
50193
diff
changeset
|
167 |
if (old_capacity_until_GC != prev_value) { |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
168 |
return false; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
169 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
170 |
|
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
171 |
if (new_cap_until_GC != NULL) { |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
172 |
*new_cap_until_GC = new_value; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
173 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
174 |
if (old_cap_until_GC != NULL) { |
50283
2f9811d99ba8
8203262: Incorrect cmpxchg usage in MetaspaceGC::inc_capacity_until_GC
tschatzl
parents:
50193
diff
changeset
|
175 |
*old_cap_until_GC = old_capacity_until_GC; |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
176 |
} |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
177 |
return true; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
178 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
179 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
180 |
size_t MetaspaceGC::dec_capacity_until_GC(size_t v) { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
181 |
assert_is_aligned(v, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
182 |
|
59250
a6deb69743d4
8234738: Harmonize parameter order in Atomic - sub
stefank
parents:
59249
diff
changeset
|
183 |
return Atomic::sub(&_capacity_until_GC, v); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
184 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
185 |
|
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
186 |
void MetaspaceGC::initialize() { |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
187 |
// Set the high-water mark to MaxMetapaceSize during VM initializaton since |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
188 |
// we can't do a GC during initialization. |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
189 |
_capacity_until_GC = MaxMetaspaceSize; |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
190 |
} |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
191 |
|
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
192 |
void MetaspaceGC::post_initialize() { |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
193 |
// Reset the high-water mark once the VM initialization is done. |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
194 |
_capacity_until_GC = MAX2(MetaspaceUtils::committed_bytes(), MetaspaceSize); |
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
195 |
} |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
196 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
197 |
bool MetaspaceGC::can_expand(size_t word_size, bool is_class) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
198 |
// Check if the compressed class space is full. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
199 |
if (is_class && Metaspace::using_class_space()) { |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
200 |
size_t class_committed = MetaspaceUtils::committed_bytes(Metaspace::ClassType); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
201 |
if (class_committed + word_size * BytesPerWord > CompressedClassSpaceSize) { |
49365 | 202 |
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (CompressedClassSpaceSize = " SIZE_FORMAT " words)", |
203 |
(is_class ? "class" : "non-class"), word_size, CompressedClassSpaceSize / sizeof(MetaWord)); |
|
18491
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
204 |
return false; |
dd63ba6b0ee4
8015391: NPG: With -XX:+UseCompressedKlassPointers OOME due to exhausted metadata space could occur when metaspace is almost empty
coleenp
parents:
17858
diff
changeset
|
205 |
} |
16391
7bf8a7699f5f
8004241: NPG: Metaspace occupies more memory than specified by -XX:MaxMetaspaceSize option
mgerdin
parents:
16387
diff
changeset
|
206 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
207 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
208 |
// Check if the user has imposed a limit on the metaspace memory. |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
209 |
size_t committed_bytes = MetaspaceUtils::committed_bytes(); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
210 |
if (committed_bytes + word_size * BytesPerWord > MaxMetaspaceSize) { |
49365 | 211 |
log_trace(gc, metaspace, freelist)("Cannot expand %s metaspace by " SIZE_FORMAT " words (MaxMetaspaceSize = " SIZE_FORMAT " words)", |
212 |
(is_class ? "class" : "non-class"), word_size, MaxMetaspaceSize / sizeof(MetaWord)); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
213 |
return false; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
214 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
215 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
216 |
return true; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
217 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
218 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
219 |
size_t MetaspaceGC::allowed_expansion() { |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
220 |
size_t committed_bytes = MetaspaceUtils::committed_bytes(); |
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
221 |
size_t capacity_until_gc = capacity_until_GC(); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
222 |
|
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
223 |
assert(capacity_until_gc >= committed_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
224 |
"capacity_until_gc: " SIZE_FORMAT " < committed_bytes: " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
225 |
capacity_until_gc, committed_bytes); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
226 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
227 |
size_t left_until_max = MaxMetaspaceSize - committed_bytes; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
228 |
size_t left_until_GC = capacity_until_gc - committed_bytes; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
229 |
size_t left_to_commit = MIN2(left_until_GC, left_until_max); |
49365 | 230 |
log_trace(gc, metaspace, freelist)("allowed expansion words: " SIZE_FORMAT |
231 |
" (left_until_max: " SIZE_FORMAT ", left_until_GC: " SIZE_FORMAT ".", |
|
232 |
left_to_commit / BytesPerWord, left_until_max / BytesPerWord, left_until_GC / BytesPerWord); |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
233 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
234 |
return left_to_commit / BytesPerWord; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
235 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
236 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
237 |
void MetaspaceGC::compute_new_size() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
238 |
assert(_shrink_factor <= 100, "invalid shrink factor"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
239 |
uint current_shrink_factor = _shrink_factor; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
240 |
_shrink_factor = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
241 |
|
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
242 |
// Using committed_bytes() for used_after_gc is an overestimation, since the |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
243 |
// chunk free lists are included in committed_bytes() and the memory in an |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
244 |
// un-fragmented chunk free list is available for future allocations. |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
245 |
// However, if the chunk free lists becomes fragmented, then the memory may |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
246 |
// not be available for future allocations and the memory is therefore "in use". |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
247 |
// Including the chunk free lists in the definition of "in use" is therefore |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
248 |
// necessary. Not including the chunk free lists can cause capacity_until_GC to |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
249 |
// shrink below committed_bytes() and this has caused serious bugs in the past. |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
250 |
const size_t used_after_gc = MetaspaceUtils::committed_bytes(); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
251 |
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
252 |
|
15610
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
253 |
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
254 |
const double maximum_used_percentage = 1.0 - minimum_free_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
255 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
256 |
const double min_tmp = used_after_gc / maximum_used_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
257 |
size_t minimum_desired_capacity = |
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
258 |
(size_t)MIN2(min_tmp, double(MaxMetaspaceSize)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
259 |
// Don't shrink less than the initial generation size |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
260 |
minimum_desired_capacity = MAX2(minimum_desired_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
261 |
MetaspaceSize); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
262 |
|
35061 | 263 |
log_trace(gc, metaspace)("MetaspaceGC::compute_new_size: "); |
264 |
log_trace(gc, metaspace)(" minimum_free_percentage: %6.2f maximum_used_percentage: %6.2f", |
|
265 |
minimum_free_percentage, maximum_used_percentage); |
|
266 |
log_trace(gc, metaspace)(" used_after_gc : %6.1fKB", used_after_gc / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
267 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
268 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
269 |
size_t shrink_bytes = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
270 |
if (capacity_until_GC < minimum_desired_capacity) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
271 |
// If we have less capacity below the metaspace HWM, then |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
272 |
// increment the HWM. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
273 |
size_t expand_bytes = minimum_desired_capacity - capacity_until_GC; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
274 |
expand_bytes = align_up(expand_bytes, Metaspace::commit_alignment()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
275 |
// Don't expand unless it's significant |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
276 |
if (expand_bytes >= MinMetaspaceExpansion) { |
26938
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
277 |
size_t new_capacity_until_GC = 0; |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
278 |
bool succeeded = MetaspaceGC::inc_capacity_until_GC(expand_bytes, &new_capacity_until_GC); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
279 |
assert(succeeded, "Should always succesfully increment HWM when at safepoint"); |
e0b35f8104a7
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
26304
diff
changeset
|
280 |
|
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
281 |
Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
282 |
new_capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
283 |
MetaspaceGCThresholdUpdater::ComputeNewSize); |
35061 | 284 |
log_trace(gc, metaspace)(" expanding: minimum_desired_capacity: %6.1fKB expand_bytes: %6.1fKB MinMetaspaceExpansion: %6.1fKB new metaspace HWM: %6.1fKB", |
285 |
minimum_desired_capacity / (double) K, |
|
286 |
expand_bytes / (double) K, |
|
287 |
MinMetaspaceExpansion / (double) K, |
|
288 |
new_capacity_until_GC / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
289 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
290 |
return; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
291 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
292 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
293 |
// No expansion, now see if we want to shrink |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
294 |
// We would never want to shrink more than this |
22499 | 295 |
assert(capacity_until_GC >= minimum_desired_capacity, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
296 |
SIZE_FORMAT " >= " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
297 |
capacity_until_GC, minimum_desired_capacity); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
298 |
size_t max_shrink_bytes = capacity_until_GC - minimum_desired_capacity; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
299 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
300 |
// Should shrinking be considered? |
15610
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
301 |
if (MaxMetaspaceFreeRatio < 100) { |
528d799702c7
8005452: NPG: Create new flags for Metaspace resizing policy
jmasa
parents:
15488
diff
changeset
|
302 |
const double maximum_free_percentage = MaxMetaspaceFreeRatio / 100.0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
303 |
const double minimum_used_percentage = 1.0 - maximum_free_percentage; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
304 |
const double max_tmp = used_after_gc / minimum_used_percentage; |
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
305 |
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(MaxMetaspaceSize)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
306 |
maximum_desired_capacity = MAX2(maximum_desired_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
307 |
MetaspaceSize); |
35061 | 308 |
log_trace(gc, metaspace)(" maximum_free_percentage: %6.2f minimum_used_percentage: %6.2f", |
309 |
maximum_free_percentage, minimum_used_percentage); |
|
310 |
log_trace(gc, metaspace)(" minimum_desired_capacity: %6.1fKB maximum_desired_capacity: %6.1fKB", |
|
311 |
minimum_desired_capacity / (double) K, maximum_desired_capacity / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
312 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
313 |
assert(minimum_desired_capacity <= maximum_desired_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
314 |
"sanity check"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
315 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
316 |
if (capacity_until_GC > maximum_desired_capacity) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
317 |
// Capacity too large, compute shrinking size |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
318 |
shrink_bytes = capacity_until_GC - maximum_desired_capacity; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
319 |
// We don't want shrink all the way back to initSize if people call |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
320 |
// System.gc(), because some programs do that between "phases" and then |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
321 |
// we'd just have to grow the heap up again for the next phase. So we |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
322 |
// damp the shrinking: 0% on the first call, 10% on the second call, 40% |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
323 |
// on the third call, and 100% by the fourth call. But if we recompute |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
324 |
// size without shrinking, it goes back to 0%. |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
325 |
shrink_bytes = shrink_bytes / 100 * current_shrink_factor; |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
326 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
327 |
shrink_bytes = align_down(shrink_bytes, Metaspace::commit_alignment()); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
328 |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
329 |
assert(shrink_bytes <= max_shrink_bytes, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
330 |
"invalid shrink size " SIZE_FORMAT " not <= " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
331 |
shrink_bytes, max_shrink_bytes); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
332 |
if (current_shrink_factor == 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
333 |
_shrink_factor = 10; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
334 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
335 |
_shrink_factor = MIN2(current_shrink_factor * 4, (uint) 100); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
336 |
} |
37151
bcda1fb89431
8151845: Comment in globals.hpp for MetaspaceSize is incorrect.
jmasa
parents:
37139
diff
changeset
|
337 |
log_trace(gc, metaspace)(" shrinking: initThreshold: %.1fK maximum_desired_capacity: %.1fK", |
35061 | 338 |
MetaspaceSize / (double) K, maximum_desired_capacity / (double) K); |
339 |
log_trace(gc, metaspace)(" shrink_bytes: %.1fK current_shrink_factor: %d new shrink factor: %d MinMetaspaceExpansion: %.1fK", |
|
340 |
shrink_bytes / (double) K, current_shrink_factor, _shrink_factor, MinMetaspaceExpansion / (double) K); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
341 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
342 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
343 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
344 |
// Don't shrink unless it's significant |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
345 |
if (shrink_bytes >= MinMetaspaceExpansion && |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
346 |
((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) { |
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
347 |
size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes); |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
348 |
Metaspace::tracer()->report_gc_threshold(capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
349 |
new_capacity_until_GC, |
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
350 |
MetaspaceGCThresholdUpdater::ComputeNewSize); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
351 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
352 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
353 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
354 |
// MetaspaceUtils |
49980 | 355 |
size_t MetaspaceUtils::_capacity_words [Metaspace:: MetadataTypeCount] = {0, 0}; |
356 |
size_t MetaspaceUtils::_overhead_words [Metaspace:: MetadataTypeCount] = {0, 0}; |
|
357 |
volatile size_t MetaspaceUtils::_used_words [Metaspace:: MetadataTypeCount] = {0, 0}; |
|
358 |
||
359 |
// Collect used metaspace statistics. This involves walking the CLDG. The resulting |
|
360 |
// output will be the accumulated values for all live metaspaces. |
|
361 |
// Note: method does not do any locking. |
|
362 |
void MetaspaceUtils::collect_statistics(ClassLoaderMetaspaceStatistics* out) { |
|
363 |
out->reset(); |
|
364 |
ClassLoaderDataGraphMetaspaceIterator iter; |
|
365 |
while (iter.repeat()) { |
|
366 |
ClassLoaderMetaspace* msp = iter.get_next(); |
|
367 |
if (msp != NULL) { |
|
368 |
msp->add_to_statistics(out); |
|
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
size_t MetaspaceUtils::free_in_vs_bytes(Metaspace::MetadataType mdtype) { |
|
19322
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
374 |
VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
375 |
return list == NULL ? 0 : list->free_bytes(); |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
376 |
} |
e35f9ed4f081
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
19319
diff
changeset
|
377 |
|
49980 | 378 |
size_t MetaspaceUtils::free_in_vs_bytes() { |
379 |
return free_in_vs_bytes(Metaspace::ClassType) + free_in_vs_bytes(Metaspace::NonClassType); |
|
380 |
} |
|
381 |
||
382 |
static void inc_stat_nonatomically(size_t* pstat, size_t words) { |
|
383 |
assert_lock_strong(MetaspaceExpand_lock); |
|
384 |
(*pstat) += words; |
|
385 |
} |
|
386 |
||
387 |
static void dec_stat_nonatomically(size_t* pstat, size_t words) { |
|
388 |
assert_lock_strong(MetaspaceExpand_lock); |
|
389 |
const size_t size_now = *pstat; |
|
390 |
assert(size_now >= words, "About to decrement counter below zero " |
|
391 |
"(current value: " SIZE_FORMAT ", decrement value: " SIZE_FORMAT ".", |
|
392 |
size_now, words); |
|
393 |
*pstat = size_now - words; |
|
394 |
} |
|
395 |
||
396 |
static void inc_stat_atomically(volatile size_t* pstat, size_t words) { |
|
59249
29b0d0b61615
8234737: Harmonize parameter order in Atomic - add
stefank
parents:
59247
diff
changeset
|
397 |
Atomic::add(pstat, words); |
49980 | 398 |
} |
399 |
||
400 |
static void dec_stat_atomically(volatile size_t* pstat, size_t words) { |
|
401 |
const size_t size_now = *pstat; |
|
402 |
assert(size_now >= words, "About to decrement counter below zero " |
|
403 |
"(current value: " SIZE_FORMAT ", decrement value: " SIZE_FORMAT ".", |
|
404 |
size_now, words); |
|
59250
a6deb69743d4
8234738: Harmonize parameter order in Atomic - sub
stefank
parents:
59249
diff
changeset
|
405 |
Atomic::sub(pstat, words); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
406 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
407 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
408 |
void MetaspaceUtils::dec_capacity(Metaspace::MetadataType mdtype, size_t words) { |
49980 | 409 |
dec_stat_nonatomically(&_capacity_words[mdtype], words); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
410 |
} |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
411 |
void MetaspaceUtils::inc_capacity(Metaspace::MetadataType mdtype, size_t words) { |
49980 | 412 |
inc_stat_nonatomically(&_capacity_words[mdtype], words); |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
413 |
} |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
414 |
void MetaspaceUtils::dec_used(Metaspace::MetadataType mdtype, size_t words) { |
49980 | 415 |
dec_stat_atomically(&_used_words[mdtype], words); |
13733
e41e23ae6758
7195789: NPG: assert(used + free == capacity) failed: Accounting is wrong
jmasa
parents:
13729
diff
changeset
|
416 |
} |
49980 | 417 |
void MetaspaceUtils::inc_used(Metaspace::MetadataType mdtype, size_t words) { |
418 |
inc_stat_atomically(&_used_words[mdtype], words); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
419 |
} |
49980 | 420 |
void MetaspaceUtils::dec_overhead(Metaspace::MetadataType mdtype, size_t words) { |
421 |
dec_stat_nonatomically(&_overhead_words[mdtype], words); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
422 |
} |
49980 | 423 |
void MetaspaceUtils::inc_overhead(Metaspace::MetadataType mdtype, size_t words) { |
424 |
inc_stat_nonatomically(&_overhead_words[mdtype], words); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
425 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
426 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
427 |
size_t MetaspaceUtils::reserved_bytes(Metaspace::MetadataType mdtype) { |
19988 | 428 |
VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
429 |
return list == NULL ? 0 : list->reserved_bytes(); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
430 |
} |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
431 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
432 |
size_t MetaspaceUtils::committed_bytes(Metaspace::MetadataType mdtype) { |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
433 |
VirtualSpaceList* list = Metaspace::get_space_list(mdtype); |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
434 |
return list == NULL ? 0 : list->committed_bytes(); |
19988 | 435 |
} |
436 |
||
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
437 |
size_t MetaspaceUtils::min_chunk_size_words() { return Metaspace::first_chunk_word_size(); } |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
438 |
|
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
439 |
size_t MetaspaceUtils::free_chunks_total_words(Metaspace::MetadataType mdtype) { |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
440 |
ChunkManager* chunk_manager = Metaspace::get_chunk_manager(mdtype); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
441 |
if (chunk_manager == NULL) { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
442 |
return 0; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
443 |
} |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
444 |
return chunk_manager->free_chunks_total_words(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
445 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
446 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
447 |
size_t MetaspaceUtils::free_chunks_total_bytes(Metaspace::MetadataType mdtype) { |
19988 | 448 |
return free_chunks_total_words(mdtype) * BytesPerWord; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
449 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
450 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
451 |
size_t MetaspaceUtils::free_chunks_total_words() { |
19988 | 452 |
return free_chunks_total_words(Metaspace::ClassType) + |
453 |
free_chunks_total_words(Metaspace::NonClassType); |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
454 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
455 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
456 |
size_t MetaspaceUtils::free_chunks_total_bytes() { |
19988 | 457 |
return free_chunks_total_words() * BytesPerWord; |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
458 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
459 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
460 |
bool MetaspaceUtils::has_chunk_free_list(Metaspace::MetadataType mdtype) { |
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
461 |
return Metaspace::get_chunk_manager(mdtype) != NULL; |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
462 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
463 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
464 |
MetaspaceChunkFreeListSummary MetaspaceUtils::chunk_free_list_summary(Metaspace::MetadataType mdtype) { |
23470
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
465 |
if (!has_chunk_free_list(mdtype)) { |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
466 |
return MetaspaceChunkFreeListSummary(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
467 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
468 |
|
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
469 |
const ChunkManager* cm = Metaspace::get_chunk_manager(mdtype); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
470 |
return cm->chunk_free_list_summary(); |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
471 |
} |
ff2a7ea4225d
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
23469
diff
changeset
|
472 |
|
55576
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
473 |
void MetaspaceUtils::print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values) { |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
474 |
const metaspace::MetaspaceSizesSnapshot meta_values; |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
475 |
|
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
476 |
if (Metaspace::using_class_space()) { |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
477 |
log_info(gc, metaspace)(HEAP_CHANGE_FORMAT" " |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
478 |
HEAP_CHANGE_FORMAT" " |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
479 |
HEAP_CHANGE_FORMAT, |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
480 |
HEAP_CHANGE_FORMAT_ARGS("Metaspace", |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
481 |
pre_meta_values.used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
482 |
pre_meta_values.committed(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
483 |
meta_values.used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
484 |
meta_values.committed()), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
485 |
HEAP_CHANGE_FORMAT_ARGS("NonClass", |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
486 |
pre_meta_values.non_class_used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
487 |
pre_meta_values.non_class_committed(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
488 |
meta_values.non_class_used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
489 |
meta_values.non_class_committed()), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
490 |
HEAP_CHANGE_FORMAT_ARGS("Class", |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
491 |
pre_meta_values.class_used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
492 |
pre_meta_values.class_committed(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
493 |
meta_values.class_used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
494 |
meta_values.class_committed())); |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
495 |
} else { |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
496 |
log_info(gc, metaspace)(HEAP_CHANGE_FORMAT, |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
497 |
HEAP_CHANGE_FORMAT_ARGS("Metaspace", |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
498 |
pre_meta_values.used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
499 |
pre_meta_values.committed(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
500 |
meta_values.used(), |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
501 |
meta_values.committed())); |
4d193e40e7af
8223575: add subspace transitions to gc+metaspace=info log lines
tonyp
parents:
55545
diff
changeset
|
502 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
503 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
504 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
505 |
void MetaspaceUtils::print_on(outputStream* out) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
506 |
Metaspace::MetadataType nct = Metaspace::NonClassType; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
507 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
508 |
out->print_cr(" Metaspace " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
509 |
"used " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
510 |
"capacity " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
511 |
"committed " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
512 |
"reserved " SIZE_FORMAT "K", |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
513 |
used_bytes()/K, |
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
514 |
capacity_bytes()/K, |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
515 |
committed_bytes()/K, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
516 |
reserved_bytes()/K); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
517 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
518 |
if (Metaspace::using_class_space()) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
519 |
Metaspace::MetadataType ct = Metaspace::ClassType; |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
520 |
out->print_cr(" class space " |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
521 |
"used " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
522 |
"capacity " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
523 |
"committed " SIZE_FORMAT "K, " |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
524 |
"reserved " SIZE_FORMAT "K", |
23854
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
525 |
used_bytes(ct)/K, |
50f7f89b34e0
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
23503
diff
changeset
|
526 |
capacity_bytes(ct)/K, |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
527 |
committed_bytes(ct)/K, |
19988 | 528 |
reserved_bytes(ct)/K); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
529 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
530 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
531 |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
532 |
|
49980 | 533 |
void MetaspaceUtils::print_vs(outputStream* out, size_t scale) { |
534 |
const size_t reserved_nonclass_words = reserved_bytes(Metaspace::NonClassType) / sizeof(MetaWord); |
|
535 |
const size_t committed_nonclass_words = committed_bytes(Metaspace::NonClassType) / sizeof(MetaWord); |
|
536 |
{ |
|
537 |
if (Metaspace::using_class_space()) { |
|
538 |
out->print(" Non-class space: "); |
|
539 |
} |
|
540 |
print_scaled_words(out, reserved_nonclass_words, scale, 7); |
|
541 |
out->print(" reserved, "); |
|
542 |
print_scaled_words_and_percentage(out, committed_nonclass_words, reserved_nonclass_words, scale, 7); |
|
543 |
out->print_cr(" committed "); |
|
544 |
||
545 |
if (Metaspace::using_class_space()) { |
|
546 |
const size_t reserved_class_words = reserved_bytes(Metaspace::ClassType) / sizeof(MetaWord); |
|
547 |
const size_t committed_class_words = committed_bytes(Metaspace::ClassType) / sizeof(MetaWord); |
|
548 |
out->print(" Class space: "); |
|
549 |
print_scaled_words(out, reserved_class_words, scale, 7); |
|
550 |
out->print(" reserved, "); |
|
551 |
print_scaled_words_and_percentage(out, committed_class_words, reserved_class_words, scale, 7); |
|
552 |
out->print_cr(" committed "); |
|
553 |
||
554 |
const size_t reserved_words = reserved_nonclass_words + reserved_class_words; |
|
555 |
const size_t committed_words = committed_nonclass_words + committed_class_words; |
|
556 |
out->print(" Both: "); |
|
557 |
print_scaled_words(out, reserved_words, scale, 7); |
|
558 |
out->print(" reserved, "); |
|
559 |
print_scaled_words_and_percentage(out, committed_words, reserved_words, scale, 7); |
|
560 |
out->print_cr(" committed "); |
|
561 |
} |
|
562 |
} |
|
563 |
} |
|
564 |
||
54341
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
565 |
static void print_basic_switches(outputStream* out, size_t scale) { |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
566 |
out->print("MaxMetaspaceSize: "); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
567 |
if (MaxMetaspaceSize >= (max_uintx) - (2 * os::vm_page_size())) { |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
568 |
// aka "very big". Default is max_uintx, but due to rounding in arg parsing the real |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
569 |
// value is smaller. |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
570 |
out->print("unlimited"); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
571 |
} else { |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
572 |
print_human_readable_size(out, MaxMetaspaceSize, scale); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
573 |
} |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
574 |
out->cr(); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
575 |
if (Metaspace::using_class_space()) { |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
576 |
out->print("CompressedClassSpaceSize: "); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
577 |
print_human_readable_size(out, CompressedClassSpaceSize, scale); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
578 |
} |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
579 |
out->cr(); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
580 |
} |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
581 |
|
49980 | 582 |
// This will print out a basic metaspace usage report but |
583 |
// unlike print_report() is guaranteed not to lock or to walk the CLDG. |
|
584 |
void MetaspaceUtils::print_basic_report(outputStream* out, size_t scale) { |
|
585 |
||
55586
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
586 |
if (!Metaspace::initialized()) { |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
587 |
out->print_cr("Metaspace not yet initialized."); |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
588 |
return; |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
589 |
} |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
590 |
|
49980 | 591 |
out->cr(); |
592 |
out->print_cr("Usage:"); |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
593 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
594 |
if (Metaspace::using_class_space()) { |
49980 | 595 |
out->print(" Non-class: "); |
596 |
} |
|
597 |
||
598 |
// In its most basic form, we do not require walking the CLDG. Instead, just print the running totals from |
|
599 |
// MetaspaceUtils. |
|
600 |
const size_t cap_nc = MetaspaceUtils::capacity_words(Metaspace::NonClassType); |
|
601 |
const size_t overhead_nc = MetaspaceUtils::overhead_words(Metaspace::NonClassType); |
|
602 |
const size_t used_nc = MetaspaceUtils::used_words(Metaspace::NonClassType); |
|
603 |
const size_t free_and_waste_nc = cap_nc - overhead_nc - used_nc; |
|
604 |
||
605 |
print_scaled_words(out, cap_nc, scale, 5); |
|
606 |
out->print(" capacity, "); |
|
607 |
print_scaled_words_and_percentage(out, used_nc, cap_nc, scale, 5); |
|
608 |
out->print(" used, "); |
|
609 |
print_scaled_words_and_percentage(out, free_and_waste_nc, cap_nc, scale, 5); |
|
610 |
out->print(" free+waste, "); |
|
611 |
print_scaled_words_and_percentage(out, overhead_nc, cap_nc, scale, 5); |
|
612 |
out->print(" overhead. "); |
|
613 |
out->cr(); |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
614 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
615 |
if (Metaspace::using_class_space()) { |
49980 | 616 |
const size_t cap_c = MetaspaceUtils::capacity_words(Metaspace::ClassType); |
617 |
const size_t overhead_c = MetaspaceUtils::overhead_words(Metaspace::ClassType); |
|
618 |
const size_t used_c = MetaspaceUtils::used_words(Metaspace::ClassType); |
|
619 |
const size_t free_and_waste_c = cap_c - overhead_c - used_c; |
|
620 |
out->print(" Class: "); |
|
621 |
print_scaled_words(out, cap_c, scale, 5); |
|
622 |
out->print(" capacity, "); |
|
623 |
print_scaled_words_and_percentage(out, used_c, cap_c, scale, 5); |
|
624 |
out->print(" used, "); |
|
625 |
print_scaled_words_and_percentage(out, free_and_waste_c, cap_c, scale, 5); |
|
626 |
out->print(" free+waste, "); |
|
627 |
print_scaled_words_and_percentage(out, overhead_c, cap_c, scale, 5); |
|
628 |
out->print(" overhead. "); |
|
629 |
out->cr(); |
|
630 |
||
631 |
out->print(" Both: "); |
|
632 |
const size_t cap = cap_nc + cap_c; |
|
633 |
||
634 |
print_scaled_words(out, cap, scale, 5); |
|
635 |
out->print(" capacity, "); |
|
636 |
print_scaled_words_and_percentage(out, used_nc + used_c, cap, scale, 5); |
|
637 |
out->print(" used, "); |
|
638 |
print_scaled_words_and_percentage(out, free_and_waste_nc + free_and_waste_c, cap, scale, 5); |
|
639 |
out->print(" free+waste, "); |
|
640 |
print_scaled_words_and_percentage(out, overhead_nc + overhead_c, cap, scale, 5); |
|
641 |
out->print(" overhead. "); |
|
642 |
out->cr(); |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
643 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
644 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
645 |
out->cr(); |
49980 | 646 |
out->print_cr("Virtual space:"); |
647 |
||
648 |
print_vs(out, scale); |
|
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
649 |
|
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
650 |
out->cr(); |
49980 | 651 |
out->print_cr("Chunk freelists:"); |
652 |
||
653 |
if (Metaspace::using_class_space()) { |
|
654 |
out->print(" Non-Class: "); |
|
655 |
} |
|
53598
69ccc5584e12
8218156: "jcmd VM.metaspace basic" misreports free chunk space
stuefe
parents:
53547
diff
changeset
|
656 |
print_human_readable_size(out, Metaspace::chunk_manager_metadata()->free_chunks_total_bytes(), scale); |
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
657 |
out->cr(); |
49980 | 658 |
if (Metaspace::using_class_space()) { |
659 |
out->print(" Class: "); |
|
53598
69ccc5584e12
8218156: "jcmd VM.metaspace basic" misreports free chunk space
stuefe
parents:
53547
diff
changeset
|
660 |
print_human_readable_size(out, Metaspace::chunk_manager_class()->free_chunks_total_bytes(), scale); |
49980 | 661 |
out->cr(); |
662 |
out->print(" Both: "); |
|
53598
69ccc5584e12
8218156: "jcmd VM.metaspace basic" misreports free chunk space
stuefe
parents:
53547
diff
changeset
|
663 |
print_human_readable_size(out, Metaspace::chunk_manager_class()->free_chunks_total_bytes() + |
69ccc5584e12
8218156: "jcmd VM.metaspace basic" misreports free chunk space
stuefe
parents:
53547
diff
changeset
|
664 |
Metaspace::chunk_manager_metadata()->free_chunks_total_bytes(), scale); |
49980 | 665 |
out->cr(); |
666 |
} |
|
54341
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
667 |
|
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
668 |
out->cr(); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
669 |
|
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
670 |
// Print basic settings |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
671 |
print_basic_switches(out, scale); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
672 |
|
49980 | 673 |
out->cr(); |
674 |
||
47802
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
675 |
} |
18dccdc438d7
8189688: NMT: Report per-class load metadata information
zgu
parents:
47654
diff
changeset
|
676 |
|
49980 | 677 |
void MetaspaceUtils::print_report(outputStream* out, size_t scale, int flags) { |
678 |
||
55586
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
679 |
if (!Metaspace::initialized()) { |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
680 |
out->print_cr("Metaspace not yet initialized."); |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
681 |
return; |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
682 |
} |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
683 |
|
49980 | 684 |
const bool print_loaders = (flags & rf_show_loaders) > 0; |
50309
37ebfe8bac7f
8203219: VM.metaspace jcmd should optionally show loaded classes for loaders
stuefe
parents:
50283
diff
changeset
|
685 |
const bool print_classes = (flags & rf_show_classes) > 0; |
49980 | 686 |
const bool print_by_chunktype = (flags & rf_break_down_by_chunktype) > 0; |
687 |
const bool print_by_spacetype = (flags & rf_break_down_by_spacetype) > 0; |
|
688 |
||
689 |
// Some report options require walking the class loader data graph. |
|
50309
37ebfe8bac7f
8203219: VM.metaspace jcmd should optionally show loaded classes for loaders
stuefe
parents:
50283
diff
changeset
|
690 |
PrintCLDMetaspaceInfoClosure cl(out, scale, print_loaders, print_classes, print_by_chunktype); |
49980 | 691 |
if (print_loaders) { |
692 |
out->cr(); |
|
693 |
out->print_cr("Usage per loader:"); |
|
694 |
out->cr(); |
|
695 |
} |
|
696 |
||
52586
74109912c738
8213751: ClassLoaderDataGraph::cld_do() should sometimes require CLDG_lock
coleenp
parents:
52468
diff
changeset
|
697 |
ClassLoaderDataGraph::loaded_cld_do(&cl); // collect data and optionally print |
49980 | 698 |
|
699 |
// Print totals, broken up by space type. |
|
700 |
if (print_by_spacetype) { |
|
701 |
out->cr(); |
|
702 |
out->print_cr("Usage per space type:"); |
|
703 |
out->cr(); |
|
704 |
for (int space_type = (int)Metaspace::ZeroMetaspaceType; |
|
705 |
space_type < (int)Metaspace::MetaspaceTypeCount; space_type ++) |
|
706 |
{ |
|
54820 | 707 |
uintx num_loaders = cl._num_loaders_by_spacetype[space_type]; |
708 |
uintx num_classes = cl._num_classes_by_spacetype[space_type]; |
|
709 |
out->print("%s - " UINTX_FORMAT " %s", |
|
49980 | 710 |
space_type_name((Metaspace::MetaspaceType)space_type), |
54820 | 711 |
num_loaders, loaders_plural(num_loaders)); |
712 |
if (num_classes > 0) { |
|
713 |
out->print(", "); |
|
714 |
print_number_of_classes(out, num_classes, cl._num_classes_shared_by_spacetype[space_type]); |
|
715 |
out->print(":"); |
|
49980 | 716 |
cl._stats_by_spacetype[space_type].print_on(out, scale, print_by_chunktype); |
54820 | 717 |
} else { |
718 |
out->print("."); |
|
719 |
out->cr(); |
|
49980 | 720 |
} |
721 |
out->cr(); |
|
722 |
} |
|
723 |
} |
|
724 |
||
725 |
// Print totals for in-use data: |
|
726 |
out->cr(); |
|
54820 | 727 |
{ |
728 |
uintx num_loaders = cl._num_loaders; |
|
729 |
out->print("Total Usage - " UINTX_FORMAT " %s, ", |
|
730 |
num_loaders, loaders_plural(num_loaders)); |
|
731 |
print_number_of_classes(out, cl._num_classes, cl._num_classes_shared); |
|
732 |
out->print(":"); |
|
733 |
cl._stats_total.print_on(out, scale, print_by_chunktype); |
|
734 |
out->cr(); |
|
735 |
} |
|
49980 | 736 |
|
737 |
// -- Print Virtual space. |
|
738 |
out->cr(); |
|
739 |
out->print_cr("Virtual space:"); |
|
740 |
||
741 |
print_vs(out, scale); |
|
742 |
||
743 |
// -- Print VirtualSpaceList details. |
|
744 |
if ((flags & rf_show_vslist) > 0) { |
|
745 |
out->cr(); |
|
746 |
out->print_cr("Virtual space list%s:", Metaspace::using_class_space() ? "s" : ""); |
|
747 |
||
748 |
if (Metaspace::using_class_space()) { |
|
749 |
out->print_cr(" Non-Class:"); |
|
750 |
} |
|
751 |
Metaspace::space_list()->print_on(out, scale); |
|
752 |
if (Metaspace::using_class_space()) { |
|
753 |
out->print_cr(" Class:"); |
|
754 |
Metaspace::class_space_list()->print_on(out, scale); |
|
755 |
} |
|
756 |
} |
|
757 |
out->cr(); |
|
758 |
||
759 |
// -- Print VirtualSpaceList map. |
|
760 |
if ((flags & rf_show_vsmap) > 0) { |
|
761 |
out->cr(); |
|
762 |
out->print_cr("Virtual space map:"); |
|
763 |
||
764 |
if (Metaspace::using_class_space()) { |
|
765 |
out->print_cr(" Non-Class:"); |
|
766 |
} |
|
767 |
Metaspace::space_list()->print_map(out); |
|
768 |
if (Metaspace::using_class_space()) { |
|
769 |
out->print_cr(" Class:"); |
|
770 |
Metaspace::class_space_list()->print_map(out); |
|
771 |
} |
|
772 |
} |
|
773 |
out->cr(); |
|
774 |
||
775 |
// -- Print Freelists (ChunkManager) details |
|
776 |
out->cr(); |
|
777 |
out->print_cr("Chunk freelist%s:", Metaspace::using_class_space() ? "s" : ""); |
|
778 |
||
779 |
ChunkManagerStatistics non_class_cm_stat; |
|
780 |
Metaspace::chunk_manager_metadata()->collect_statistics(&non_class_cm_stat); |
|
781 |
||
782 |
if (Metaspace::using_class_space()) { |
|
783 |
out->print_cr(" Non-Class:"); |
|
784 |
} |
|
785 |
non_class_cm_stat.print_on(out, scale); |
|
786 |
||
787 |
if (Metaspace::using_class_space()) { |
|
788 |
ChunkManagerStatistics class_cm_stat; |
|
789 |
Metaspace::chunk_manager_class()->collect_statistics(&class_cm_stat); |
|
790 |
out->print_cr(" Class:"); |
|
791 |
class_cm_stat.print_on(out, scale); |
|
792 |
} |
|
793 |
||
794 |
// As a convenience, print a summary of common waste. |
|
795 |
out->cr(); |
|
796 |
out->print("Waste "); |
|
797 |
// For all wastages, print percentages from total. As total use the total size of memory committed for metaspace. |
|
798 |
const size_t committed_words = committed_bytes() / BytesPerWord; |
|
799 |
||
800 |
out->print("(percentages refer to total committed size "); |
|
801 |
print_scaled_words(out, committed_words, scale); |
|
802 |
out->print_cr("):"); |
|
803 |
||
804 |
// Print space committed but not yet used by any class loader |
|
805 |
const size_t unused_words_in_vs = MetaspaceUtils::free_in_vs_bytes() / BytesPerWord; |
|
806 |
out->print(" Committed unused: "); |
|
807 |
print_scaled_words_and_percentage(out, unused_words_in_vs, committed_words, scale, 6); |
|
808 |
out->cr(); |
|
809 |
||
810 |
// Print waste for in-use chunks. |
|
811 |
UsedChunksStatistics ucs_nonclass = cl._stats_total.nonclass_sm_stats().totals(); |
|
812 |
UsedChunksStatistics ucs_class = cl._stats_total.class_sm_stats().totals(); |
|
813 |
UsedChunksStatistics ucs_all; |
|
814 |
ucs_all.add(ucs_nonclass); |
|
815 |
ucs_all.add(ucs_class); |
|
816 |
||
817 |
out->print(" Waste in chunks in use: "); |
|
818 |
print_scaled_words_and_percentage(out, ucs_all.waste(), committed_words, scale, 6); |
|
819 |
out->cr(); |
|
820 |
out->print(" Free in chunks in use: "); |
|
821 |
print_scaled_words_and_percentage(out, ucs_all.free(), committed_words, scale, 6); |
|
822 |
out->cr(); |
|
823 |
out->print(" Overhead in chunks in use: "); |
|
824 |
print_scaled_words_and_percentage(out, ucs_all.overhead(), committed_words, scale, 6); |
|
825 |
out->cr(); |
|
826 |
||
827 |
// Print waste in free chunks. |
|
828 |
const size_t total_capacity_in_free_chunks = |
|
829 |
Metaspace::chunk_manager_metadata()->free_chunks_total_words() + |
|
830 |
(Metaspace::using_class_space() ? Metaspace::chunk_manager_class()->free_chunks_total_words() : 0); |
|
831 |
out->print(" In free chunks: "); |
|
832 |
print_scaled_words_and_percentage(out, total_capacity_in_free_chunks, committed_words, scale, 6); |
|
833 |
out->cr(); |
|
834 |
||
835 |
// Print waste in deallocated blocks. |
|
836 |
const uintx free_blocks_num = |
|
837 |
cl._stats_total.nonclass_sm_stats().free_blocks_num() + |
|
838 |
cl._stats_total.class_sm_stats().free_blocks_num(); |
|
839 |
const size_t free_blocks_cap_words = |
|
840 |
cl._stats_total.nonclass_sm_stats().free_blocks_cap_words() + |
|
841 |
cl._stats_total.class_sm_stats().free_blocks_cap_words(); |
|
842 |
out->print("Deallocated from chunks in use: "); |
|
843 |
print_scaled_words_and_percentage(out, free_blocks_cap_words, committed_words, scale, 6); |
|
50020
9e82ca74f086
8202672: Build failed in metaspace.cpp with VS2017
kbarrett
parents:
49980
diff
changeset
|
844 |
out->print(" (" UINTX_FORMAT " blocks)", free_blocks_num); |
49980 | 845 |
out->cr(); |
846 |
||
847 |
// Print total waste. |
|
848 |
const size_t total_waste = ucs_all.waste() + ucs_all.free() + ucs_all.overhead() + total_capacity_in_free_chunks |
|
849 |
+ free_blocks_cap_words + unused_words_in_vs; |
|
850 |
out->print(" -total-: "); |
|
851 |
print_scaled_words_and_percentage(out, total_waste, committed_words, scale, 6); |
|
852 |
out->cr(); |
|
853 |
||
854 |
// Print internal statistics |
|
855 |
#ifdef ASSERT |
|
856 |
out->cr(); |
|
857 |
out->cr(); |
|
858 |
out->print_cr("Internal statistics:"); |
|
859 |
out->cr(); |
|
860 |
out->print_cr("Number of allocations: " UINTX_FORMAT ".", g_internal_statistics.num_allocs); |
|
861 |
out->print_cr("Number of space births: " UINTX_FORMAT ".", g_internal_statistics.num_metaspace_births); |
|
862 |
out->print_cr("Number of space deaths: " UINTX_FORMAT ".", g_internal_statistics.num_metaspace_deaths); |
|
863 |
out->print_cr("Number of virtual space node births: " UINTX_FORMAT ".", g_internal_statistics.num_vsnodes_created); |
|
864 |
out->print_cr("Number of virtual space node deaths: " UINTX_FORMAT ".", g_internal_statistics.num_vsnodes_purged); |
|
865 |
out->print_cr("Number of times virtual space nodes were expanded: " UINTX_FORMAT ".", g_internal_statistics.num_committed_space_expanded); |
|
866 |
out->print_cr("Number of deallocations: " UINTX_FORMAT " (" UINTX_FORMAT " external).", g_internal_statistics.num_deallocs, g_internal_statistics.num_external_deallocs); |
|
867 |
out->print_cr("Allocations from deallocated blocks: " UINTX_FORMAT ".", g_internal_statistics.num_allocs_from_deallocated_blocks); |
|
53970 | 868 |
out->print_cr("Number of chunks added to freelist: " UINTX_FORMAT ".", |
869 |
g_internal_statistics.num_chunks_added_to_freelist); |
|
870 |
out->print_cr("Number of chunks removed from freelist: " UINTX_FORMAT ".", |
|
871 |
g_internal_statistics.num_chunks_removed_from_freelist); |
|
872 |
out->print_cr("Number of chunk merges: " UINTX_FORMAT ", split-ups: " UINTX_FORMAT ".", |
|
873 |
g_internal_statistics.num_chunk_merges, g_internal_statistics.num_chunk_splits); |
|
874 |
||
49980 | 875 |
out->cr(); |
876 |
#endif |
|
877 |
||
878 |
// Print some interesting settings |
|
879 |
out->cr(); |
|
880 |
out->cr(); |
|
54341
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
881 |
print_basic_switches(out, scale); |
0b47455de59b
8221480: jcmd VM.metaspace shall print limits in basic mode
stuefe
parents:
53970
diff
changeset
|
882 |
|
49980 | 883 |
out->cr(); |
884 |
out->print("InitialBootClassLoaderMetaspaceSize: "); |
|
885 |
print_human_readable_size(out, InitialBootClassLoaderMetaspaceSize, scale); |
|
886 |
||
887 |
out->cr(); |
|
888 |
out->cr(); |
|
889 |
||
890 |
} // MetaspaceUtils::print_report() |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
891 |
|
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
892 |
// Prints an ASCII representation of the given space. |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
893 |
void MetaspaceUtils::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54341
diff
changeset
|
894 |
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
47808
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
895 |
const bool for_class = mdtype == Metaspace::ClassType ? true : false; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
896 |
VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
897 |
if (vsl != NULL) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
898 |
if (for_class) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
899 |
if (!Metaspace::using_class_space()) { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
900 |
out->print_cr("No Class Space."); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
901 |
return; |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
902 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
903 |
out->print_raw("---- Metaspace Map (Class Space) ----"); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
904 |
} else { |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
905 |
out->print_raw("---- Metaspace Map (Non-Class Space) ----"); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
906 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
907 |
// Print legend: |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
908 |
out->cr(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
909 |
out->print_cr("Chunk Types (uppercase chunks are in use): x-specialized, s-small, m-medium, h-humongous."); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
910 |
out->cr(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
911 |
VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
912 |
vsl->print_map(out); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
913 |
out->cr(); |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
914 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
915 |
} |
57752bd5d1b4
8189864: Provide an ascii map to visualize metaspace fragmentation
stuefe
parents:
47802
diff
changeset
|
916 |
|
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
917 |
void MetaspaceUtils::verify_free_chunks() { |
53970 | 918 |
#ifdef ASSERT |
919 |
Metaspace::chunk_manager_metadata()->verify(false); |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
920 |
if (Metaspace::using_class_space()) { |
53970 | 921 |
Metaspace::chunk_manager_class()->verify(false); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
922 |
} |
53970 | 923 |
#endif |
14474
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
924 |
} |
4154f1817a75
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
14123
diff
changeset
|
925 |
|
49980 | 926 |
void MetaspaceUtils::verify_metrics() { |
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
927 |
#ifdef ASSERT |
49980 | 928 |
// Please note: there are time windows where the internal counters are out of sync with |
929 |
// reality. For example, when a newly created ClassLoaderMetaspace creates its first chunk - |
|
930 |
// the ClassLoaderMetaspace is not yet attached to its ClassLoaderData object and hence will |
|
931 |
// not be counted when iterating the CLDG. So be careful when you call this method. |
|
932 |
ClassLoaderMetaspaceStatistics total_stat; |
|
933 |
collect_statistics(&total_stat); |
|
934 |
UsedChunksStatistics nonclass_chunk_stat = total_stat.nonclass_sm_stats().totals(); |
|
935 |
UsedChunksStatistics class_chunk_stat = total_stat.class_sm_stats().totals(); |
|
936 |
||
937 |
bool mismatch = false; |
|
938 |
for (int i = 0; i < Metaspace::MetadataTypeCount; i ++) { |
|
939 |
Metaspace::MetadataType mdtype = (Metaspace::MetadataType)i; |
|
940 |
UsedChunksStatistics chunk_stat = total_stat.sm_stats(mdtype).totals(); |
|
941 |
if (capacity_words(mdtype) != chunk_stat.cap() || |
|
942 |
used_words(mdtype) != chunk_stat.used() || |
|
943 |
overhead_words(mdtype) != chunk_stat.overhead()) { |
|
944 |
mismatch = true; |
|
945 |
tty->print_cr("MetaspaceUtils::verify_metrics: counter mismatch for mdtype=%u:", mdtype); |
|
946 |
tty->print_cr("Expected cap " SIZE_FORMAT ", used " SIZE_FORMAT ", overhead " SIZE_FORMAT ".", |
|
947 |
capacity_words(mdtype), used_words(mdtype), overhead_words(mdtype)); |
|
948 |
tty->print_cr("Got cap " SIZE_FORMAT ", used " SIZE_FORMAT ", overhead " SIZE_FORMAT ".", |
|
949 |
chunk_stat.cap(), chunk_stat.used(), chunk_stat.overhead()); |
|
950 |
tty->flush(); |
|
951 |
} |
|
952 |
} |
|
953 |
assert(mismatch == false, "MetaspaceUtils::verify_metrics: counter mismatch."); |
|
17109
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
954 |
#endif |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
955 |
} |
90e6c31bbbe4
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
17101
diff
changeset
|
956 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
957 |
// Metaspace methods |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
958 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
959 |
size_t Metaspace::_first_chunk_word_size = 0; |
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
960 |
size_t Metaspace::_first_class_chunk_word_size = 0; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
961 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
962 |
size_t Metaspace::_commit_alignment = 0; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
963 |
size_t Metaspace::_reserve_alignment = 0; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
964 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
965 |
VirtualSpaceList* Metaspace::_space_list = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
966 |
VirtualSpaceList* Metaspace::_class_space_list = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
967 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
968 |
ChunkManager* Metaspace::_chunk_manager_metadata = NULL; |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
969 |
ChunkManager* Metaspace::_chunk_manager_class = NULL; |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
970 |
|
55586
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
971 |
bool Metaspace::_initialized = false; |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
972 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
973 |
#define VIRTUALSPACEMULTIPLIER 2 |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
974 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
975 |
#ifdef _LP64 |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
976 |
static const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1); |
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
977 |
|
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
978 |
void Metaspace::set_narrow_klass_base_and_shift(ReservedSpace metaspace_rs, address cds_base) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
979 |
assert(!DumpSharedSpaces, "narrow_klass is set by MetaspaceShared class."); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
980 |
// Figure out the narrow_klass_base and the narrow_klass_shift. The |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
981 |
// narrow_klass_base is the lower of the metaspace base and the cds base |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
982 |
// (if cds is enabled). The narrow_klass_shift depends on the distance |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
983 |
// between the lower base and higher address. |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
984 |
address lower_base = (address)metaspace_rs.base(); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
985 |
address higher_address = (address)metaspace_rs.end(); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
986 |
if (cds_base != NULL) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
987 |
assert(UseSharedSpaces, "must be"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
988 |
lower_base = MIN2(lower_base, cds_base); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
989 |
} else { |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
990 |
uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes; |
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
991 |
// If compressed class space fits in lower 32G, we don't need a base. |
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
992 |
if (higher_address <= (address)klass_encoding_max) { |
22551 | 993 |
lower_base = 0; // Effectively lower base is zero. |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
994 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
995 |
} |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
996 |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
997 |
CompressedKlassPointers::set_base(lower_base); |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
998 |
|
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
999 |
// CDS uses LogKlassAlignmentInBytes for narrow_klass_shift. See |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1000 |
// MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() for |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1001 |
// how dump time narrow_klass_shift is set. Although, CDS can work |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1002 |
// with zero-shift mode also, to be consistent with AOT it uses |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1003 |
// LogKlassAlignmentInBytes for klass shift so archived java heap objects |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1004 |
// can be used at same time as AOT code. |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1005 |
if (!UseSharedSpaces |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1006 |
&& (uint64_t)(higher_address - lower_base) <= UnscaledClassSpaceMax) { |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
1007 |
CompressedKlassPointers::set_shift(0); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1008 |
} else { |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
1009 |
CompressedKlassPointers::set_shift(LogKlassAlignmentInBytes); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1010 |
} |
42650 | 1011 |
AOTLoader::set_narrow_klass_shift(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1012 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1013 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1014 |
// Try to allocate the metaspace at the requested addr. |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1015 |
void Metaspace::allocate_metaspace_compressed_klass_ptrs(ReservedSpace metaspace_rs, char* requested_addr, address cds_base) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1016 |
assert(!DumpSharedSpaces, "compress klass space is allocated by MetaspaceShared class."); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1017 |
assert(using_class_space(), "called improperly"); |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
1018 |
assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); |
21188
d053e4e8f901
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
21186
diff
changeset
|
1019 |
assert(compressed_class_space_size() < KlassEncodingMetaspaceMax, |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1020 |
"Metaspace size is too big"); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1021 |
assert_is_aligned(requested_addr, _reserve_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1022 |
assert_is_aligned(cds_base, _reserve_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1023 |
assert_is_aligned(compressed_class_space_size(), _reserve_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1024 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1025 |
// Don't use large pages for the class space. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1026 |
bool large_pages = false; |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1027 |
|
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1028 |
if (metaspace_rs.is_reserved()) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1029 |
// CDS should have already reserved the space. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1030 |
assert(requested_addr == NULL, "not used"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1031 |
assert(cds_base != NULL, "CDS should have already reserved the memory space"); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1032 |
} else { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1033 |
assert(cds_base == NULL, "must be"); |
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1034 |
#if !(defined(AARCH64) || defined(AIX)) |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1035 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), _reserve_alignment, |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1036 |
large_pages, requested_addr); |
29180 | 1037 |
#else // AARCH64 |
1038 |
// Our compressed klass pointers may fit nicely into the lower 32 |
|
1039 |
// bits. |
|
1040 |
if ((uint64_t)requested_addr + compressed_class_space_size() < 4*G) { |
|
1041 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
|
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1042 |
_reserve_alignment, |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1043 |
large_pages, |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1044 |
requested_addr); |
29180 | 1045 |
} |
1046 |
||
1047 |
if (! metaspace_rs.is_reserved()) { |
|
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1048 |
// Aarch64: Try to align metaspace so that we can decode a compressed |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1049 |
// klass with a single MOVK instruction. We can do this iff the |
29180 | 1050 |
// compressed class base is a multiple of 4G. |
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1051 |
// Aix: Search for a place where we can find memory. If we need to load |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1052 |
// the base, 4G alignment is helpful, too. |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1053 |
size_t increment = AARCH64_ONLY(4*)G; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1054 |
for (char *a = align_up(requested_addr, increment); |
29180 | 1055 |
a < (char*)(1024*G); |
39229
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1056 |
a += increment) { |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1057 |
if (a == (char *)(32*G)) { |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1058 |
// Go faster from here on. Zero-based is no longer possible. |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1059 |
increment = 4*G; |
8bfc00dd44b6
8159056: [aix] Compressed class space not allocated in lower regions
goetz
parents:
37267
diff
changeset
|
1060 |
} |
29180 | 1061 |
|
1062 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
|
1063 |
_reserve_alignment, |
|
1064 |
large_pages, |
|
29187 | 1065 |
a); |
29180 | 1066 |
if (metaspace_rs.is_reserved()) |
1067 |
break; |
|
1068 |
} |
|
1069 |
} |
|
1070 |
#endif // AARCH64 |
|
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1071 |
} |
29180 | 1072 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1073 |
if (!metaspace_rs.is_reserved()) { |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1074 |
assert(cds_base == NULL, "CDS should have already reserved the memory space"); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1075 |
// If no successful allocation then try to allocate the space anywhere. If |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1076 |
// that fails then OOM doom. At this point we cannot try allocating the |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
1077 |
// metaspace as if UseCompressedClassPointers is off because too much |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
1078 |
// initialization has happened that depends on UseCompressedClassPointers. |
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
1079 |
// So, UseCompressedClassPointers cannot be turned off at this point. |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1080 |
metaspace_rs = ReservedSpace(compressed_class_space_size(), |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1081 |
_reserve_alignment, large_pages); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1082 |
if (!metaspace_rs.is_reserved()) { |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1083 |
vm_exit_during_initialization(err_msg("Could not allocate metaspace: " SIZE_FORMAT " bytes", |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1084 |
compressed_class_space_size())); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1085 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1086 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1087 |
|
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1088 |
if (cds_base == NULL) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1089 |
// If we got here then the metaspace got allocated. |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1090 |
MemTracker::record_virtual_memory_type((address)metaspace_rs.base(), mtClass); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1091 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1092 |
|
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1093 |
set_narrow_klass_base_and_shift(metaspace_rs, cds_base); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1094 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1095 |
initialize_class_space(metaspace_rs); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1096 |
|
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1097 |
LogTarget(Trace, gc, metaspace) lt; |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1098 |
if (lt.is_enabled()) { |
35061 | 1099 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1100 |
LogStream ls(lt); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1101 |
print_compressed_class_space(&ls, requested_addr); |
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1102 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1103 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1104 |
|
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1105 |
void Metaspace::print_compressed_class_space(outputStream* st, const char* requested_addr) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1106 |
st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d", |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54623
diff
changeset
|
1107 |
p2i(CompressedKlassPointers::base()), CompressedKlassPointers::shift()); |
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1108 |
if (_class_space_list != NULL) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1109 |
address base = (address)_class_space_list->current_virtual_space()->bottom(); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1110 |
st->print("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT, |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1111 |
compressed_class_space_size(), p2i(base)); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1112 |
if (requested_addr != 0) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1113 |
st->print(" Req Addr: " PTR_FORMAT, p2i(requested_addr)); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1114 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
31028
diff
changeset
|
1115 |
st->cr(); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1116 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1117 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1118 |
|
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
1119 |
// For UseCompressedClassPointers the class space is reserved above the top of |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1120 |
// the Java heap. The argument passed in is at the base of the compressed space. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1121 |
void Metaspace::initialize_class_space(ReservedSpace rs) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1122 |
// The reserved space size may be bigger because of alignment, esp with UseLargePages |
19979
ebe1dbb6e1aa
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
19546
diff
changeset
|
1123 |
assert(rs.size() >= CompressedClassSpaceSize, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1124 |
SIZE_FORMAT " != " SIZE_FORMAT, rs.size(), CompressedClassSpaceSize); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1125 |
assert(using_class_space(), "Must be using class space"); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1126 |
_class_space_list = new VirtualSpaceList(rs); |
49365 | 1127 |
_chunk_manager_class = new ChunkManager(true/*is_class*/); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1128 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1129 |
if (!_class_space_list->initialization_succeeded()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1130 |
vm_exit_during_initialization("Failed to setup compressed class space virtual space list."); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1131 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1132 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1133 |
|
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1134 |
#endif |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1135 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1136 |
void Metaspace::ergo_initialize() { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1137 |
if (DumpSharedSpaces) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1138 |
// Using large pages when dumping the shared archive is currently not implemented. |
54983
81becad91321
8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents:
54927
diff
changeset
|
1139 |
FLAG_SET_ERGO(UseLargePagesInMetaspace, false); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1140 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1141 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1142 |
size_t page_size = os::vm_page_size(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1143 |
if (UseLargePages && UseLargePagesInMetaspace) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1144 |
page_size = os::large_page_size(); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1145 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1146 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1147 |
_commit_alignment = page_size; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1148 |
_reserve_alignment = MAX2(page_size, (size_t)os::vm_allocation_granularity()); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1149 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1150 |
// Do not use FLAG_SET_ERGO to update MaxMetaspaceSize, since this will |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1151 |
// override if MaxMetaspaceSize was set on the command line or not. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1152 |
// This information is needed later to conform to the specification of the |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1153 |
// java.lang.management.MemoryUsage API. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1154 |
// |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1155 |
// Ideally, we would be able to set the default value of MaxMetaspaceSize in |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1156 |
// globals.hpp to the aligned value, but this is not possible, since the |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1157 |
// alignment depends on other flags being parsed. |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1158 |
MaxMetaspaceSize = align_down_bounded(MaxMetaspaceSize, _reserve_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1159 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1160 |
if (MetaspaceSize > MaxMetaspaceSize) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1161 |
MetaspaceSize = MaxMetaspaceSize; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1162 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1163 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1164 |
MetaspaceSize = align_down_bounded(MetaspaceSize, _commit_alignment); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1165 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1166 |
assert(MetaspaceSize <= MaxMetaspaceSize, "MetaspaceSize should be limited by MaxMetaspaceSize"); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1167 |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1168 |
MinMetaspaceExpansion = align_down_bounded(MinMetaspaceExpansion, _commit_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1169 |
MaxMetaspaceExpansion = align_down_bounded(MaxMetaspaceExpansion, _commit_alignment); |
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1170 |
|
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
1171 |
CompressedClassSpaceSize = align_down_bounded(CompressedClassSpaceSize, _reserve_alignment); |
47654
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1172 |
|
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1173 |
// Initial virtual space size will be calculated at global_initialize() |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1174 |
size_t min_metaspace_sz = |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1175 |
VIRTUALSPACEMULTIPLIER * InitialBootClassLoaderMetaspaceSize; |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1176 |
if (UseCompressedClassPointers) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1177 |
if ((min_metaspace_sz + CompressedClassSpaceSize) > MaxMetaspaceSize) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1178 |
if (min_metaspace_sz >= MaxMetaspaceSize) { |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1179 |
vm_exit_during_initialization("MaxMetaspaceSize is too small."); |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1180 |
} else { |
54983
81becad91321
8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents:
54927
diff
changeset
|
1181 |
FLAG_SET_ERGO(CompressedClassSpaceSize, |
47654
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1182 |
MaxMetaspaceSize - min_metaspace_sz); |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1183 |
} |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1184 |
} |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1185 |
} else if (min_metaspace_sz >= MaxMetaspaceSize) { |
54983
81becad91321
8224203: Remove need to specify type when using FLAG_SET macros
stefank
parents:
54927
diff
changeset
|
1186 |
FLAG_SET_ERGO(InitialBootClassLoaderMetaspaceSize, |
47654
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1187 |
min_metaspace_sz); |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1188 |
} |
dbd1f4f276ba
8087291: InitialBootClassLoaderMetaspaceSize and CompressedClassSpaceSize should be checked consistent from MaxMetaspaceSize
ysuenaga
parents:
47634
diff
changeset
|
1189 |
|
48387
7daebcef2e0d
8193386: CompressedClassSize too large with MaxMetaspace
coleenp
parents:
48148
diff
changeset
|
1190 |
set_compressed_class_space_size(CompressedClassSpaceSize); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1191 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1192 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1193 |
void Metaspace::global_initialize() { |
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
1194 |
MetaspaceGC::initialize(); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
1195 |
|
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1196 |
bool class_space_inited = false; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1197 |
#if INCLUDE_CDS |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1198 |
if (DumpSharedSpaces) { |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1199 |
MetaspaceShared::initialize_dumptime_shared_and_meta_spaces(); |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1200 |
class_space_inited = true; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1201 |
} else if (UseSharedSpaces) { |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1202 |
// If any of the archived space fails to map, UseSharedSpaces |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1203 |
// is reset to false. |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1204 |
MetaspaceShared::initialize_runtime_shared_and_meta_spaces(); |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1205 |
class_space_inited = UseSharedSpaces; |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1206 |
} |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47553
diff
changeset
|
1207 |
|
54927 | 1208 |
if (DynamicDumpSharedSpaces && !UseSharedSpaces) { |
55348
d109188f6480
8224710: [TESTBUG] dynamicArchive/ExcludedClasses.java test failed in tier6 testing on Windows
ccheung
parents:
54983
diff
changeset
|
1209 |
vm_exit_during_initialization("DynamicDumpSharedSpaces is unsupported when base CDS archive is not loaded", NULL); |
54927 | 1210 |
} |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1211 |
#endif // INCLUDE_CDS |
54927 | 1212 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1213 |
#ifdef _LP64 |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1214 |
if (using_class_space() && !class_space_inited) { |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1215 |
char* base = (char*)align_up(CompressedOops::end(), _reserve_alignment); |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1216 |
ReservedSpace dummy; |
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1217 |
allocate_metaspace_compressed_klass_ptrs(dummy, base, 0); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1218 |
} |
59070
22ee476cc664
8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents:
59053
diff
changeset
|
1219 |
#endif |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1220 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1221 |
// Initialize these before initializing the VirtualSpaceList |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1222 |
_first_chunk_word_size = InitialBootClassLoaderMetaspaceSize / BytesPerWord; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1223 |
_first_chunk_word_size = align_word_size_up(_first_chunk_word_size); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1224 |
// Make the first class chunk bigger than a medium chunk so it's not put |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1225 |
// on the medium chunk list. The next chunk will be small and progress |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1226 |
// from there. This size calculated by -version. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1227 |
_first_class_chunk_word_size = MIN2((size_t)MediumChunk*6, |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1228 |
(CompressedClassSpaceSize/BytesPerWord)*2); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1229 |
_first_class_chunk_word_size = align_word_size_up(_first_class_chunk_word_size); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1230 |
// Arbitrarily set the initial virtual space to a multiple |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1231 |
// of the boot class loader size. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1232 |
size_t word_size = VIRTUALSPACEMULTIPLIER * _first_chunk_word_size; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1233 |
word_size = align_up(word_size, Metaspace::reserve_alignment_words()); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1234 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1235 |
// Initialize the list of virtual spaces. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1236 |
_space_list = new VirtualSpaceList(word_size); |
49365 | 1237 |
_chunk_manager_metadata = new ChunkManager(false/*metaspace*/); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1238 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1239 |
if (!_space_list->initialization_succeeded()) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1240 |
vm_exit_during_initialization("Unable to setup metadata virtual space list.", NULL); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1241 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1242 |
|
23465
14790e4d53ec
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
22884
diff
changeset
|
1243 |
_tracer = new MetaspaceTracer(); |
55586
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
1244 |
|
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
1245 |
_initialized = true; |
014c8cd323af
8227032: MetaspaceUtils::print_report crashes when called before initialization
stuefe
parents:
55576
diff
changeset
|
1246 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1247 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1248 |
|
24847
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
1249 |
void Metaspace::post_initialize() { |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
1250 |
MetaspaceGC::post_initialize(); |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
1251 |
} |
37c354b113fe
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
24665
diff
changeset
|
1252 |
|
42615
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1253 |
void Metaspace::verify_global_initialization() { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1254 |
assert(space_list() != NULL, "Metadata VirtualSpaceList has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1255 |
assert(chunk_manager_metadata() != NULL, "Metadata ChunkManager has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1256 |
|
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1257 |
if (using_class_space()) { |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1258 |
assert(class_space_list() != NULL, "Class VirtualSpaceList has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1259 |
assert(chunk_manager_class() != NULL, "Class ChunkManager has not been initialized"); |
86c4562176fa
8170395: Metaspace initialization queries the wrong chunk freelist
stefank
parents:
42602
diff
changeset
|
1260 |
} |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1261 |
} |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1262 |
|
15086
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1263 |
size_t Metaspace::align_word_size_up(size_t word_size) { |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1264 |
size_t byte_size = word_size * wordSize; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1265 |
return ReservedSpace::allocation_align_size_up(byte_size) / wordSize; |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1266 |
} |
2bfd799e9147
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
14842
diff
changeset
|
1267 |
|
20729 | 1268 |
MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1269 |
MetaspaceObj::Type type, TRAPS) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46723
diff
changeset
|
1270 |
assert(!_frozen, "sanity"); |
52468
e0fd97beab7e
8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents:
52363
diff
changeset
|
1271 |
assert(!(DumpSharedSpaces && THREAD->is_VM_thread()), "sanity"); |
e0fd97beab7e
8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents:
52363
diff
changeset
|
1272 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1273 |
if (HAS_PENDING_EXCEPTION) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1274 |
assert(false, "Should not allocate with exception pending"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1275 |
return NULL; // caller does a CHECK_NULL too |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1276 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1277 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1278 |
assert(loader_data != NULL, "Should never pass around a NULL loader_data. " |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1279 |
"ClassLoaderData::the_null_class_loader_data() should have been used."); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1280 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1281 |
MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType; |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1282 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1283 |
// Try to allocate metadata. |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1284 |
MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1285 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1286 |
if (result == NULL) { |
23468
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1287 |
tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype); |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1288 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1289 |
// Allocation failed. |
52468
e0fd97beab7e
8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents:
52363
diff
changeset
|
1290 |
if (is_init_completed()) { |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1291 |
// Only start a GC if the bootstrapping has completed. |
52468
e0fd97beab7e
8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents:
52363
diff
changeset
|
1292 |
// Try to clean out some heap memory and retry. This can prevent premature |
e0fd97beab7e
8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents:
52363
diff
changeset
|
1293 |
// expansion of the metaspace. |
49045
9b556b613a07
8198509: Move satisfy_failed_metadata_allocation out from CollectorPolicy
stefank
parents:
48971
diff
changeset
|
1294 |
result = Universe::heap()->satisfy_failed_metadata_allocation(loader_data, word_size, mdtype); |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1295 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1296 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1297 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1298 |
if (result == NULL) { |
49652
a74836b05c28
8200078: [Graal] runtime/appcds/GraalWithLimitedMetaspace.java crashes in visit_all_interfaces
ccheung
parents:
49601
diff
changeset
|
1299 |
if (DumpSharedSpaces) { |
a74836b05c28
8200078: [Graal] runtime/appcds/GraalWithLimitedMetaspace.java crashes in visit_all_interfaces
ccheung
parents:
49601
diff
changeset
|
1300 |
// CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM. |
a74836b05c28
8200078: [Graal] runtime/appcds/GraalWithLimitedMetaspace.java crashes in visit_all_interfaces
ccheung
parents:
49601
diff
changeset
|
1301 |
// We should abort to avoid generating a potentially bad archive. |
52300
9e29d8388514
8209598: Clean up how messages are printed when CDS aborts start-up
ccheung
parents:
52014
diff
changeset
|
1302 |
vm_exit_during_cds_dumping(err_msg("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.", |
9e29d8388514
8209598: Clean up how messages are printed when CDS aborts start-up
ccheung
parents:
52014
diff
changeset
|
1303 |
MetaspaceObj::type_name(type), word_size * BytesPerWord), |
9e29d8388514
8209598: Clean up how messages are printed when CDS aborts start-up
ccheung
parents:
52014
diff
changeset
|
1304 |
err_msg("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize)); |
49652
a74836b05c28
8200078: [Graal] runtime/appcds/GraalWithLimitedMetaspace.java crashes in visit_all_interfaces
ccheung
parents:
49601
diff
changeset
|
1305 |
} |
51070 | 1306 |
report_metadata_oome(loader_data, word_size, type, mdtype, THREAD); |
1307 |
assert(HAS_PENDING_EXCEPTION, "sanity"); |
|
1308 |
return NULL; |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1309 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1310 |
|
20729 | 1311 |
// Zero initialize. |
35898
ddc274f0052f
8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
coleenp
parents:
35231
diff
changeset
|
1312 |
Copy::fill_to_words((HeapWord*)result, word_size, 0); |
20729 | 1313 |
|
1314 |
return result; |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1315 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1316 |
|
23469
0a4d02776968
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
23468
diff
changeset
|
1317 |
void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) { |
0a4d02776968
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
23468
diff
changeset
|
1318 |
tracer()->report_metadata_oom(loader_data, word_size, type, mdtype); |
0a4d02776968
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
23468
diff
changeset
|
1319 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1320 |
// If result is still null, we are out of memory. |
50372 | 1321 |
Log(gc, metaspace, freelist, oom) log; |
41727
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1322 |
if (log.is_info()) { |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1323 |
log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT, |
f1658e76a682
8164921: Memory leaked when instrumentation.retransformClasses() is called repeatedly
coleenp
parents:
41182
diff
changeset
|
1324 |
is_class_space_allocation(mdtype) ? "class" : "data", word_size); |
35061 | 1325 |
ResourceMark rm; |
46723
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
1326 |
if (log.is_debug()) { |
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
1327 |
if (loader_data->metaspace_or_null() != NULL) { |
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
1328 |
LogStream ls(log.debug()); |
49348
fde3feaaa4ed
8198926: Move ClassLoaderData::_dependencies to ClassLoaderData::_handles
coleenp
parents:
49045
diff
changeset
|
1329 |
loader_data->print_value_on(&ls); |
46723
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
1330 |
} |
5c418c5fcade
8185262: Keep default logging for Metaspace OOM short and concise
stuefe
parents:
46709
diff
changeset
|
1331 |
} |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46674
diff
changeset
|
1332 |
LogStream ls(log.info()); |
49980 | 1333 |
// In case of an OOM, log out a short but still useful report. |
1334 |
MetaspaceUtils::print_basic_report(&ls, 0); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1335 |
} |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1336 |
|
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1337 |
bool out_of_compressed_class_space = false; |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1338 |
if (is_class_space_allocation(mdtype)) { |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1339 |
ClassLoaderMetaspace* metaspace = loader_data->metaspace_non_null(); |
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1340 |
out_of_compressed_class_space = |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49386
diff
changeset
|
1341 |
MetaspaceUtils::committed_bytes(Metaspace::ClassType) + |
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1342 |
(metaspace->class_chunk_size(word_size) * BytesPerWord) > |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1343 |
CompressedClassSpaceSize; |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1344 |
} |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1345 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1346 |
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1347 |
const char* space_string = out_of_compressed_class_space ? |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1348 |
"Compressed class space" : "Metaspace"; |
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1349 |
|
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1350 |
report_java_out_of_memory(space_string); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1351 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1352 |
if (JvmtiExport::should_post_resource_exhausted()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1353 |
JvmtiExport::post_resource_exhausted( |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1354 |
JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1355 |
space_string); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1356 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1357 |
|
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1358 |
if (!is_init_completed()) { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1359 |
vm_exit_during_initialization("OutOfMemoryError", space_string); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1360 |
} |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1361 |
|
21186
db851068711f
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
20733
diff
changeset
|
1362 |
if (out_of_compressed_class_space) { |
20406
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1363 |
THROW_OOP(Universe::out_of_memory_error_class_metaspace()); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1364 |
} else { |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1365 |
THROW_OOP(Universe::out_of_memory_error_metaspace()); |
934f0b12daa9
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
20306
diff
changeset
|
1366 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1367 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1368 |
|
23468
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1369 |
const char* Metaspace::metadata_type_name(Metaspace::MetadataType mdtype) { |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1370 |
switch (mdtype) { |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1371 |
case Metaspace::ClassType: return "Class"; |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1372 |
case Metaspace::NonClassType: return "Metadata"; |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1373 |
default: |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31374
diff
changeset
|
1374 |
assert(false, "Got bad mdtype: %d", (int) mdtype); |
23468
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1375 |
return NULL; |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1376 |
} |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1377 |
} |
6bb416a59349
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
23465
diff
changeset
|
1378 |
|
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1379 |
void Metaspace::purge(MetadataType mdtype) { |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1380 |
get_space_list(mdtype)->purge(get_chunk_manager(mdtype)); |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1381 |
} |
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1382 |
|
17101 | 1383 |
void Metaspace::purge() { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54341
diff
changeset
|
1384 |
MutexLocker cl(MetaspaceExpand_lock, |
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54341
diff
changeset
|
1385 |
Mutex::_no_safepoint_check_flag); |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1386 |
purge(NonClassType); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1387 |
if (using_class_space()) { |
20081
e26536e86a5c
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
20080
diff
changeset
|
1388 |
purge(ClassType); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1389 |
} |
17101 | 1390 |
} |
1391 |
||
22201
9c2ccfa3a5fe
8029178: Parallel class loading test anonymous-simple gets SIGSEGV in Metaspace::contains
coleenp
parents:
21569
diff
changeset
|
1392 |
bool Metaspace::contains(const void* ptr) { |
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
48387
diff
changeset
|
1393 |
if (MetaspaceShared::is_in_shared_metaspace(ptr)) { |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1394 |
return true; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1395 |
} |
46324
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
1396 |
return contains_non_shared(ptr); |
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
1397 |
} |
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
1398 |
|
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
42650
diff
changeset
|
1399 |
bool Metaspace::contains_non_shared(const void* ptr) { |
24457
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1400 |
if (using_class_space() && get_space_list(ClassType)->contains(ptr)) { |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1401 |
return true; |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1402 |
} |
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1403 |
|
0e20b36df5c4
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
24424
diff
changeset
|
1404 |
return get_space_list(NonClassType)->contains(ptr); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1405 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1406 |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1407 |
// ClassLoaderMetaspace |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1408 |
|
49980 | 1409 |
ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type) |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
51070
diff
changeset
|
1410 |
: _space_type(type) |
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
51070
diff
changeset
|
1411 |
, _lock(lock) |
49980 | 1412 |
, _vsm(NULL) |
1413 |
, _class_vsm(NULL) |
|
1414 |
{ |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1415 |
initialize(lock, type); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1416 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1417 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1418 |
ClassLoaderMetaspace::~ClassLoaderMetaspace() { |
52468
e0fd97beab7e
8213250: CDS archive creation aborts due to metaspace object allocation failure
iklam
parents:
52363
diff
changeset
|
1419 |
Metaspace::assert_not_frozen(); |
49980 | 1420 |
DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_metaspace_deaths)); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1421 |
delete _vsm; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1422 |
if (Metaspace::using_class_space()) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1423 |
delete _class_vsm; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1424 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1425 |
} |
49980 | 1426 |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1427 |
void ClassLoaderMetaspace::initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1428 |
Metachunk* chunk = get_initialization_chunk(type, mdtype); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1429 |
if (chunk != NULL) { |
49869
c71f40e37583
8202074: Metaspace: If humongous chunk is added to SpaceManager, previous current chunk may not get retired correctly.
stuefe
parents:
49852
diff
changeset
|
1430 |
// Add to this manager's list of chunks in use and make it the current_chunk(). |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1431 |
get_space_manager(mdtype)->add_chunk(chunk, true); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1432 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1433 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1434 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1435 |
Metachunk* ClassLoaderMetaspace::get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1436 |
size_t chunk_word_size = get_space_manager(mdtype)->get_initial_chunk_size(type); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1437 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1438 |
// Get a chunk from the chunk freelist |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1439 |
Metachunk* chunk = Metaspace::get_chunk_manager(mdtype)->chunk_freelist_allocate(chunk_word_size); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1440 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1441 |
if (chunk == NULL) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1442 |
chunk = Metaspace::get_space_list(mdtype)->get_new_chunk(chunk_word_size, |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1443 |
get_space_manager(mdtype)->medium_chunk_bunch()); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1444 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1445 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1446 |
return chunk; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1447 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1448 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1449 |
void ClassLoaderMetaspace::initialize(Mutex* lock, Metaspace::MetaspaceType type) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1450 |
Metaspace::verify_global_initialization(); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1451 |
|
49980 | 1452 |
DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_metaspace_births)); |
1453 |
||
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1454 |
// Allocate SpaceManager for metadata objects. |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1455 |
_vsm = new SpaceManager(Metaspace::NonClassType, type, lock); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1456 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1457 |
if (Metaspace::using_class_space()) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1458 |
// Allocate SpaceManager for classes. |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1459 |
_class_vsm = new SpaceManager(Metaspace::ClassType, type, lock); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1460 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1461 |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54341
diff
changeset
|
1462 |
MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1463 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1464 |
// Allocate chunk for metadata objects |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1465 |
initialize_first_chunk(type, Metaspace::NonClassType); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1466 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1467 |
// Allocate chunk for class metadata objects |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1468 |
if (Metaspace::using_class_space()) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1469 |
initialize_first_chunk(type, Metaspace::ClassType); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1470 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1471 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1472 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1473 |
MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdtype) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1474 |
Metaspace::assert_not_frozen(); |
49980 | 1475 |
|
1476 |
DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_allocs)); |
|
1477 |
||
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1478 |
// Don't use class_vsm() unless UseCompressedClassPointers is true. |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1479 |
if (Metaspace::is_class_space_allocation(mdtype)) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1480 |
return class_vsm()->allocate(word_size); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1481 |
} else { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1482 |
return vsm()->allocate(word_size); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1483 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1484 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1485 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1486 |
MetaWord* ClassLoaderMetaspace::expand_and_allocate(size_t word_size, Metaspace::MetadataType mdtype) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1487 |
Metaspace::assert_not_frozen(); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1488 |
size_t delta_bytes = MetaspaceGC::delta_capacity_until_GC(word_size * BytesPerWord); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1489 |
assert(delta_bytes > 0, "Must be"); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1490 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1491 |
size_t before = 0; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1492 |
size_t after = 0; |
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
1493 |
bool can_retry = true; |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1494 |
MetaWord* res; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1495 |
bool incremented; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1496 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1497 |
// Each thread increments the HWM at most once. Even if the thread fails to increment |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1498 |
// the HWM, an allocation is still attempted. This is because another thread must then |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1499 |
// have incremented the HWM and therefore the allocation might still succeed. |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1500 |
do { |
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
1501 |
incremented = MetaspaceGC::inc_capacity_until_GC(delta_bytes, &after, &before, &can_retry); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1502 |
res = allocate(word_size, mdtype); |
53602
d1282cd2c1fc
8217432: MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
ysuenaga
parents:
53598
diff
changeset
|
1503 |
} while (!incremented && res == NULL && can_retry); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1504 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1505 |
if (incremented) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1506 |
Metaspace::tracer()->report_gc_threshold(before, after, |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1507 |
MetaspaceGCThresholdUpdater::ExpandAndAllocate); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1508 |
log_trace(gc, metaspace)("Increase capacity to GC from " SIZE_FORMAT " to " SIZE_FORMAT, before, after); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1509 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1510 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1511 |
return res; |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1512 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1513 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1514 |
size_t ClassLoaderMetaspace::allocated_blocks_bytes() const { |
49980 | 1515 |
return (vsm()->used_words() + |
1516 |
(Metaspace::using_class_space() ? class_vsm()->used_words() : 0)) * BytesPerWord; |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1517 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1518 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1519 |
size_t ClassLoaderMetaspace::allocated_chunks_bytes() const { |
49980 | 1520 |
return (vsm()->capacity_words() + |
1521 |
(Metaspace::using_class_space() ? class_vsm()->capacity_words() : 0)) * BytesPerWord; |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1522 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1523 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1524 |
void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1525 |
Metaspace::assert_not_frozen(); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1526 |
assert(!SafepointSynchronize::is_at_safepoint() |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1527 |
|| Thread::current()->is_VM_thread(), "should be the VM thread"); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1528 |
|
49980 | 1529 |
DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_external_deallocs)); |
1530 |
||
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54341
diff
changeset
|
1531 |
MutexLocker ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1532 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1533 |
if (is_class && Metaspace::using_class_space()) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1534 |
class_vsm()->deallocate(ptr, word_size); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1535 |
} else { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1536 |
vsm()->deallocate(ptr, word_size); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1537 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1538 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1539 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1540 |
size_t ClassLoaderMetaspace::class_chunk_size(size_t word_size) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1541 |
assert(Metaspace::using_class_space(), "Has to use class space"); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1542 |
return class_vsm()->calc_chunk_size(word_size); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1543 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1544 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1545 |
void ClassLoaderMetaspace::print_on(outputStream* out) const { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1546 |
// Print both class virtual space counts and metaspace. |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1547 |
if (Verbose) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1548 |
vsm()->print_on(out); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1549 |
if (Metaspace::using_class_space()) { |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1550 |
class_vsm()->print_on(out); |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1551 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1552 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1553 |
} |
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1554 |
|
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1555 |
void ClassLoaderMetaspace::verify() { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1556 |
vsm()->verify(); |
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1557 |
if (Metaspace::using_class_space()) { |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1558 |
class_vsm()->verify(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1559 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1560 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1561 |
|
49980 | 1562 |
void ClassLoaderMetaspace::add_to_statistics_locked(ClassLoaderMetaspaceStatistics* out) const { |
1563 |
assert_lock_strong(lock()); |
|
1564 |
vsm()->add_to_statistics_locked(&out->nonclass_sm_stats()); |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1565 |
if (Metaspace::using_class_space()) { |
49980 | 1566 |
class_vsm()->add_to_statistics_locked(&out->class_sm_stats()); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18987
diff
changeset
|
1567 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1568 |
} |
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1569 |
|
49980 | 1570 |
void ClassLoaderMetaspace::add_to_statistics(ClassLoaderMetaspaceStatistics* out) const { |
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54341
diff
changeset
|
1571 |
MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag); |
49980 | 1572 |
add_to_statistics_locked(out); |
1573 |
} |
|
49401
0c71baee49a7
8199431: Split up class Metaspace into a static and a non-static part
stuefe
parents:
49395
diff
changeset
|
1574 |
|
19989
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1575 |
/////////////// Unit tests /////////////// |
0fc247fb59bc
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
19988
diff
changeset
|
1576 |
|
49365 | 1577 |
struct chunkmanager_statistics_t { |
1578 |
int num_specialized_chunks; |
|
1579 |
int num_small_chunks; |
|
1580 |
int num_medium_chunks; |
|
1581 |
int num_humongous_chunks; |
|
1582 |
}; |
|
1583 |
||
1584 |
extern void test_metaspace_retrieve_chunkmanager_statistics(Metaspace::MetadataType mdType, chunkmanager_statistics_t* out) { |
|
1585 |
ChunkManager* const chunk_manager = Metaspace::get_chunk_manager(mdType); |
|
49980 | 1586 |
ChunkManagerStatistics stat; |
1587 |
chunk_manager->collect_statistics(&stat); |
|
1588 |
out->num_specialized_chunks = (int)stat.chunk_stats(SpecializedIndex).num(); |
|
1589 |
out->num_small_chunks = (int)stat.chunk_stats(SmallIndex).num(); |
|
1590 |
out->num_medium_chunks = (int)stat.chunk_stats(MediumIndex).num(); |
|
1591 |
out->num_humongous_chunks = (int)stat.chunk_stats(HumongousIndex).num(); |
|
49365 | 1592 |
} |
1593 |
||
1594 |
struct chunk_geometry_t { |
|
1595 |
size_t specialized_chunk_word_size; |
|
1596 |
size_t small_chunk_word_size; |
|
1597 |
size_t medium_chunk_word_size; |
|
1598 |
}; |
|
1599 |
||
1600 |
extern void test_metaspace_retrieve_chunk_geometry(Metaspace::MetadataType mdType, chunk_geometry_t* out) { |
|
1601 |
if (mdType == Metaspace::NonClassType) { |
|
1602 |
out->specialized_chunk_word_size = SpecializedChunk; |
|
1603 |
out->small_chunk_word_size = SmallChunk; |
|
1604 |
out->medium_chunk_word_size = MediumChunk; |
|
1605 |
} else { |
|
1606 |
out->specialized_chunk_word_size = ClassSpecializedChunk; |
|
1607 |
out->small_chunk_word_size = ClassSmallChunk; |
|
1608 |
out->medium_chunk_word_size = ClassMediumChunk; |
|
1609 |
} |
|
1610 |
} |