Mercurial > hg > truffle
annotate src/share/vm/memory/metaspace.hpp @ 20543:e7d0505c8a30
8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso
author | tschatzl |
---|---|
date | Fri, 10 Oct 2014 15:51:58 +0200 |
parents | b509b7ff561c |
children | 7848fc12602b |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
17935
7384f6a12fc1
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
17866
diff
changeset
|
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
6725
da91efe96a93
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. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 * |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 * |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 * accompanied this code). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 * |
da91efe96a93
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 |
da91efe96a93
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, |
da91efe96a93
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. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 * |
da91efe96a93
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 |
da91efe96a93
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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 * questions. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 * |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 */ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
24 #ifndef SHARE_VM_MEMORY_METASPACE_HPP |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 #define SHARE_VM_MEMORY_METASPACE_HPP |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 #include "memory/allocation.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
28 #include "memory/memRegion.hpp" |
17771
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
29 #include "memory/metaspaceChunkFreeListSummary.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 #include "runtime/virtualspace.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 #include "utilities/exceptions.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 // Metaspace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
35 // Metaspaces are Arenas for the VM's metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 // They are allocated one per class loader object, and one for the null |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
37 // bootstrap class loader |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 // Eventually for bootstrap loader we'll have a read-only section and read-write |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 // to write for DumpSharedSpaces and read for UseSharedSpaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 // block X ---+ +-------------------+ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 // | | Virtualspace | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 // | | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 // | | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 // | |-------------------| |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 // | || Chunk | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 // | || | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 // | ||---------- | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 // +------>||| block 0 | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 // ||---------- | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 // ||| block 1 | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
52 // ||---------- | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
53 // || | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 // |-------------------| |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
55 // | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
56 // | | |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 // +-------------------+ |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
60 class ChunkManager; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
61 class ClassLoaderData; |
6885 | 62 class Metablock; |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
63 class Metachunk; |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17663
diff
changeset
|
64 class MetaspaceTracer; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
65 class MetaWord; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
66 class Mutex; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
67 class outputStream; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
68 class SpaceManager; |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
69 class VirtualSpaceList; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
70 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
71 // Metaspaces each have a SpaceManager and allocations |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
72 // are done by the SpaceManager. Allocations are done |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
73 // out of the current Metachunk. When the current Metachunk |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
74 // is exhausted, the SpaceManager gets a new one from |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 // the current VirtualSpace. When the VirtualSpace is exhausted |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 // the SpaceManager gets a new one. The SpaceManager |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 // also manages freelists of available Chunks. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
78 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 // Currently the space manager maintains the list of |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
80 // virtual spaces and the list of chunks in use. Its |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 // allocate() method returns a block for use as a |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 // quantum of metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 class Metaspace : public CHeapObj<mtClass> { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 friend class VMStructs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 friend class SpaceManager; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 friend class VM_CollectForMetadataAllocation; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 friend class MetaspaceGC; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 friend class MetaspaceAux; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 public: |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
92 enum MetadataType { |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
93 ClassType, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
94 NonClassType, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
95 MetadataTypeCount |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
96 }; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
97 enum MetaspaceType { |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
98 StandardMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
99 BootMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
100 ROMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
101 ReadWriteMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
102 AnonymousMetaspaceType, |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
103 ReflectionMetaspaceType |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
104 }; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 private: |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
107 void initialize(Mutex* lock, MetaspaceType type); |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
108 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
109 // Get the first chunk for a Metaspace. Used for |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
110 // special cases such as the boot class loader, reflection |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
111 // class loader and anonymous class loader. |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
112 Metachunk* get_initialization_chunk(MetadataType mdtype, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
113 size_t chunk_word_size, |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
114 size_t chunk_bunch); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
115 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
116 // Align up the word size to the allocation word size |
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
117 static size_t align_word_size_up(size_t); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
119 // Aligned size of the metaspace. |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
120 static size_t _compressed_class_space_size; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
121 |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
122 static size_t compressed_class_space_size() { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
123 return _compressed_class_space_size; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
124 } |
14437
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13000
diff
changeset
|
125 |
13000
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
126 static void set_compressed_class_space_size(size_t size) { |
209aa13ab8c0
8024927: Nashorn performance regression with CompressedOops
coleenp
parents:
12998
diff
changeset
|
127 _compressed_class_space_size = size; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
128 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
129 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
130 static size_t _first_chunk_word_size; |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
131 static size_t _first_class_chunk_word_size; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
132 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
133 static size_t _commit_alignment; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
134 static size_t _reserve_alignment; |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
135 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
136 SpaceManager* _vsm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
137 SpaceManager* vsm() const { return _vsm; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
138 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
139 SpaceManager* _class_vsm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
140 SpaceManager* class_vsm() const { return _class_vsm; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
141 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
142 // Allocate space for metadata of type mdtype. This is space |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
143 // within a Metachunk and is used by |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
144 // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS) |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
145 MetaWord* allocate(size_t word_size, MetadataType mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
146 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
147 // Virtual Space lists for both classes and other metadata |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
148 static VirtualSpaceList* _space_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
149 static VirtualSpaceList* _class_space_list; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
150 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
151 static ChunkManager* _chunk_manager_metadata; |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
152 static ChunkManager* _chunk_manager_class; |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
153 |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17663
diff
changeset
|
154 static const MetaspaceTracer* _tracer; |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17663
diff
changeset
|
155 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
156 public: |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
157 static VirtualSpaceList* space_list() { return _space_list; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
158 static VirtualSpaceList* class_space_list() { return _class_space_list; } |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
159 static VirtualSpaceList* get_space_list(MetadataType mdtype) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
160 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
161 return mdtype == ClassType ? class_space_list() : space_list(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
162 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
163 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
164 static ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
165 static ChunkManager* chunk_manager_class() { return _chunk_manager_class; } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
166 static ChunkManager* get_chunk_manager(MetadataType mdtype) { |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
167 assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
168 return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata(); |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
169 } |
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
170 |
17768
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17663
diff
changeset
|
171 static const MetaspaceTracer* tracer() { return _tracer; } |
daef39043d2c
8036698: Add trace event for updates to metaspace gc threshold
ehelin
parents:
17663
diff
changeset
|
172 |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
173 private: |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17979
diff
changeset
|
174 // These 2 methods are used by DumpSharedSpaces only, where only _vsm is used. So we will |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
175 // maintain a single list for now. |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
176 void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17979
diff
changeset
|
177 void record_deallocation(void* ptr, size_t word_size); |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
178 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
179 #ifdef _LP64 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
180 static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
181 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
182 // Returns true if can use CDS with metaspace allocated as specified address. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
183 static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
184 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
185 static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
186 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
187 static void initialize_class_space(ReservedSpace rs); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
188 #endif |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
189 |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
190 class AllocRecord : public CHeapObj<mtClass> { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
191 public: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
192 AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
193 : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
194 AllocRecord *_next; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
195 address _ptr; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
196 MetaspaceObj::Type _type; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
197 int _byte_size; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
198 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
199 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
200 AllocRecord * _alloc_record_head; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
201 AllocRecord * _alloc_record_tail; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
202 |
12998
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12902
diff
changeset
|
203 size_t class_chunk_size(size_t word_size); |
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12902
diff
changeset
|
204 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
205 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
206 |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
207 Metaspace(Mutex* lock, MetaspaceType type); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
208 ~Metaspace(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
209 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
210 static void ergo_initialize(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
211 static void global_initialize(); |
17979
e204777ac770
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
17935
diff
changeset
|
212 static void post_initialize(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
213 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
214 static size_t first_chunk_word_size() { return _first_chunk_word_size; } |
7446
e51c9860cf66
8005082: NPG: Add specialized Metachunk sizes for reflection and anonymous classloaders
jmasa
parents:
7435
diff
changeset
|
215 static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
216 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
217 static size_t reserve_alignment() { return _reserve_alignment; } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
218 static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
219 static size_t commit_alignment() { return _commit_alignment; } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
220 static size_t commit_alignment_words() { return _commit_alignment / BytesPerWord; } |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
221 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
222 char* bottom() const; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
223 size_t used_words_slow(MetadataType mdtype) const; |
12235 | 224 size_t free_words_slow(MetadataType mdtype) const; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
225 size_t capacity_words_slow(MetadataType mdtype) const; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
226 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
227 size_t used_bytes_slow(MetadataType mdtype) const; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
228 size_t capacity_bytes_slow(MetadataType mdtype) const; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
229 |
12902 | 230 static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size, |
231 bool read_only, MetaspaceObj::Type type, TRAPS); | |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6734
diff
changeset
|
232 void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
233 |
6753
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6734
diff
changeset
|
234 MetaWord* expand_and_allocate(size_t size, |
8da5e203b993
7197557: NPG: nsk/sysdict/vm/stress/chain/chain004 hangs intermittently
jmasa
parents:
6734
diff
changeset
|
235 MetadataType mdtype); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
236 |
17935
7384f6a12fc1
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
17866
diff
changeset
|
237 static bool contains(const void* ptr); |
7384f6a12fc1
8038212: Method::is_valid_method() check has performance regression impact for stackwalking
coleenp
parents:
17866
diff
changeset
|
238 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
239 void dump(outputStream* const out) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
240 |
10175 | 241 // Free empty virtualspaces |
12303
b960c9df4f11
8025096: Move the ChunkManager instances out of the VirtualSpaceLists
stefank
parents:
12236
diff
changeset
|
242 static void purge(MetadataType mdtype); |
10175 | 243 static void purge(); |
244 | |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
245 static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, |
17770
5af31f70a866
8036701: Add trace event when a metaspace throws out of memory error
ehelin
parents:
17769
diff
changeset
|
246 MetaspaceObj::Type type, MetadataType mdtype, TRAPS); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
247 |
17769
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
248 static const char* metadata_type_name(Metaspace::MetadataType mdtype); |
bc7714614ad8
8036699: Add trace event when a metaspace allocation fails
ehelin
parents:
17768
diff
changeset
|
249 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
250 void print_on(outputStream* st) const; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
251 // Debugging support |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
252 void verify(); |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
253 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
254 class AllocRecordClosure : public StackObj { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
255 public: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
256 virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
257 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
258 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10330
diff
changeset
|
259 void iterate(AllocRecordClosure *closure); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
260 |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12063
diff
changeset
|
261 // Return TRUE only if UseCompressedClassPointers is True and DumpSharedSpaces is False. |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
262 static bool using_class_space() { |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
12063
diff
changeset
|
263 return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers && !DumpSharedSpaces); |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
264 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
265 |
12340
bc918fd1e584
8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents:
12303
diff
changeset
|
266 static bool is_class_space_allocation(MetadataType mdType) { |
bc918fd1e584
8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents:
12303
diff
changeset
|
267 return mdType == ClassType && using_class_space(); |
bc918fd1e584
8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
mgerdin
parents:
12303
diff
changeset
|
268 } |
12998
a6177f601c64
8026822: metaspace/flags/maxMetaspaceSize throws OOM of unexpected type.java.lang.OutOfMemoryError: Compressed class space
hseigel
parents:
12902
diff
changeset
|
269 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
270 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
271 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
272 class MetaspaceAux : AllStatic { |
12235 | 273 static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
274 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
275 // These methods iterate over the classloader data graph |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
276 // for the given Metaspace type. These are slow. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
277 static size_t used_bytes_slow(Metaspace::MetadataType mdtype); |
12235 | 278 static size_t free_bytes_slow(Metaspace::MetadataType mdtype); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
279 static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); |
12235 | 280 static size_t capacity_bytes_slow(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
281 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
282 // Running sum of space in all Metachunks that has been |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
283 // allocated to a Metaspace. This is used instead of |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
284 // iterating over all the classloaders. One for each |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
285 // type of Metadata |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
286 static size_t _capacity_words[Metaspace:: MetadataTypeCount]; |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
287 // Running sum of space in all Metachunks that |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
288 // are being used for metadata. One for each |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
289 // type of Metadata. |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
290 static size_t _used_words[Metaspace:: MetadataTypeCount]; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
291 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
292 public: |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
293 // Decrement and increment _allocated_capacity_words |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
294 static void dec_capacity(Metaspace::MetadataType type, size_t words); |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
295 static void inc_capacity(Metaspace::MetadataType type, size_t words); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
296 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
297 // Decrement and increment _allocated_used_words |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
298 static void dec_used(Metaspace::MetadataType type, size_t words); |
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
299 static void inc_used(Metaspace::MetadataType type, size_t words); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
300 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
301 // Total of space allocated to metadata in all Metaspaces. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
302 // This sums the space used in each Metachunk by |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
303 // iterating over the classloader data graph |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
304 static size_t used_bytes_slow() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
305 return used_bytes_slow(Metaspace::ClassType) + |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
306 used_bytes_slow(Metaspace::NonClassType); |
7435
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
307 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
308 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
309 // Used by MetaspaceCounters |
12235 | 310 static size_t free_chunks_total_words(); |
311 static size_t free_chunks_total_bytes(); | |
312 static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype); | |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
313 |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
314 static size_t capacity_words(Metaspace::MetadataType mdtype) { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
315 return _capacity_words[mdtype]; |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
316 } |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
317 static size_t capacity_words() { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
318 return capacity_words(Metaspace::NonClassType) + |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
319 capacity_words(Metaspace::ClassType); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
320 } |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
321 static size_t capacity_bytes(Metaspace::MetadataType mdtype) { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
322 return capacity_words(mdtype) * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
323 } |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
324 static size_t capacity_bytes() { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
325 return capacity_words() * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
326 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
327 |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
328 static size_t used_words(Metaspace::MetadataType mdtype) { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
329 return _used_words[mdtype]; |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
330 } |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
331 static size_t used_words() { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
332 return used_words(Metaspace::NonClassType) + |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
333 used_words(Metaspace::ClassType); |
10330
2b1a9d972fc2
8014862: Add fast Metasapce capacity and used per MetadataType
jmasa
parents:
10183
diff
changeset
|
334 } |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
335 static size_t used_bytes(Metaspace::MetadataType mdtype) { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
336 return used_words(mdtype) * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
337 } |
17866
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
338 static size_t used_bytes() { |
270d7cb38f40
8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents:
17810
diff
changeset
|
339 return used_words() * BytesPerWord; |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
340 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
341 |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
342 static size_t free_bytes(); |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
12056
diff
changeset
|
343 static size_t free_bytes(Metaspace::MetadataType mdtype); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
344 |
12235 | 345 static size_t reserved_bytes(Metaspace::MetadataType mdtype); |
346 static size_t reserved_bytes() { | |
347 return reserved_bytes(Metaspace::ClassType) + | |
348 reserved_bytes(Metaspace::NonClassType); | |
7435
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
349 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
350 |
12236
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
351 static size_t committed_bytes(Metaspace::MetadataType mdtype); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
352 static size_t committed_bytes() { |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
353 return committed_bytes(Metaspace::ClassType) + |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
354 committed_bytes(Metaspace::NonClassType); |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
355 } |
c4c768305a8f
8024638: Count and expose the amount of committed memory in the metaspaces
stefank
parents:
12235
diff
changeset
|
356 |
12235 | 357 static size_t min_chunk_size_words(); |
358 static size_t min_chunk_size_bytes() { | |
359 return min_chunk_size_words() * BytesPerWord; | |
7435
c71879335291
8005108: NPG: MetaspaceAux::used_in_bytes(), capacity_in_bytes() and reserved_in_bytes() return inconsistent numbers
stefank
parents:
7187
diff
changeset
|
360 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
361 |
17771
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
362 static bool has_chunk_free_list(Metaspace::MetadataType mdtype); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
363 static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype); |
9fdaa79b0c27
8036703: Add trace event with statistics for the metaspace chunk free lists
ehelin
parents:
17770
diff
changeset
|
364 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
365 // Print change in used metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
366 static void print_metaspace_change(size_t prev_metadata_used); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
367 static void print_on(outputStream * out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
368 static void print_on(outputStream * out, Metaspace::MetadataType mdtype); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
369 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
10405
diff
changeset
|
370 static void print_class_waste(outputStream* out); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
371 static void print_waste(outputStream* out); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
372 static void dump(outputStream* out); |
6969
6bc207d87e5d
7200229: NPG: possible performance issue exposed by closed/runtime/6559877/Test6559877.java
mgerdin
parents:
6885
diff
changeset
|
373 static void verify_free_chunks(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
374 // Checks that the values returned by allocated_capacity_bytes() and |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
375 // capacity_bytes_slow() are the same. |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
376 static void verify_capacity(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
377 static void verify_used(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
10175
diff
changeset
|
378 static void verify_metrics(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
379 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
380 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
381 // Metaspace are deallocated when their class loader are GC'ed. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
382 // This class implements a policy for inducing GC's to recover |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
383 // Metaspaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
384 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
385 class MetaspaceGC : AllStatic { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
386 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
387 // The current high-water-mark for inducing a GC. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
388 // When committed memory of all metaspaces reaches this value, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
389 // a GC is induced and the value is increased. Size is in bytes. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
390 static volatile intptr_t _capacity_until_GC; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
391 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
392 // For a CMS collection, signal that a concurrent collection should |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
393 // be started. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
394 static bool _should_concurrent_collect; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
395 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
396 static uint _shrink_factor; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
397 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
398 static size_t shrink_factor() { return _shrink_factor; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
399 void set_shrink_factor(uint v) { _shrink_factor = v; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
400 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
401 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
402 |
17979
e204777ac770
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
17935
diff
changeset
|
403 static void initialize(); |
e204777ac770
8042933: assert(capacity_until_gc >= committed_bytes) failed
ehelin
parents:
17935
diff
changeset
|
404 static void post_initialize(); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
405 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
406 static size_t capacity_until_GC(); |
20540
b509b7ff561c
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
20375
diff
changeset
|
407 static bool inc_capacity_until_GC(size_t v, |
b509b7ff561c
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
20375
diff
changeset
|
408 size_t* new_cap_until_GC = NULL, |
b509b7ff561c
8049599: MetaspaceGC::_capacity_until_GC can overflow
ehelin
parents:
20375
diff
changeset
|
409 size_t* old_cap_until_GC = NULL); |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
410 static size_t dec_capacity_until_GC(size_t v); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
411 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
412 static bool should_concurrent_collect() { return _should_concurrent_collect; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
413 static void set_should_concurrent_collect(bool v) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
414 _should_concurrent_collect = v; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
415 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
416 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
417 // The amount to increase the high-water-mark (_capacity_until_GC) |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
418 static size_t delta_capacity_until_GC(size_t bytes); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
419 |
12838
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
420 // Tells if we have can expand metaspace without hitting set limits. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
421 static bool can_expand(size_t words, bool is_class); |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
422 |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
423 // Returns amount that we can expand without hitting a GC, |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
424 // measured in words. |
85c1ca43713f
8024547: MaxMetaspaceSize should limit the committed memory used by the metaspaces
stefank
parents:
12340
diff
changeset
|
425 static size_t allowed_expansion(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
426 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
427 // Calculate the new high-water mark at which to induce |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
428 // a GC. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
429 static void compute_new_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
430 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
431 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
432 #endif // SHARE_VM_MEMORY_METASPACE_HPP |