Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/memory/metaspaceCounters.cpp
40949 views
1
/*
2
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#include "precompiled.hpp"
26
#include "memory/metaspace.hpp"
27
#include "memory/metaspaceCounters.hpp"
28
#include "memory/metaspaceStats.hpp"
29
#include "memory/metaspaceUtils.hpp"
30
#include "memory/resourceArea.hpp"
31
#include "runtime/globals.hpp"
32
#include "runtime/perfData.hpp"
33
#include "utilities/exceptions.hpp"
34
35
class MetaspacePerfCounters {
36
friend class VMStructs;
37
PerfVariable* _capacity;
38
PerfVariable* _used;
39
PerfVariable* _max_capacity;
40
41
PerfVariable* create_variable(const char *ns, const char *name, size_t value, TRAPS) {
42
const char *path = PerfDataManager::counter_name(ns, name);
43
return PerfDataManager::create_variable(SUN_GC, path, PerfData::U_Bytes, value, THREAD);
44
}
45
46
void create_constant(const char *ns, const char *name, size_t value, TRAPS) {
47
const char *path = PerfDataManager::counter_name(ns, name);
48
PerfDataManager::create_constant(SUN_GC, path, PerfData::U_Bytes, value, THREAD);
49
}
50
51
public:
52
MetaspacePerfCounters() : _capacity(NULL), _used(NULL), _max_capacity(NULL) {}
53
54
void initialize(const char* ns) {
55
assert(_capacity == NULL, "Only initialize once");
56
EXCEPTION_MARK;
57
ResourceMark rm;
58
59
create_constant(ns, "minCapacity", 0, THREAD); // min_capacity makes little sense in the context of metaspace
60
_capacity = create_variable(ns, "capacity", 0, THREAD);
61
_max_capacity = create_variable(ns, "maxCapacity", 0, THREAD);
62
_used = create_variable(ns, "used", 0, THREAD);
63
}
64
65
void update(const MetaspaceStats& stats) {
66
_capacity->set_value(stats.committed());
67
_max_capacity->set_value(stats.reserved());
68
_used->set_value(stats.used());
69
}
70
};
71
72
static MetaspacePerfCounters g_meta_space_perf_counters; // class + nonclass
73
static MetaspacePerfCounters g_class_space_perf_counters;
74
75
void MetaspaceCounters::initialize_performance_counters() {
76
if (UsePerfData) {
77
g_meta_space_perf_counters.initialize("metaspace");
78
g_class_space_perf_counters.initialize("compressedclassspace");
79
update_performance_counters();
80
}
81
}
82
83
void MetaspaceCounters::update_performance_counters() {
84
if (UsePerfData) {
85
g_meta_space_perf_counters.update(MetaspaceUtils::get_combined_statistics());
86
g_class_space_perf_counters.update(MetaspaceUtils::get_statistics(Metaspace::ClassType));
87
}
88
}
89
90