src/hotspot/share/gc/g1/g1MonitoringSupport.hpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49377 ecd91135d645
child 51497 ec014e5694ec
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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22551
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22551
diff changeset
    26
#define SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    27
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
    28
#include "gc/shared/generationCounters.hpp"
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    29
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
    30
class CollectorCounters;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    31
class G1CollectedHeap;
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
    32
class HSpaceCounters;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    33
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    34
// Class for monitoring logical spaces in G1. It provides data for
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    35
// both G1's jstat counters as well as G1's memory pools.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    36
//
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    37
// G1 splits the heap into heap regions and each heap region belongs
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    38
// to one of the following categories:
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
// * eden      : regions that have been allocated since the last GC
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    41
// * survivors : regions with objects that survived the last few GCs
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    42
// * old       : long-lived non-humongous regions
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    43
// * humongous : humongous regions
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    44
// * free      : free regions
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    45
//
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    46
// The combination of eden and survivor regions form the equivalent of
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    47
// the young generation in the other GCs. The combination of old and
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    48
// humongous regions form the equivalent of the old generation in the
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    49
// other GCs. Free regions do not have a good equivalent in the other
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    50
// GCs given that they can be allocated as any of the other region types.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    51
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    52
// The monitoring tools expect the heap to contain a number of
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    53
// generations (young, old, perm) and each generation to contain a
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    54
// number of spaces (young: eden, survivors, old). Given that G1 does
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    55
// not maintain those spaces physically (e.g., the set of
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    56
// non-contiguous eden regions can be considered as a "logical"
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    57
// space), we'll provide the illusion that those generations and
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    58
// spaces exist. In reality, each generation and space refers to a set
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    59
// of heap regions that are potentially non-contiguous.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    60
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    61
// This class provides interfaces to access the min, current, and max
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    62
// capacity and current occupancy for each of G1's logical spaces and
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    63
// generations we expose to the monitoring tools. Also provided are
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    64
// counters for G1 concurrent collections and stop-the-world full heap
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    65
// collections.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    66
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    67
// Below is a description of how the various sizes are calculated.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    68
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    69
// * Current Capacity
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    70
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    71
//    - heap_capacity = current heap capacity (e.g., current committed size)
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    72
//    - young_gen_capacity = current max young gen target capacity
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    73
//          (i.e., young gen target capacity + max allowed expansion capacity)
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    74
//    - survivor_capacity = current survivor region capacity
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    75
//    - eden_capacity = young_gen_capacity - survivor_capacity
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    76
//    - old_capacity = heap_capacity - young_gen_capacity
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    77
//
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    78
//    What we do in the above is to distribute the free regions among
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    79
//    eden_capacity and old_capacity.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    80
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    81
// * Occupancy
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    82
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    83
//    - young_gen_used = current young region capacity
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    84
//    - survivor_used = survivor_capacity
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    85
//    - eden_used = young_gen_used - survivor_used
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    86
//    - old_used = overall_used - young_gen_used
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    87
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    88
//    Unfortunately, we currently only keep track of the number of
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    89
//    currently allocated young and survivor regions + the overall used
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    90
//    bytes in the heap, so the above can be a little inaccurate.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    91
//
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    92
// * Min Capacity
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    93
//
11579
6c94c23b3199 7078465: G1: Don't use the undefined value (-1) for the G1 old memory pool max size
tonyp
parents: 11249
diff changeset
    94
//    We set this to 0 for all spaces.
10671
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
// * Max Capacity
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    97
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    98
//    For jstat, we set the max capacity of all spaces to heap_capacity,
11579
6c94c23b3199 7078465: G1: Don't use the undefined value (-1) for the G1 old memory pool max size
tonyp
parents: 11249
diff changeset
    99
//    given that we don't always have a reasonable upper bound on how big
6c94c23b3199 7078465: G1: Don't use the undefined value (-1) for the G1 old memory pool max size
tonyp
parents: 11249
diff changeset
   100
//    each space can grow. For the memory pools, we make the max
6c94c23b3199 7078465: G1: Don't use the undefined value (-1) for the G1 old memory pool max size
tonyp
parents: 11249
diff changeset
   101
