src/hotspot/share/gc/g1/g1MonitoringSupport.cpp
author mgronlun
Wed, 30 Oct 2019 19:43:52 +0100
changeset 58863 c16ac7a2eba4
parent 54623 1126f0607c70
permissions -rw-r--r--
8226511: Implement JFR Event Streaming Reviewed-by: egahlin, mseledtsov, mgronlun Contributed-by: erik.gahlin@oracle.com, mikhailo.seledtsov@oracle.com, markus.gronlund@oracle.com
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
/*
53726
5ef581e59d91 8214236: sun.gc.collector.2.name should be changed
cito
parents: 51625
diff changeset
     2
 * Copyright (c) 2011, 2019, 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"
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
    29
#include "gc/g1/g1MemoryPool.hpp"
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
    30
#include "gc/shared/hSpaceCounters.hpp"
49824
e242740a92b8 8201556: Disallow reading oops in ClassLoaderData if unloading
coleenp
parents: 49806
diff changeset
    31
#include "memory/metaspaceCounters.hpp"
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
    32
#include "services/memoryPool.hpp"
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    33
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    34
class G1GenerationCounters : public GenerationCounters {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    35
protected:
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    36
  G1MonitoringSupport* _g1mm;
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    37
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    38
public:
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    39
  G1GenerationCounters(G1MonitoringSupport* g1mm,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    40
                       const char* name, int ordinal, int spaces,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    41
                       size_t min_capacity, size_t max_capacity,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    42
                       size_t curr_capacity)
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    43
  : GenerationCounters(name, ordinal, spaces, min_capacity,
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    44
                       max_capacity, curr_capacity), _g1mm(g1mm) { }
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    45
};
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    46
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    47
class G1YoungGenerationCounters : public G1GenerationCounters {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    48
public:
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    49
  // We pad the capacity three times given that the young generation
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    50
  // contains three spaces (eden and two survivors).
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    51
  G1YoungGenerationCounters(G1MonitoringSupport* g1mm, const char* name, size_t max_size)
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    52
  : G1GenerationCounters(g1mm, name, 0 /* ordinal */, 3 /* spaces */,
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    53
                         G1MonitoringSupport::pad_capacity(0, 3) /* min_capacity */,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    54
                         G1MonitoringSupport::pad_capacity(max_size, 3),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    55
                         G1MonitoringSupport::pad_capacity(0, 3) /* curr_capacity */) {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    56
    if (UsePerfData) {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    57
      update_all();
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    58
    }
12096
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    59
  }
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    60
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    61
  virtual void update_all() {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    62
    size_t committed =
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    63
              G1MonitoringSupport::pad_capacity(_g1mm->young_gen_committed(), 3);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    64
    _current_size->set_value(committed);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    65
  }
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    66
};
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    67
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    68
class G1OldGenerationCounters : public G1GenerationCounters {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    69
public:
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    70
  G1OldGenerationCounters(G1MonitoringSupport* g1mm, const char* name, size_t max_size)
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    71
  : G1GenerationCounters(g1mm, name, 1 /* ordinal */, 1 /* spaces */,
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    72
                         G1MonitoringSupport::pad_capacity(0) /* min_capacity */,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    73
                         G1MonitoringSupport::pad_capacity(max_size),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    74
                         G1MonitoringSupport::pad_capacity(0) /* curr_capacity */) {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    75
    if (UsePerfData) {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    76
      update_all();
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    77
    }
12096
c9ee3caeda27 7147806: G1: Crash in vm bootstrap when running with -XX:+UseG1GC -XX:-UsePerfData
johnc
parents: 10671
diff changeset
    78
  }
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    79
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    80
  virtual void update_all() {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    81
    size_t committed =
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    82
              G1MonitoringSupport::pad_capacity(_g1mm->old_gen_committed());
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    83
    _current_size->set_value(committed);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    84
  }
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    85
};
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    86
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
    87
