Mercurial > hg > truffle
annotate src/share/vm/memory/metaspaceCounters.cpp @ 11969:c65045599519
8021314: minimal1.make needs to force off components not supported by the minimal VM
Reviewed-by: coleenp, bpittore
author | dholmes |
---|---|
date | Thu, 25 Jul 2013 21:05:29 -0400 |
parents | 868d87ed63c8 |
children | 1a8fb39bdbc4 |
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" |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
28 #include "utilities/exceptions.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 MetaspaceCounters* MetaspaceCounters::_metaspace_counters = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
32 size_t MetaspaceCounters::calc_total_capacity() { |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
33 // The total capacity is the sum of |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
34 // 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
|
35 // 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
|
36 // 3) space in the freelist |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
37 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
|
38 + 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
|
39 return total_capacity; |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
40 } |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
41 |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
42 MetaspaceCounters::MetaspaceCounters() : |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
43 _capacity(NULL), |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
44 _used(NULL), |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
45 _max_capacity(NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 if (UsePerfData) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
47 size_t min_capacity = MetaspaceAux::min_chunk_size(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
48 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
|
49 size_t curr_capacity = calc_total_capacity(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
50 size_t used = MetaspaceAux::allocated_used_bytes(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
52 initialize(min_capacity, max_capacity, curr_capacity, used); |
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 |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
56 static PerfVariable* create_ms_variable(const char *ns, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
57 const char *name, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
58 size_t value, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
59 TRAPS) { |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
60 const char *path = PerfDataManager::counter_name(ns, name); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
61 PerfVariable *result = |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
62 PerfDataManager::create_variable(SUN_GC, path, PerfData::U_Bytes, value, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
63 CHECK_NULL); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
64 return result; |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
65 } |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
66 |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
67 static void create_ms_constant(const char *ns, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
68 const char *name, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
69 size_t value, |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
70 TRAPS) { |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
71 const char *path = PerfDataManager::counter_name(ns, name); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
72 PerfDataManager::create_constant(SUN_GC, path, PerfData::U_Bytes, value, CHECK); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
73 } |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
74 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 void MetaspaceCounters::initialize(size_t min_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 size_t max_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 size_t curr_capacity, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
78 size_t used) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
80 if (UsePerfData) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 EXCEPTION_MARK; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 ResourceMark rm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
84 const char *ms = "metaspace"; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
86 create_ms_constant(ms, "minCapacity", min_capacity, CHECK); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
87 _max_capacity = create_ms_variable(ms, "maxCapacity", max_capacity, CHECK); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
88 _capacity = create_ms_variable(ms, "capacity", curr_capacity, CHECK); |
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
89 _used = create_ms_variable(ms, "used", used, CHECK); |
6725
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 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
93 void MetaspaceCounters::update_capacity() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 assert(UsePerfData, "Should not be called unless being used"); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
95 size_t total_capacity = calc_total_capacity(); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
96 _capacity->set_value(total_capacity); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
97 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
98 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 void MetaspaceCounters::update_used() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
100 assert(UsePerfData, "Should not be called unless being used"); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8680
diff
changeset
|
101 size_t used_in_bytes = MetaspaceAux::allocated_used_bytes(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 _used->set_value(used_in_bytes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
104 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 void MetaspaceCounters::update_max_capacity() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 assert(UsePerfData, "Should not be called unless being used"); |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
107 assert(_max_capacity != NULL, "Should be initialized"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 size_t reserved_in_bytes = MetaspaceAux::reserved_in_bytes(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
109 _max_capacity->set_value(reserved_in_bytes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
110 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 void MetaspaceCounters::update_all() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
113 if (UsePerfData) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
114 update_used(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 update_capacity(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 update_max_capacity(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
119 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
120 void MetaspaceCounters::initialize_performance_counters() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
121 if (UsePerfData) { |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
122 assert(_metaspace_counters == NULL, "Should only be initialized once"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 _metaspace_counters = new MetaspaceCounters(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
124 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
126 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
127 void MetaspaceCounters::update_performance_counters() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
128 if (UsePerfData) { |
8680
0624b9d81255
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
7440
diff
changeset
|
129 assert(_metaspace_counters != NULL, "Should be initialized"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
130 _metaspace_counters->update_all(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
131 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
132 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
133 |