//    capacity undefined with the exception of the old memory pool for
6c94c23b3199 7078465: G1: Don't use the undefined value (-1) for the G1 old memory pool max size
tonyp
parents: 11249
diff changeset
   102
//    which we make the max capacity same as the max heap capacity.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   103
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   104
// If we had more accurate occupancy / capacity information per
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   105
// region set the above calculations would be greatly simplified and
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   106
// be made more accurate.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   107
//
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   108
// We update all the above synchronously and we store the results in
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   109
// fields so that we just read said fields when needed. A subtle point
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   110
// is that all the above sizes need to be recalculated when the old
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   111
// gen changes capacity (after a GC or after a humongous allocation)
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   112
// but only the eden occupancy changes when a new eden region is
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 18025
diff changeset
   113
// allocated. So, in the latter case we have minimal recalculation to
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   114
// do which is important as we want to keep the eden region allocation
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   115
// path as low-overhead as possible.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   116
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12381
diff changeset
   117
class G1MonitoringSupport : public CHeapObj<mtGC> {
10675
8b887b2cb116 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 10671
diff changeset
   118
  friend class VMStructs;
8b887b2cb116 7097048: G1: extend the G1 SA changes to print per-heap space information
tonyp
parents: 10671
diff changeset
   119
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   120
  G1CollectedHeap* _g1h;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   121
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   122
  // jstat performance counters
11249
b0c1cc35cafe 7113012: G1: rename not-fully-young GCs as "mixed"
tonyp
parents: 10675
diff changeset
   123
  //  incremental collections both young and mixed
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   124
  CollectorCounters*   _incremental_collection_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   125
  //  full stop-the-world collections
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   126
  CollectorCounters*   _full_collection_counters;
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   127
  //  stop-the-world phases in G1
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   128
  CollectorCounters*   _conc_collection_counters;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   129
  //  young collection set counters.  The _eden_counters,
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   130
  // _from_counters, and _to_counters are associated with
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   131
  // this "generational" counter.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   132
  GenerationCounters*  _young_collection_counters;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   133
  //  old collection set counters. The _old_space_counters
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   134
  // below are associated with this "generational" counter.
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   135
  GenerationCounters*  _old_collection_counters;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   136
  // Counters for the capacity and used for
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   137
  //   the whole heap
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   138
  HSpaceCounters*      _old_space_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   139
  //   the young collection
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   140
  HSpaceCounters*      _eden_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   141
  //   the survivor collection (only one, _to_counters, is actively used)
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   142
  HSpaceCounters*      _from_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   143
  HSpaceCounters*      _to_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   144
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   145
  // When it's appropriate to recalculate the various sizes (at the
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   146
  // end of a GC, when a new eden region is allocated, etc.) we store
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   147
  // them here so that we can easily report them when needed and not
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   148
  // have to recalculate them every time.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   149
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   150
  size_t _overall_reserved;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   151
  size_t _overall_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   152
  size_t _overall_used;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   153
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 11579
diff changeset
   154
  uint   _young_region_num;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   155
  size_t _young_gen_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   156
  size_t _eden_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   157
  size_t _eden_used;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   158
  size_t _survivor_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   159
  size_t _survivor_used;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   160
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   161
  size_t _old_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   162
  size_t _old_used;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   163
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   164
  // It returns x - y if x > y, 0 otherwise.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   165
  // As described in the comment above, some of the inputs to the
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   166
  // calculations we have to do are obtained concurrently and hence
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   167
  // may be inconsistent with each other. So, this provides a
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   168
  // defensive way of performing the subtraction and avoids the value
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   169
  // going negative (which would mean a very large result, given that
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   170
  // the parameter are size_t).
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   171
  static size_t subtract_up_to_zero(size_t x, size_t y) {
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   172
    if (x > y) {
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   173
      return x - y;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   174
    } else {
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   175
      return 0;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   176
    }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   177
  }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   178
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   179
  // Recalculate all the sizes.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   180
  void recalculate_sizes();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   181
  // Recalculate only what's necessary when a new eden region is allocated.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   182
  void recalculate_eden_size();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   183
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   184
 public:
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   185
  G1MonitoringSupport(G1CollectedHeap* g1h);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   186
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   187
  // Unfortunately, the jstat tool assumes that no space has 0
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   188
  // capacity. In our case, given that each space is logical, it's
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   189
  // possible that no regions will be allocated to it, hence to have 0
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   190
  // capacity (e.g., if there are no survivor regions, the survivor
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   191
  // space has 0 capacity). The way we deal with this is to always pad
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   192
  // each capacity value we report to jstat by a very small amount to
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   193
  // make sure that it's never zero. Given that we sometimes have to
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   194
  // report a capacity of a generation that contains several spaces
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   195
  // (e.g., young gen includes one eden, two survivor spaces), the
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   196
  // mult parameter is provided in order to adding the appropriate
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   197
  // padding multiple times so that the capacities add up correctly.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   198
  static size_t pad_capacity(size_t size_bytes, size_t mult = 1) {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   199
    return size_bytes + MinObjAlignmentInBytes * mult;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   200
  }
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   201
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   202
  // Recalculate all the sizes from scratch and update all the jstat
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   203
  // counters accordingly.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   204
  void update_sizes();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   205
  // Recalculate only what's necessary when a new eden region is
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   206
  // allocated and update any jstat counters that need to be updated.
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   207
  void update_eden_size();
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   208
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   209
  CollectorCounters* incremental_collection_counters() {
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   210
    return _incremental_collection_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   211
  }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   212
  CollectorCounters* full_collection_counters() {
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   213
    return _full_collection_counters;
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   214
  }
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   215
  CollectorCounters* conc_collection_counters() {
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   216
    return _conc_collection_counters;
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   217
  }
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   218
  GenerationCounters* young_collection_counters() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   219
    return _young_collection_counters;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   220
  }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   221
  GenerationCounters* old_collection_counters() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   222
    return _old_collection_counters;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   223
  }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   224
  HSpaceCounters*      old_space_counters() { return _old_space_counters; }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   225
  HSpaceCounters*      eden_counters() { return _eden_counters; }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   226
  HSpaceCounters*      from_counters() { return _from_counters; }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   227
  HSpaceCounters*      to_counters() { return _to_counters; }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   228
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   229
  // Monitoring support used by
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   230
  //   MemoryService
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   231
  //   jstat counters
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 13195
diff changeset
   232
  //   Tracing
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   233
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   234
  size_t overall_reserved()           { return _overall_reserved;     }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   235
  size_t overall_committed()          { return _overall_committed;    }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   236
  size_t overall_used()               { return _overall_used;         }
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   237
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   238
  size_t young_gen_committed()        { return _young_gen_committed;  }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   239
  size_t young_gen_max()              { return overall_reserved();    }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   240
  size_t eden_space_committed()       { return _eden_committed;       }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   241
  size_t eden_space_used()            { return _eden_used;            }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   242
  size_t survivor_space_committed()   { return _survivor_committed;   }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   243
  size_t survivor_space_used()        { return _survivor_used;        }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   244
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   245
  size_t old_gen_committed()          { return old_space_committed(); }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   246
  size_t old_gen_max()                { return overall_reserved();    }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   247
  size_t old_space_committed()        { return _old_committed;        }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   248
  size_t old_space_used()             { return _old_used;             }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   249
};
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   250
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   251
class G1GenerationCounters: public GenerationCounters {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   252
protected:
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   253
  G1MonitoringSupport* _g1mm;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   254
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   255
public:
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   256
  G1GenerationCounters(G1MonitoringSupport* g1mm,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   257
                       const char* name, int ordinal, int spaces,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   258
                       size_t min_capacity, size_t max_capacity,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   259
                       size_t curr_capacity);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   260
};
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   261
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   262
class G1YoungGenerationCounters: public G1GenerationCounters {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   263
public:
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   264
  G1YoungGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   265
  virtual void update_all();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   266
};
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   267
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   268
class G1OldGenerationCounters: public G1GenerationCounters {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   269
public:
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   270
  G1OldGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   271
  virtual void update_all();
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   272
};
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   273
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 22551
diff changeset
   274
#endif // SHARE_VM_GC_G1_G1MONITORINGSUPPORT_HPP