src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49377 ecd91135d645
child 49824 e242740a92b8
permissions -rw-r--r--
8200426: Make G1 code use _g1h members Summary: Consistently use _g1h member names for cached G1CollectedHeap* variables. Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     1
/*
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     4
 *
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     7
 * published by the Free Software Foundation.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     8
 *
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    13
 * accompanied this code).
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    14
 *
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    18
 *
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    21
 * questions.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    22
 *
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    23
 */
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    24
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22551
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22551
diff changeset
    27
#include "gc/g1/g1MonitoringSupport.hpp"
37985
539c597ee0fa 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents: 37235
diff changeset
    28
#include "gc/g1/g1Policy.hpp"
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
    29
#include "gc/shared/hSpaceCounters.hpp"
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    30
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    31
G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    32
                                           const char* name,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    33
                                           int ordinal, int spaces,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    34
                                           size_t min_capacity,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    35
                                           size_t max_capacity,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    36
                                           size_t curr_capacity)
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    37
  : GenerationCounters(name, ordinal, spaces, min_capacity,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    38
                       max_capacity, curr_capacity), _g1mm(g1mm) { }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    39
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    40
// We pad the capacity three times given that the young generation
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    41
// contains three spaces (eden and two survivors).
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    42
G1YoungGenerationCounters::G1YoungGenerationCounters(G1MonitoringSupport* g1mm,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    43
                                                     const char* name)
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    44
  : G1GenerationCounters(g1mm, name, 0 /* ordinal */, 3 /* spaces */,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    45
               G1MonitoringSupport::pad_capacity(0, 3) /* min_capacity */,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    46
               G1MonitoringSupport::pad_capacity(g1mm->young_gen_max(), 3),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    47
               G1MonitoringSupport::pad_capacity(0, 3) /* curr_capacity */) {
12096
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    48
  if (UsePerfData) {
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    49
    update_all();
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    50
  }
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    51
}
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    52
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    53
G1OldGenerationCounters::G1OldGenerationCounters(G1MonitoringSupport* g1mm,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    54
                                                 const char* name)
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    55
  : G1GenerationCounters(g1mm, name, 1 /* ordinal */, 1 /* spaces */,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    56
               G1MonitoringSupport::pad_capacity(0) /* min_capacity */,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    57
               G1MonitoringSupport::pad_capacity(g1mm->old_gen_max()),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    58
               G1MonitoringSupport::pad_capacity(0) /* curr_capacity */) {
12096
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    59
  if (UsePerfData) {
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    60
    update_all();
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    61
  }
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    62
}
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    63
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    64
void G1YoungGenerationCounters::update_all() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    65
  size_t committed =
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    66
            G1MonitoringSupport::pad_capacity(_g1mm->young_gen_committed(), 3);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    67
  _current_size->set_value(committed);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    68
}
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    69
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    70
void G1OldGenerationCounters::update_all() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    71
  size_t committed =
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    72
            G1MonitoringSupport::pad_capacity(_g1mm->old_gen_committed());
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    73
  _current_size->set_value(committed);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    74
}
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    75
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    76
G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    77
  _g1h(g1h),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    78
  _incremental_collection_counters(NULL),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    79
  _full_collection_counters(NULL),
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
    80
  _conc_collection_counters(NULL),
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    81
  _old_collection_counters(NULL),
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    82
  _old_space_counters(NULL),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    83
  _young_collection_counters(NULL),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    84
  _eden_counters(NULL),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    85
  _from_counters(NULL),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    86
  _to_counters(NULL),
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    87
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    88
  _overall_reserved(0),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    89
  _overall_committed(0),    _overall_used(0),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    90
  _young_region_num(0),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    91
  _young_gen_committed(0),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    92
  _eden_committed(0),       _eden_used(0),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    93
  _survivor_committed(0),   _survivor_used(0),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    94
  _old_committed(0),        _old_used(0) {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    95
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    96
  _overall_reserved = g1h->max_capacity();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    97
  recalculate_sizes();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    98
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    99
  // Counters for GC collections
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   100
  //
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   101
  //  name "collector.0".  In a generational collector this would be the
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   102
  // young generation collection.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   103
  _incremental_collection_counters =
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   104
    new CollectorCounters("G1 incremental collections", 0);
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   105
  //   name "collector.1".  In a generational collector this would be the
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   106
  // old generation collection.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   107
  _full_collection_counters =
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   108
    new CollectorCounters("G1 stop-the-world full collections", 1);
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   109
  //   name "collector.2".  In a generational collector this would be the
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   110
  // STW phases in concurrent collection.
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   111
  _conc_collection_counters =
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   112
    new CollectorCounters("G1 stop-the-world phases", 2);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   113
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   114
  // timer sampling for all counters supporting sampling only update the
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   115
  // used value.  See the take_sample() method.  G1 requires both used and
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   116
  // capacity updated so sampling is not currently used.  It might
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   117
  // be sufficient to update all counters in take_sample() even though
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   118
  // take_sample() only returns "used".  When sampling was used, there
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   119
  // were some anomolous values emitted which may have been the consequence
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   120
  // of not updating all values simultaneously (i.e., see the calculation done
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   121
  // in eden_space_used(), is it possible that the values used to
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   122
  // calculate either eden_used or survivor_used are being updated by
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   123
  // the collector when the sample is being done?).
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   124
  const bool sampled = false;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   125
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   126
  // "Generation" and "Space" counters.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   127
  //
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   128
  //  name "generation.1" This is logically the old generation in
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   129
  // generational GC terms.  The "1, 1" parameters are for
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   130
  // the n-th generation (=1) with 1 space.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   131
  // Counters are created from minCapacity, maxCapacity, and capacity
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   132
  _old_collection_counters = new G1OldGenerationCounters(this, "old");
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   133
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   134
  //  name  "generation.1.space.0"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   135
  // Counters are created from maxCapacity, capacity, initCapacity,
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   136
  // and used.
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   137
  _old_space_counters = new HSpaceCounters(_old_collection_counters->name_space(),
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   138
    "space", 0 /* ordinal */,
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   139
    pad_capacity(overall_reserved()) /* max_capacity */,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   140
    pad_capacity(old_space_committed()) /* init_capacity */);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   141
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   142
  //   Young collection set
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   143
  //  name "generation.0".  This is logically the young generation.
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   144
  //  The "0, 3" are parameters for the n-th generation (=0) with 3 spaces.
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   145
  // See  _old_collection_counters for additional counters
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   146
  _young_collection_counters = new G1YoungGenerationCounters(this, "young");
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   147
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   148
  const char* young_collection_name_space = _young_collection_counters->name_space();
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   149
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   150
  //  name "generation.0.space.0"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   151
  // See _old_space_counters for additional counters
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   152
  _eden_counters = new HSpaceCounters(young_collection_name_space,
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   153
    "eden", 0 /* ordinal */,
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   154
    pad_capacity(overall_reserved()) /* max_capacity */,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   155
    pad_capacity(eden_space_committed()) /* init_capacity */);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   156
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   157
  //  name "generation.0.space.1"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   158
  // See _old_space_counters for additional counters
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   159
  // Set the arguments to indicate that this survivor space is not used.
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   160
  _from_counters = new HSpaceCounters(young_collection_name_space,
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   161
    "s0", 1 /* ordinal */,
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   162
    pad_capacity(0) /* max_capacity */,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   163
    pad_capacity(0) /* init_capacity */);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   164
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   165
  //  name "generation.0.space.2"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   166
  // See _old_space_counters for additional counters
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   167
  _to_counters = new HSpaceCounters(young_collection_name_space,
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   168
    "s1", 2 /* ordinal */,
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   169
    pad_capacity(overall_reserved()) /* max_capacity */,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   170
    pad_capacity(survivor_space_committed()) /* init_capacity */);
12096
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   171
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   172
  if (UsePerfData) {
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   173
    // Given that this survivor space is not used, we update it here
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   174
    // once to reflect that its used space is 0 so that we don't have to
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   175
    // worry about updating it again later.
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   176
    _from_counters->update_used(0);
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
   177
  }
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   178
}
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   179
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   180
void G1MonitoringSupport::recalculate_sizes() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   181
  // Recalculate all the sizes from scratch. We assume that this is
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   182
  // called at a point where no concurrent updates to the various
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   183
  // values we read here are possible (i.e., at a STW phase at the end
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   184
  // of a GC).
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   185
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   186
  uint young_list_length = _g1h->young_regions_count();
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   187
  uint survivor_list_length = _g1h->survivor_regions_count();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   188
  assert(young_list_length >= survivor_list_length, "invariant");
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   189
  uint eden_list_length = young_list_length - survivor_list_length;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   190
  // Max length includes any potential extensions to the young gen
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   191
  // we'll do when the GC locker is active.
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   192
  uint young_list_max_length = _g1h->g1_policy()->young_list_max_length();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   193
  assert(young_list_max_length >= survivor_list_length, "invariant");
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   194
  uint eden_list_max_length = young_list_max_length - survivor_list_length;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   195
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   196
  _overall_used = _g1h->used_unlocked();
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   197
  _eden_used = (size_t) eden_list_length * HeapRegion::GrainBytes;
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   198
  _survivor_used = (size_t) survivor_list_length * HeapRegion::GrainBytes;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   199
  _young_region_num = young_list_length;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   200
  _old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   201
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   202
  // First calculate the committed sizes that can be calculated independently.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   203
  _survivor_committed = _survivor_used;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   204
  _old_committed = HeapRegion::align_up_to_region_byte_size(_old_used);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   205
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   206
  // Next, start with the overall committed size.
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   207
  _overall_committed = _g1h->capacity();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   208
  size_t committed = _overall_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   209
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   210
  // Remove the committed size we have calculated so far (for the
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   211
  // survivor and old space).
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   212
  assert(committed >= (_survivor_committed + _old_committed), "sanity");
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   213
  committed -= _survivor_committed + _old_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   214
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   215
  // Next, calculate and remove the committed size for the eden.
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   216
  _eden_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   217
  // Somewhat defensive: be robust in case there are inaccuracies in
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   218
  // the calculations
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   219
  _eden_committed = MIN2(_eden_committed, committed);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   220
  committed -= _eden_committed;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   221
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   222
  // Finally, give the rest to the old space...
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   223
  _old_committed += committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   224
  // ..and calculate the young gen committed.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   225
  _young_gen_committed = _eden_committed + _survivor_committed;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   226
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   227
  assert(_overall_committed ==
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   228
         (_eden_committed + _survivor_committed + _old_committed),
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   229
         "the committed sizes should add up");
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   230
  // Somewhat defensive: cap the eden used size to make sure it
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   231
  // never exceeds the committed size.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   232
  _eden_used = MIN2(_eden_used, _eden_committed);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   233
  // _survivor_committed and _old_committed are calculated in terms of
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   234
  // the corresponding _*_used value, so the next two conditions
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   235
  // should hold.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   236
  assert(_survivor_used <= _survivor_committed, "post-condition");
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   237
  assert(_old_used <= _old_committed, "post-condition");
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   238
}
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   239
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   240
void G1MonitoringSupport::recalculate_eden_size() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   241
  // When a new eden region is allocated, only the eden_used size is
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   242
  // affected (since we have recalculated everything else at the last GC).
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   243
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   244
  uint young_region_num = _g1h->young_regions_count();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   245
  if (young_region_num > _young_region_num) {
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   246
    uint diff = young_region_num - _young_region_num;
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12096
diff changeset
   247
    _eden_used += (size_t) diff * HeapRegion::GrainBytes;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   248
    // Somewhat defensive: cap the eden used size to make sure it
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   249
    // never exceeds the committed size.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   250
    _eden_used = MIN2(_eden_used, _eden_committed);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   251
    _young_region_num = young_region_num;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   252
  }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   253
}
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   254
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   255
void G1MonitoringSupport::update_sizes() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   256
  recalculate_sizes();
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   257
  if (UsePerfData) {
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   258
    eden_counters()->update_capacity(pad_capacity(eden_space_committed()));
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   259
    eden_counters()->update_used(eden_space_used());
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   260
    // only the to survivor space (s1) is active, so we don't need to
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   261
    // update the counters for the from survivor space (s0)
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   262
    to_counters()->update_capacity(pad_capacity(survivor_space_committed()));
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   263
    to_counters()->update_used(survivor_space_used());
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   264
    old_space_counters()->update_capacity(pad_capacity(old_space_committed()));
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   265
    old_space_counters()->update_used(old_space_used());
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   266
    old_collection_counters()->update_all();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   267
    young_collection_counters()->update_all();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12381
diff changeset
   268
    MetaspaceCounters::update_performance_counters();
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 13728
diff changeset
   269
    CompressedClassSpaceCounters::update_performance_counters();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   270
  }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   271
}
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   272
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   273
void G1MonitoringSupport::update_eden_size() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   274
  recalculate_eden_size();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   275
  if (UsePerfData) {
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   276
    eden_counters()->update_used(eden_space_used());
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   277
  }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   278
}