src/hotspot/share/memory/metaspace/metaspaceStatistics.cpp
author stuefe
Tue, 10 Sep 2019 09:24:05 +0200
branchstuefe-new-metaspace-branch
changeset 58063 bdf136b8ae0e
parent 50193 49c3e91c424f
permissions -rw-r--r--
Initial changes for new metaspace. Only tested for Linux x64.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     1
/*
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
     2
 * Copyright (c) 2018, 2019 SAP SE. All rights reserved.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
     3
 * Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     5
 *
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     8
 * published by the Free Software Foundation.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
     9
 *
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    14
 * accompanied this code).
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    15
 *
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    19
 *
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    22
 * questions.
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    23
 *
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    24
 */
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    25
#include "precompiled.hpp"
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    26
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    27
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    28
#include "memory/metaspace/chunkLevel.hpp"
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    29
#include "memory/metaspace/metaspaceCommon.hpp"
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    30
#include "memory/metaspace/metaspaceStatistics.hpp"
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    31
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    32
#include "utilities/debug.hpp"
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    33
#include "utilities/globalDefinitions.hpp"
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    34
#include "utilities/ostream.hpp"
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    35
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    36
namespace metaspace {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    37
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    38
// ChunkManagerStatistics methods
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    39
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    40
// Returns total word size of all chunks in this manager.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    41
void cm_stats_t::add(const cm_stats_t& other) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    42
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    43
    num_chunks[l] += other.num_chunks[l];
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    44
    committed_word_size[l] += other.committed_word_size[l];
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    45
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    46
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    47
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    48
// Returns total word size of all chunks in this manager.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    49
size_t cm_stats_t::total_word_size() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    50
  size_t s = 0;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    51
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    52
    s += num_chunks[l] * chklvl::word_size_for_level(l);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    53
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    54
  return s;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    55
}
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    56
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    57
// Returns total committed word size of all chunks in this manager.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    58
size_t cm_stats_t::total_committed_word_size() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    59
  size_t s = 0;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    60
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    61
    s += committed_word_size[l];
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    62
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    63
  return s;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    64
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    65
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    66
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    67
void cm_stats_t::print_on(outputStream* st, size_t scale) const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    68
  // Note: used as part of MetaspaceReport so formatting matters.
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    69
  size_t total_size = 0;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    70
  size_t total_committed_size = 0;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    71
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    72
    st->cr();
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    73
    chklvl::print_chunk_size(st, l);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    74
    st->print(": ");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    75
    if (num_chunks[l] > 0) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    76
      const size_t word_size = num_chunks[l] * chklvl::word_size_for_level(l);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    77
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    78
      st->print("%4d, capacity=", num_chunks[l]);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    79
      print_scaled_words(st, word_size, scale);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    80
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    81
      st->print(", committed=");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    82
      print_scaled_words_and_percentage(st, committed_word_size[l], word_size, scale);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    83
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    84
      total_size += word_size;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    85
      total_committed_size += committed_word_size[l];
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    86
    } else {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    87
      st->print("(none)");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    88
    }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    89
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    90
  st->cr();
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    91
  st->print("Total word size: ");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    92
  print_scaled_words(st, total_size, scale);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    93
  st->print(", committed: ");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    94
  print_scaled_words_and_percentage(st, total_committed_size, total_size, scale);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    95
  st->cr();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    96
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
    97
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    98
#ifdef ASSERT
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
    99
