src/share/vm/memory/metaspaceCounters.cpp

Wed, 01 May 2013 14:11:01 +0100

author
chegar
date
Wed, 01 May 2013 14:11:01 +0100
changeset 5246
4b52137b07c9
parent 4680
0624b9d81255
child 5015
868d87ed63c8
permissions
-rw-r--r--

Merge

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

mercurial