hotspot/src/share/vm/memory/metaspaceCounters.cpp
author ehelin
Mon, 31 Mar 2014 17:09:38 +0200
changeset 23854 50f7f89b34e0
parent 22234 da823d78ad65
permissions -rw-r--r--
8038934: Remove prefix allocated_ from methods and variables in Metaspace Reviewed-by: jmasa, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 20001
diff changeset
     2
 * Copyright (c) 2012, 2013, 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"
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    28
#include "runtime/globals.hpp"
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    29
#include "runtime/perfData.hpp"
15860
4375d0d48f37 8004172: Update jstat counter names to reflect metaspace changes
ehelin
parents: 14847
diff changeset
    30
#include "utilities/exceptions.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    31
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    32
class MetaspacePerfCounters: public CHeapObj<mtInternal> {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    33
  friend class VMStructs;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    34
  PerfVariable*      _capacity;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    35
  PerfVariable*      _used;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    36
  PerfVariable*      _max_capacity;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    37
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    38
  PerfVariable* create_variable(const char *ns, const char *name, size_t value, TRAPS) {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    39
    const char *path = PerfDataManager::counter_name(ns, name);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    40
    return PerfDataManager::create_variable(SUN_GC, path, PerfData::U_Bytes, value, THREAD);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    41
  }
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    42
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    43
  void create_constant(const char *ns, const char *name, size_t value, TRAPS) {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    44
    const char *path = PerfDataManager::counter_name(ns, name);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    45
    PerfDataManager::create_constant(SUN_GC, path, PerfData::U_Bytes, value, THREAD);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    46
  }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    47
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    48
 public:
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    49
  MetaspacePerfCounters(const char* ns, size_t min_capacity, size_t curr_capacity, size_t max_capacity, size_t used) {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    50
    EXCEPTION_MARK;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    51
    ResourceMark rm;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    52
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    53
    create_constant(ns, "minCapacity", min_capacity, THREAD);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    54
    _capacity = create_variable(ns, "capacity", curr_capacity, THREAD);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    55
    _max_capacity = create_variable(ns, "maxCapacity", max_capacity, THREAD);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    56
    _used = create_variable(ns, "used", used, THREAD);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    57
  }
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    58
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    59
  void update(size_t capacity, size_t max_capacity, size_t used) {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    60
    _capacity->set_value(capacity);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    61
    _max_capacity->set_value(max_capacity);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    62
    _used->set_value(used);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    63
  }
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    64
};
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    65
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    66
MetaspacePerfCounters* MetaspaceCounters::_perf_counters = NULL;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    67
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    68
size_t MetaspaceCounters::used() {
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 22234
diff changeset
    69
  return MetaspaceAux::used_bytes();
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    70
}
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    71
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    72
size_t MetaspaceCounters::capacity() {
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    73
  return MetaspaceAux::committed_bytes();
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    74
}
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    75
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    76
size_t MetaspaceCounters::max_capacity() {
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    77
  return MetaspaceAux::reserved_bytes();
17109
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 15860
diff changeset
    78
}
90e6c31bbbe4 8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents: 15860
diff changeset
    79
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    80
void MetaspaceCounters::initialize_performance_counters() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    81
  if (UsePerfData) {
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    82
    assert(_perf_counters == NULL, "Should only be initialized once");
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    83
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    84
    size_t min_capacity = 0;
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    85
    _perf_counters = new MetaspacePerfCounters("metaspace", min_capacity,
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    86
                                               capacity(), max_capacity(), used());
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    87
  }
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_performance_counters() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    91
  if (UsePerfData) {
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    92
    assert(_perf_counters != NULL, "Should be initialized");
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    93
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
    94
    _perf_counters->update(capacity(), max_capacity(), used());
13728
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
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    98
MetaspacePerfCounters* CompressedClassSpaceCounters::_perf_counters = NULL;
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
    99
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   100
size_t CompressedClassSpaceCounters::used() {
23854
50f7f89b34e0 8038934: Remove prefix allocated_ from methods and variables in Metaspace
ehelin
parents: 22234
diff changeset
   101
  return MetaspaceAux::used_bytes(Metaspace::ClassType);
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   102
}
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   103
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   104
size_t CompressedClassSpaceCounters::capacity() {
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   105
  return MetaspaceAux::committed_bytes(Metaspace::ClassType);
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   106
}
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   107
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   108
size_t CompressedClassSpaceCounters::max_capacity() {
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   109
  return MetaspaceAux::reserved_bytes(Metaspace::ClassType);
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   110
}
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   111
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   112
void CompressedClassSpaceCounters::update_performance_counters() {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19322
diff changeset
   113
  if (UsePerfData && UseCompressedClassPointers) {
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   114
    assert(_perf_counters != NULL, "Should be initialized");
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   115
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   116
    _perf_counters->update(capacity(), max_capacity(), used());
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   117
  }
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   118
}
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   119
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   120
void CompressedClassSpaceCounters::initialize_performance_counters() {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   121
  if (UsePerfData) {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   122
    assert(_perf_counters == NULL, "Should only be initialized once");
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   123
    const char* ns = "compressedclassspace";
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   124
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 19322
diff changeset
   125
    if (UseCompressedClassPointers) {
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   126
      size_t min_capacity = 0;
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   127
      _perf_counters = new MetaspacePerfCounters(ns, min_capacity, capacity(),
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19988
diff changeset
   128
                                                 max_capacity(), used());
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   129
    } else {
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   130
      _perf_counters = new MetaspacePerfCounters(ns, 0, 0, 0, 0);
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   131
    }
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   132
  }
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 17109
diff changeset
   133
}