G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    88
  _g1h(g1h),
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    89
  _incremental_memory_manager("G1 Young Generation", "end of minor GC"),
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
    90
  _full_gc_memory_manager("G1 Old Generation", "end of major GC"),
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    91
  _eden_space_pool(NULL),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    92
  _survivor_space_pool(NULL),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    93
  _old_gen_pool(NULL),
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    94
  _incremental_collection_counters(NULL),
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    95
  _full_collection_counters(NULL),
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
    96
  _conc_collection_counters(NULL),
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    97
  _young_gen_counters(NULL),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
    98
  _old_gen_counters(NULL),
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
    99
  _old_space_counters(NULL),
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   100
  _eden_space_counters(NULL),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   101
  _from_space_counters(NULL),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   102
  _to_space_counters(NULL),
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   103
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49982
diff changeset
   104
  _overall_committed(0),
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49982
diff changeset
   105
  _overall_used(0),
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   106
  _young_gen_committed(0),
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   107
  _old_gen_committed(0),
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   108
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   109
  _eden_space_committed(0),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   110
  _eden_space_used(0),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   111
  _survivor_space_committed(0),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   112
  _survivor_space_used(0),
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   113
  _old_gen_used(0) {
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   114
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   115
  recalculate_sizes();
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   116
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   117
  // Counters for garbage collections
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   118
  //
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   119
  //  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
   120
  // young generation collection.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   121
  _incremental_collection_counters =
53726
5ef581e59d91 8214236: sun.gc.collector.2.name should be changed
cito
parents: 51625
diff changeset
   122
    new CollectorCounters("G1 young collection pauses", 0);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   123
  //   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
   124
  // old generation collection.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   125
  _full_collection_counters =
53726
5ef581e59d91 8214236: sun.gc.collector.2.name should be changed
cito
parents: 51625
diff changeset
   126
    new CollectorCounters("G1 full collection pauses", 1);
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   127
  //   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
   128
  // STW phases in concurrent collection.
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 48116
diff changeset
   129
  _conc_collection_counters =
53726
5ef581e59d91 8214236: sun.gc.collector.2.name should be changed
cito
parents: 51625
diff changeset
   130
    new CollectorCounters("G1 concurrent cycle pauses", 2);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   131
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   132
  // "Generation" and "Space" counters.
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" This is logically the old generation in
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   135
  // generational GC terms.  The "1, 1" parameters are for
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   136
  // the n-th generation (=1) with 1 space.
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   137
  // Counters are created from minCapacity, maxCapacity, and capacity
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   138
  _old_gen_counters = new G1OldGenerationCounters(this, "old", _g1h->max_capacity());
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   139
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   140
  //  name  "generation.1.space.0"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   141
  // Counters are created from maxCapacity, capacity, initCapacity,
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   142
  // and used.
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   143
  _old_space_counters = new HSpaceCounters(_old_gen_counters->name_space(),
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   144
    "space", 0 /* ordinal */,
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   145
    pad_capacity(g1h->max_capacity()) /* max_capacity */,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   146
    pad_capacity(_old_gen_committed) /* init_capacity */);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   147
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   148
  //   Young collection set
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   149
  //  name "generation.0".  This is logically the young generation.
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   150
  //  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
   151
  // See  _old_collection_counters for additional counters
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   152
  _young_gen_counters = new G1YoungGenerationCounters(this, "young", _g1h->max_capacity());
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   153
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   154
  const char* young_collection_name_space = _young_gen_counters->name_space();
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   155
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   156
  //  name "generation.0.space.0"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   157
  // See _old_space_counters for additional counters
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   158
  _eden_space_counters = new HSpaceCounters(young_collection_name_space,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   159
    "eden", 0 /* ordinal */,
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   160
    pad_capacity(g1h->max_capacity()) /* max_capacity */,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   161
    pad_capacity(_eden_space_committed) /* init_capacity */);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   162
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   163
  //  name "generation.0.space.1"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   164
  // See _old_space_counters for additional counters
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   165
  // Set the arguments to indicate that this survivor space is not used.
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   166
  _from_space_counters = new HSpaceCounters(young_collection_name_space,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   167
    "s0", 1 /* ordinal */,
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   168
    pad_capacity(0) /* max_capacity */,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   169
    pad_capacity(0) /* init_capacity */);
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   170
  // Given that this survivor space is not used, we update it here
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   171
  // once to reflect that its used space is 0 so that we don't have to
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   172
  // worry about updating it again later.
51624
7ed777a14094 8210265: Crash in HSpaceCounters::update_used()
tschatzl
parents: 51498
diff changeset
   173
  if (UsePerfData) {
7ed777a14094 8210265: Crash in HSpaceCounters::update_used()
tschatzl
parents: 51498
diff changeset
   174
    _from_space_counters->update_used(0);
7ed777a14094 8210265: Crash in HSpaceCounters::update_used()
tschatzl
parents: 51498
diff changeset
   175
  }
9338
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
  //  name "generation.0.space.2"
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   178
  // See _old_space_counters for additional counters
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   179
  _to_space_counters = new HSpaceCounters(young_collection_name_space,
48116
8a5e8cd321d9 8191861: Move and refactor hSpaceCounters
stefank
parents: 47216
diff changeset
   180
    "s1", 2 /* ordinal */,
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   181
    pad_capacity(g1h->max_capacity()) /* max_capacity */,
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   182
    pad_capacity(_survivor_space_committed) /* init_capacity */);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   183
}
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   184
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   185
G1MonitoringSupport::~G1MonitoringSupport() {
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   186
  delete _eden_space_pool;
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   187
  delete _survivor_space_pool;
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   188
  delete _old_gen_pool;
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   189
}
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   190
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   191
void G1MonitoringSupport::initialize_serviceability() {
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   192
  _eden_space_pool = new G1EdenPool(_g1h, _eden_space_committed);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   193
  _survivor_space_pool = new G1SurvivorPool(_g1h, _survivor_space_committed);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   194
  _old_gen_pool = new G1OldGenPool(_g1h, _old_gen_committed, _g1h->max_capacity());
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   195
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   196
  _full_gc_memory_manager.add_pool(_eden_space_pool);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   197
  _full_gc_memory_manager.add_pool(_survivor_space_pool);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   198
  _full_gc_memory_manager.add_pool(_old_gen_pool);
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   199
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   200
  _incremental_memory_manager.add_pool(_eden_space_pool);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   201
  _incremental_memory_manager.add_pool(_survivor_space_pool);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   202
  _incremental_memory_manager.add_pool(_old_gen_pool, false /* always_affected_by_gc */);
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   203
}
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   204
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   205
MemoryUsage G1MonitoringSupport::memory_usage() {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54467
diff changeset
   206
  MutexLocker x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   207
  return MemoryUsage(InitialHeapSize, _overall_used, _overall_committed, _g1h->max_capacity());
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   208
}
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   209
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   210
GrowableArray<GCMemoryManager*> G1MonitoringSupport::memory_managers() {
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   211
  GrowableArray<GCMemoryManager*> memory_managers(2);
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   212
  memory_managers.append(&_incremental_memory_manager);
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   213
  memory_managers.append(&_full_gc_memory_manager);
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   214
  return memory_managers;
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   215
}
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   216
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   217
GrowableArray<MemoryPool*> G1MonitoringSupport::memory_pools() {
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   218
  GrowableArray<MemoryPool*> memory_pools(3);
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   219
  memory_pools.append(_eden_space_pool);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   220
  memory_pools.append(_survivor_space_pool);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   221
  memory_pools.append(_old_gen_pool);
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   222
  return memory_pools;
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   223
}
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   224
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   225
void G1MonitoringSupport::recalculate_sizes() {
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   226
  assert_heap_locked_or_at_safepoint(true);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   227
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54467
diff changeset
   228
  MutexLocker x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   229
  // Recalculate all the sizes from scratch.
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   230
54467
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   231
  // This never includes used bytes of current allocating heap region.
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   232
  _overall_used = _g1h->used_unlocked();
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   233
  _eden_space_used = _g1h->eden_regions_used_bytes();
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   234
  _survivor_space_used = _g1h->survivor_regions_used_bytes();
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   235
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   236
  // _overall_used and _eden_space_used are obtained concurrently so
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   237
  // may be inconsistent with each other. To prevent _old_gen_used going negative,
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   238
  // use smaller value to substract.
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   239
  _old_gen_used = _overall_used - MIN2(_overall_used, _eden_space_used + _survivor_space_used);
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   240
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   241
  uint survivor_list_length = _g1h->survivor_regions_count();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   242
  // Max length includes any potential extensions to the young gen
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   243
  // we'll do when the GC locker is active.
53985
0da5c17f5e43 8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents: 53726
diff changeset
   244
  uint young_list_max_length = _g1h->policy()->young_list_max_length();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   245
  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
   246
  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
   247
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   248
  // First calculate the committed sizes that can be calculated independently.
54467
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   249
  _survivor_space_committed = survivor_list_length * HeapRegion::GrainBytes;
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   250
  _old_gen_committed = HeapRegion::align_up_to_region_byte_size(_old_gen_used);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   251
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   252
  // Next, start with the overall committed size.
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49377
diff changeset
   253
  _overall_committed = _g1h->capacity();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   254
  size_t committed = _overall_committed;
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   255
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   256
  // 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
   257
  // survivor and old space).
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   258
  assert(committed >= (_survivor_space_committed + _old_gen_committed), "sanity");
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   259
  committed -= _survivor_space_committed + _old_gen_committed;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   260
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   261
  // Next, calculate and remove the committed size for the eden.
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   262
  _eden_space_committed = (size_t) eden_list_max_length * HeapRegion::GrainBytes;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   263
  // Somewhat defensive: be robust in case there are inaccuracies in
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   264
  // the calculations
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   265
  _eden_space_committed = MIN2(_eden_space_committed, committed);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   266
  committed -= _eden_space_committed;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   267
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   268
  // Finally, give the rest to the old space...
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   269
  _old_gen_committed += committed;
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   270
  // ..and calculate the young gen committed.
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   271
  _young_gen_committed = _eden_space_committed + _survivor_space_committed;
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   272
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   273
  assert(_overall_committed ==
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   274
         (_eden_space_committed + _survivor_space_committed + _old_gen_committed),
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   275
         "the committed sizes should add up");
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   276
  // 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
   277
  // never exceeds the committed size.
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   278
  _eden_space_used = MIN2(_eden_space_used, _eden_space_committed);
54467
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   279
  // _survivor_space_used is calculated during a safepoint and _survivor_space_committed
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   280
  // is calculated from survivor region count * heap region size.
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   281
  assert(_survivor_space_used <= _survivor_space_committed, "Survivor used bytes(" SIZE_FORMAT
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   282
         ") should be less than or equal to survivor committed(" SIZE_FORMAT ")",
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   283
         _survivor_space_used, _survivor_space_committed);
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   284
  // _old_gen_committed is calculated in terms of _old_gen_used value.
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   285
  assert(_old_gen_used <= _old_gen_committed, "Old gen used bytes(" SIZE_FORMAT
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   286
         ") should be less than or equal to old gen committed(" SIZE_FORMAT ")",
0c5d713cf43f 8218049: Survivor MemoryMXBean used() size granularity is region based
sangheki
parents: 53985
diff changeset
   287
         _old_gen_used, _old_gen_committed);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   288
}
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   289
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   290
void G1MonitoringSupport::update_sizes() {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   291
  recalculate_sizes();
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   292
  if (UsePerfData) {
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   293
    _eden_space_counters->update_capacity(pad_capacity(_eden_space_committed));
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   294
    _eden_space_counters->update_used(_eden_space_used);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   295
   // only the "to" survivor space is active, so we don't need to
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   296
    // update the counters for the "from" survivor space
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   297
    _to_space_counters->update_capacity(pad_capacity(_survivor_space_committed));
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   298
    _to_space_counters->update_used(_survivor_space_used);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   299
    _old_space_counters->update_capacity(pad_capacity(_old_gen_committed));
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   300
    _old_space_counters->update_used(_old_gen_used);
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   301
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   302
    _young_gen_counters->update_all();
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   303
    _old_gen_counters->update_all();
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   304
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12381
diff changeset
   305
    MetaspaceCounters::update_performance_counters();
19322
e35f9ed4f081 8014659: NPG: performance counters for compressed klass space
ehelin
parents: 13728
diff changeset
   306
    CompressedClassSpaceCounters::update_performance_counters();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   307
  }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   308
}
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   309
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   310
void G1MonitoringSupport::update_eden_size() {
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   311
  // Recalculate everything - this should be fast enough and we are sure that we do not
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   312
  // miss anything.
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   313
  recalculate_sizes();
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 9338
diff changeset
   314
  if (UsePerfData) {
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   315
    _eden_space_counters->update_used(_eden_space_used);
9338
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   316
  }
05ee447bd420 6946417: G1: Java VisualVM does not support G1 properly.
jmasa
parents:
diff changeset
   317
}
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   318
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   319
MemoryUsage G1MonitoringSupport::eden_space_memory_usage(size_t initial_size, size_t max_size) {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54467
diff changeset
   320
  MutexLocker x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   321
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   322
  return MemoryUsage(initial_size,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   323
                     _eden_space_used,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   324
                     _eden_space_committed,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   325
                     max_size);
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   326
}
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   327
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   328
MemoryUsage G1MonitoringSupport::survivor_space_memory_usage(size_t initial_size, size_t max_size) {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54467
diff changeset
   329
  MutexLocker x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   330
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   331
  return MemoryUsage(initial_size,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   332
                     _survivor_space_used,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   333
                     _survivor_space_committed,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   334
                     max_size);
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   335
}
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   336
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   337
MemoryUsage G1MonitoringSupport::old_gen_memory_usage(size_t initial_size, size_t max_size) {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54467
diff changeset
   338
  MutexLocker x(MonitoringSupport_lock, Mutex::_no_safepoint_check_flag);
51625
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   339
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   340
  return MemoryUsage(initial_size,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   341
                     _old_gen_used,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   342
                     _old_gen_committed,
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   343
                     max_size);
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   344
}
c265860d5d45 8207200: Committed > max memory usage when getting MemoryUsage
tschatzl
parents: 51624
diff changeset
   345
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   346
G1MonitoringScope::G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected) :
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   347
  _tcs(full_gc ? g1mm->_full_collection_counters : g1mm->_incremental_collection_counters),
51498
9a5200b84046 8209062: Clean up G1MonitoringSupport
tschatzl
parents: 51497
diff changeset
   348
  _tms(full_gc ? &g1mm->_full_gc_memory_manager : &g1mm->_incremental_memory_manager,
51497
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   349
       G1CollectedHeap::heap()->gc_cause(), all_memory_pools_affected) {
ec014e5694ec 8209061: Move G1 serviceability functionality to G1MonitoringSupport
tschatzl
parents: 51332
diff changeset
   350
}