void cm_stats_t::verify() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   100
  assert(total_committed_word_size() <= total_word_size(),
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   101
         "Sanity");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   102
}
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   103
#endif
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   104
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   105
// UsedChunksStatistics methods
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   106
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   107
void in_use_chunk_stats_t::print_on(outputStream* st, size_t scale) const {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   108
  int col = st->position();
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   109
  st->print("%4d chunk%s, ", num, num != 1 ? "s" : "");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   110
  if (num > 0) {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   111
    col += 14; st->fill_to(col);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   112
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   113
    print_scaled_words(st, word_size, scale, 5);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   114
    st->print(" capacity,");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   115
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   116
    col += 20; st->fill_to(col);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   117
    print_scaled_words_and_percentage(st, committed_words, word_size, scale, 5);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   118
    st->print(" committed, ");
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   119
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   120
    col += 18; st->fill_to(col);
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   121
    print_scaled_words_and_percentage(st, used_words, word_size, scale, 5);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   122
    st->print(" used, ");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   123
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   124
    col += 20; st->fill_to(col);
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   125
    print_scaled_words_and_percentage(st, free_words, word_size, scale, 5);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   126
    st->print(" free, ");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   127
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   128
    col += 20; st->fill_to(col);
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   129
    print_scaled_words_and_percentage(st, waste_words, word_size, scale, 5);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   130
    st->print(" waste ");
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   131
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   132
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   133
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   134
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   135
#ifdef ASSERT
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   136
void in_use_chunk_stats_t::verify() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   137
  assert(word_size >= committed_words &&
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   138
      committed_words == used_words + free_words + waste_words,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   139
         "Sanity: cap " SIZE_FORMAT ", committed " SIZE_FORMAT ", used " SIZE_FORMAT ", free " SIZE_FORMAT ", waste " SIZE_FORMAT ".",
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   140
         word_size, committed_words, used_words, free_words, waste_words);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   141
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   142
#endif
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   143
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   144
// SpaceManagerStatistics methods
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   145
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   146
void sm_stats_t::add(const sm_stats_t& other) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   147
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   148
    stats[l].add(other.stats[l]);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   149
  }
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   150
  free_blocks_num += other.free_blocks_num;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   151
  free_blocks_word_size += other.free_blocks_word_size;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   152
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   153
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   154
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   155
// Returns total chunk statistics over all chunk types.
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   156
in_use_chunk_stats_t sm_stats_t::totals() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   157
  in_use_chunk_stats_t out;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   158
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   159
    out.add(stats[l]);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   160
  }
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   161
  return out;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   162
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   163
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   164
void sm_stats_t::print_on(outputStream* st, size_t scale,  bool detailed) const {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   165
  streamIndentor sti(st);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   166
  if (detailed) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   167
    st->cr_indent();
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   168
    st->print("Usage by chunk level:");
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   169
    {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   170
      streamIndentor sti2(st);
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   171
      for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   172
        st->cr_indent();
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   173
        chklvl::print_chunk_size(st, l);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   174
        st->print(" chunks: ");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   175
        if (stats[l].num == 0) {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   176
          st->print(" (none)");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   177
        } else {
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   178
          stats[l].print_on(st, scale);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   179
        }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   180
      }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   181
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   182
      st->cr_indent();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   183
      st->print("%15s: ", "-total-");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   184
      totals().print_on(st, scale);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   185
    }
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   186
    if (free_blocks_num > 0) {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   187
      st->cr_indent();
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   188
      st->print("deallocated: " UINTX_FORMAT " blocks with ", free_blocks_num);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   189
      print_scaled_words(st, free_blocks_word_size, scale);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   190
    }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   191
  } else {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   192
    totals().print_on(st, scale);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   193
    st->print(", ");
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   194
    st->print("deallocated: " UINTX_FORMAT " blocks with ", free_blocks_num);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   195
    print_scaled_words(st, free_blocks_word_size, scale);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   196
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   197
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   198
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   199
#ifdef ASSERT
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   200
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   201
void sm_stats_t::verify() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   202
  size_t total_used = 0;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   203
  for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   204
    stats[l].verify();
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   205
    total_used += stats[l].used_words;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   206
  }
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   207
  // Deallocated allocations still count as used
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   208
  assert(total_used >= free_blocks_word_size,
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   209
         "Sanity");
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   210
}
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   211
#endif
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   212
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   213
// ClassLoaderMetaspaceStatistics methods
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   214
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   215
// Returns total space manager statistics for both class and non-class metaspace
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   216
sm_stats_t clms_stats_t::totals() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   217
  sm_stats_t out;
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   218
  out.add(sm_stats_nonclass);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   219
  out.add(sm_stats_class);
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   220
  return out;
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   221
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   222
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   223
void clms_stats_t::print_on(outputStream* st, size_t scale, bool detailed) const {
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   224
  streamIndentor sti(st);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   225
  st->cr_indent();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   226
  if (Metaspace::using_class_space()) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   227
    st->print("Non-Class: ");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   228
  }
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   229
  sm_stats_nonclass.print_on(st, scale, detailed);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   230
  if (detailed) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   231
    st->cr();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   232
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   233
  if (Metaspace::using_class_space()) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   234
    st->cr_indent();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   235
    st->print("    Class: ");
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   236
    sm_stats_class.print_on(st, scale, detailed);
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   237
    if (detailed) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   238
      st->cr();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   239
    }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   240
    st->cr_indent();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   241
    st->print("     Both: ");
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   242
    totals().print_on(st, scale, detailed);
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   243
    if (detailed) {
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   244
      st->cr();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   245
    }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   246
  }
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   247
  st->cr();
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   248
}
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   249
58063
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   250
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   251
#ifdef ASSERT
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   252
void clms_stats_t::verify() const {
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   253
  sm_stats_nonclass.verify();
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   254
  sm_stats_class.verify();
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   255
}
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   256
#endif
bdf136b8ae0e Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents: 50193
diff changeset
   257
49980
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   258
} // end namespace metaspace
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   259
57dd7b4ba338 8201572: Improve Metaspace Statistics
stuefe
parents:
diff changeset
   260
50193
49c3e91c424f 8176808: Split up metaspace.cpp
stuefe
parents: 49980
diff changeset
   261