Mercurial > hg > truffle
annotate src/share/vm/memory/metaspaceCounters.cpp @ 12182:bb57d48691f5
Merge
author | tschatzl |
---|---|
date | Thu, 05 Sep 2013 14:15:54 +0200 |
parents | 1a8fb39bdbc4 |
children | 7944aba7ba41 |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
7440 | 2 * Copyright (c) 2012, 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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 #include "memory/metaspaceCounters.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 #include "memory/resourceArea.hpp" |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
28 #include "runtime/globals.hpp" |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
29 #include "runtime/perfData.hpp" |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
30 #include "utilities/exceptions.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
32 class MetaspacePerfCounters: public CHeapObj<mtInternal> { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
33 friend class VMStructs; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
34 PerfVariable* _capacity; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
35 PerfVariable* _used; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
36 PerfVariable* _max_capacity; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
37 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
38 PerfVariable* create_variable(const char *ns, const char *name, size_t value, TRAPS) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
39 const char *path = PerfDataManager::counter_name(ns, name); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
40 return PerfDataManager::create_variable(SUN_GC, path, PerfData::U_Bytes, value, THREAD); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
41 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
42 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
43 void create_constant(const char *ns, const char *name, size_t value, TRAPS) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
44 const char *path = PerfDataManager::counter_name(ns, name); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
45 PerfDataManager::create_constant(SUN_GC, path, PerfData::U_Bytes, value, THREAD); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
46 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
48 public: |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
49 MetaspacePerfCounters(const char* ns, size_t min_capacity, size_t curr_capacity, size_t max_capacity, size_t used) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
50 EXCEPTION_MARK; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
51 ResourceMark rm; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
52 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
53 create_constant(ns, "minCapacity", min_capacity, THREAD); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
54 _capacity = create_variable(ns, "capacity", curr_capacity, THREAD); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
55 _max_capacity = create_variable(ns, "maxCapacity", max_capacity, THREAD); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
56 _used = create_variable(ns, "used", used, THREAD); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
57 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
58 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
59 void update(size_t capacity, size_t max_capacity, size_t used) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
60 _capacity->set_value(capacity); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
61 _max_capacity->set_value(max_capacity); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
62 _used->set_value(used); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
63 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
64 }; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
65 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
66 MetaspacePerfCounters* MetaspaceCounters::_perf_counters = NULL; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
67 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
68 size_t MetaspaceCounters::calculate_capacity() { |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
69 // The total capacity is the sum of |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
70 // 1) capacity of Metachunks in use by all Metaspaces |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
71 // 2) unused space at the end of each Metachunk |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
72 // 3) space in the freelist |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
73 size_t total_capacity = MetaspaceAux::allocated_capacity_bytes() |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
74 + MetaspaceAux::free_bytes() + MetaspaceAux::free_chunks_total_in_bytes(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
75 return total_capacity; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
76 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
77 |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
78 void MetaspaceCounters::initialize_performance_counters() { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 if (UsePerfData) { |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
80 assert(_perf_counters == NULL, "Should only be initialized once"); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
81 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 size_t min_capacity = MetaspaceAux::min_chunk_size(); |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
83 size_t capacity = calculate_capacity(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 size_t max_capacity = MetaspaceAux::reserved_in_bytes(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
85 size_t used = MetaspaceAux::allocated_used_bytes(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
87 _perf_counters = new MetaspacePerfCounters("metaspace", min_capacity, capacity, max_capacity, used); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 } |
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 void MetaspaceCounters::update_performance_counters() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 if (UsePerfData) { |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
93 assert(_perf_counters != NULL, "Should be initialized"); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
94 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
95 size_t capacity = calculate_capacity(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
96 size_t max_capacity = MetaspaceAux::reserved_in_bytes(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
97 size_t used = MetaspaceAux::allocated_used_bytes(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
98 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
99 _perf_counters->update(capacity, max_capacity, used); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
100 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 |
12063
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
103 MetaspacePerfCounters* CompressedClassSpaceCounters::_perf_counters = NULL; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
104 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
105 size_t CompressedClassSpaceCounters::calculate_capacity() { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
106 return MetaspaceAux::allocated_capacity_bytes(_class_type) + |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
107 MetaspaceAux::free_bytes(_class_type) + |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
108 MetaspaceAux::free_chunks_total_in_bytes(_class_type); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
109 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
110 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
111 void CompressedClassSpaceCounters::update_performance_counters() { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
112 if (UsePerfData && UseCompressedKlassPointers) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
113 assert(_perf_counters != NULL, "Should be initialized"); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
114 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
115 size_t capacity = calculate_capacity(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
116 size_t max_capacity = MetaspaceAux::reserved_in_bytes(_class_type); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
117 size_t used = MetaspaceAux::allocated_used_bytes(_class_type); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
118 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
119 _perf_counters->update(capacity, max_capacity, used); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
120 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
121 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
122 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
123 void CompressedClassSpaceCounters::initialize_performance_counters() { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
124 if (UsePerfData) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
125 assert(_perf_counters == NULL, "Should only be initialized once"); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
126 const char* ns = "compressedclassspace"; |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
127 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
128 if (UseCompressedKlassPointers) { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
129 size_t min_capacity = MetaspaceAux::min_chunk_size(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
130 size_t capacity = calculate_capacity(); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
131 size_t max_capacity = MetaspaceAux::reserved_in_bytes(_class_type); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
132 size_t used = MetaspaceAux::allocated_used_bytes(_class_type); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
133 |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
134 _perf_counters = new MetaspacePerfCounters(ns, min_capacity, capacity, max_capacity, used); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
135 } else { |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
136 _perf_counters = new MetaspacePerfCounters(ns, 0, 0, 0, 0); |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
137 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
138 } |
1a8fb39bdbc4
8014659: NPG: performance counters for compressed klass space
ehelin
parents:
10183
diff
changeset
|
139 } |