author | stefank |
Mon, 18 Mar 2013 09:34:58 +0100 | |
changeset 16387 | 6751eb6eceb0 |
parent 15860 | 4375d0d48f37 |
child 17109 | 90e6c31bbbe4 |
permissions | -rw-r--r-- |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 |
/* |
14847 | 2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 |
* questions. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 |
*/ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
24 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 |
#include "memory/metaspaceCounters.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 |
#include "memory/resourceArea.hpp" |
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
28 |
#include "utilities/exceptions.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 |
MetaspaceCounters* MetaspaceCounters::_metaspace_counters = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
|
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
32 |
MetaspaceCounters::MetaspaceCounters() : |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
33 |
_capacity(NULL), |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
34 |
_used(NULL), |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
35 |
_max_capacity(NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 |
if (UsePerfData) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
37 |
size_t min_capacity = MetaspaceAux::min_chunk_size(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 |
size_t max_capacity = MetaspaceAux::reserved_in_bytes(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 |
size_t curr_capacity = MetaspaceAux::capacity_in_bytes(); |
13737 | 40 |
size_t used = MetaspaceAux::used_in_bytes(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 |
initialize(min_capacity, max_capacity, curr_capacity, used); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 |
|
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
46 |
static PerfVariable* create_ms_variable(const char *ns, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
47 |
const char *name, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
48 |
size_t value, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
49 |
TRAPS) { |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
50 |
const char *path = PerfDataManager::counter_name(ns, name); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
51 |
PerfVariable *result = |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
52 |
PerfDataManager::create_variable(SUN_GC, path, PerfData::U_Bytes, value, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
53 |
CHECK_NULL); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
54 |
return result; |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
55 |
} |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
56 |
|
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
57 |
static void create_ms_constant(const char *ns, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
58 |
const char *name, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
59 |
size_t value, |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
60 |
TRAPS) { |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
61 |
const char *path = PerfDataManager::counter_name(ns, name); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
62 |
PerfDataManager::create_constant(SUN_GC, path, PerfData::U_Bytes, value, CHECK); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
63 |
} |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
64 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
65 |
void MetaspaceCounters::initialize(size_t min_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
66 |
size_t max_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
67 |
size_t curr_capacity, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
68 |
size_t used) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
69 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
70 |
if (UsePerfData) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
71 |
EXCEPTION_MARK; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
72 |
ResourceMark rm; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
73 |
|
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
74 |
const char *ms = "metaspace"; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 |
|
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
76 |
create_ms_constant(ms, "minCapacity", min_capacity, CHECK); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
77 |
_max_capacity = create_ms_variable(ms, "maxCapacity", max_capacity, CHECK); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
78 |
_capacity = create_ms_variable(ms, "capacity", curr_capacity, CHECK); |
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
79 |
_used = create_ms_variable(ms, "used", used, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
80 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
void MetaspaceCounters::update_capacity() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 |
assert(UsePerfData, "Should not be called unless being used"); |
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
85 |
assert(_capacity != NULL, "Should be initialized"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 |
size_t capacity_in_bytes = MetaspaceAux::capacity_in_bytes(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 |
_capacity->set_value(capacity_in_bytes); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 |
void MetaspaceCounters::update_used() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 |
assert(UsePerfData, "Should not be called unless being used"); |
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
92 |
assert(_used != NULL, "Should be initialized"); |
13737 | 93 |
size_t used_in_bytes = MetaspaceAux::used_in_bytes(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 |
_used->set_value(used_in_bytes); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
95 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
96 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
97 |
void MetaspaceCounters::update_max_capacity() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
98 |
assert(UsePerfData, "Should not be called unless being used"); |
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
99 |
assert(_max_capacity != NULL, "Should be initialized"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
100 |
size_t reserved_in_bytes = MetaspaceAux::reserved_in_bytes(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 |
_max_capacity->set_value(reserved_in_bytes); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
104 |
void MetaspaceCounters::update_all() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 |
if (UsePerfData) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 |
update_used(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
107 |
update_capacity(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 |
update_max_capacity(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
109 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
110 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 |
void MetaspaceCounters::initialize_performance_counters() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
113 |
if (UsePerfData) { |
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
114 |
assert(_metaspace_counters == NULL, "Should only be initialized once"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 |
_metaspace_counters = new MetaspaceCounters(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
119 |
void MetaspaceCounters::update_performance_counters() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
120 |
if (UsePerfData) { |
15860
4375d0d48f37
8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents:
14847
diff
changeset
|
121 |
assert(_metaspace_counters != NULL, "Should be initialized"); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
122 |
_metaspace_counters->update_all(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
124 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 |