annotate src/hotspot/share/gc/z/zServiceability.cpp @ 54215:5ef581e59d91

8214236: sun.gc.collector.2.name should be changed Reviewed-by: pliden, tschatzl
author cito
date Tue, 12 Feb 2019 08:56:03 +0900
parents 7504e7937183
children
rev   line source
duke@50058 1 /*
cito@54215 2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
duke@50058 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@50058 4 *
duke@50058 5 * This code is free software; you can redistribute it and/or modify it
duke@50058 6 * under the terms of the GNU General Public License version 2 only, as
duke@50058 7 * published by the Free Software Foundation.
duke@50058 8 *
duke@50058 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@50058 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@50058 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@50058 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@50058 13 * accompanied this code).
duke@50058 14 *
duke@50058 15 * You should have received a copy of the GNU General Public License version
duke@50058 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@50058 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@50058 18 *
duke@50058 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
duke@50058 20 * or visit www.oracle.com if you need additional information or have any
duke@50058 21 * questions.
duke@50058 22 */
duke@50058 23
duke@50058 24 #include "precompiled.hpp"
duke@50058 25 #include "gc/shared/generationCounters.hpp"
duke@50058 26 #include "gc/shared/hSpaceCounters.hpp"
duke@50058 27 #include "gc/z/zCollectedHeap.hpp"
duke@50058 28 #include "gc/z/zHeap.inline.hpp"
duke@50058 29 #include "gc/z/zServiceability.hpp"
duke@50058 30 #include "memory/metaspaceCounters.hpp"
duke@50058 31 #include "runtime/perfData.hpp"
duke@50058 32
pliden@51764 33 class ZGenerationCounters : public GenerationCounters {
duke@50058 34 public:
pliden@51764 35 ZGenerationCounters(const char* name, int ordinal, int spaces,
pliden@51764 36 size_t min_capacity, size_t max_capacity, size_t curr_capacity) :
pliden@51764 37 GenerationCounters(name, ordinal, spaces,
pliden@51764 38 min_capacity, max_capacity, curr_capacity) {}
duke@50058 39
pliden@51764 40 void update_capacity(size_t capacity) {
pliden@51764 41 _current_size->set_value(capacity);
duke@50058 42 }
duke@50058 43 };
duke@50058 44
duke@50058 45 // Class to expose perf counters used by jstat.
duke@50058 46 class ZServiceabilityCounters : public CHeapObj<mtGC> {
duke@50058 47 private:
pliden@51764 48 ZGenerationCounters _generation_counters;
pliden@51764 49 HSpaceCounters _space_counters;
pliden@51764 50 CollectorCounters _collector_counters;
duke@50058 51
duke@50058 52 public:
duke@50058 53 ZServiceabilityCounters(size_t min_capacity, size_t max_capacity);
duke@50058 54
pliden@51763 55 CollectorCounters* collector_counters();
pliden@51763 56
duke@50058 57 void update_sizes();
duke@50058 58 };
duke@50058 59
duke@50058 60 ZServiceabilityCounters::ZServiceabilityCounters(size_t min_capacity, size_t max_capacity) :
duke@50058 61 // generation.1
pliden@51764 62 _generation_counters("old" /* name */,
pliden@51764 63 1 /* ordinal */,
pliden@51764 64 1 /* spaces */,
pliden@51764 65 min_capacity /* min_capacity */,
pliden@51764 66 max_capacity /* max_capacity */,
pliden@51764 67 min_capacity /* curr_capacity */),
duke@50058 68 // generation.1.space.0
pliden@51764 69 _space_counters(_generation_counters.name_space(),
pliden@51764 70 "space" /* name */,
pliden@51764 71 0 /* ordinal */,
pliden@51764 72 max_capacity /* max_capacity */,
pliden@51764 73 min_capacity /* init_capacity */),
pliden@51763 74 // gc.collector.2
cito@54215 75 _collector_counters("Z concurrent cycle pauses" /* name */,
cito@54215 76 2 /* ordinal */) {}
pliden@51763 77
pliden@51763 78 CollectorCounters* ZServiceabilityCounters::collector_counters() {
pliden@51763 79 return &_collector_counters;
pliden@51763 80 }
duke@50058 81
duke@50058 82 void ZServiceabilityCounters::update_sizes() {
duke@50058 83 if (UsePerfData) {
pliden@51764 84 const size_t capacity = ZHeap::heap()->capacity();
pliden@51764 85 const size_t used = MIN2(ZHeap::heap()->used(), capacity);
duke@50058 86
pliden@51764 87 _generation_counters.update_capacity(capacity);
pliden@51764 88 _space_counters.update_capacity(capacity);
pliden@51764 89 _space_counters.update_used(used);
duke@50058 90
duke@50058 91 MetaspaceCounters::update_performance_counters();
duke@50058 92 CompressedClassSpaceCounters::update_performance_counters();
duke@50058 93 }
duke@50058 94 }
duke@50058 95
duke@50058 96 ZServiceabilityMemoryPool::ZServiceabilityMemoryPool(size_t min_capacity, size_t max_capacity) :
duke@50058 97 CollectedMemoryPool("ZHeap",
duke@50058 98 min_capacity,
duke@50058 99 max_capacity,
duke@50058 100 true /* support_usage_threshold */) {}
duke@50058 101
duke@50058 102 size_t ZServiceabilityMemoryPool::used_in_bytes() {
duke@50058 103 return ZHeap::heap()->used();
duke@50058 104 }
duke@50058 105
duke@50058 106 MemoryUsage ZServiceabilityMemoryPool::get_memory_usage() {
duke@50058 107 const size_t committed = ZHeap::heap()->capacity();
duke@50058 108 const size_t used = MIN2(ZHeap::heap()->used(), committed);
duke@50058 109
duke@50058 110 return MemoryUsage(initial_size(), used, committed, max_size());
duke@50058 111 }
duke@50058 112
duke@50058 113 ZServiceabilityMemoryManager::ZServiceabilityMemoryManager(ZServiceabilityMemoryPool* pool)
duke@50058 114 : GCMemoryManager("ZGC", "end of major GC") {
duke@50058 115 add_pool(pool);
duke@50058 116 }
duke@50058 117
duke@50058 118 ZServiceability::ZServiceability(size_t min_capacity, size_t max_capacity) :
duke@50058 119 _min_capacity(min_capacity),
duke@50058 120 _max_capacity(max_capacity),
duke@50058 121 _memory_pool(_min_capacity, _max_capacity),
duke@50058 122 _memory_manager(&_memory_pool),
duke@50058 123 _counters(NULL) {}
duke@50058 124
duke@50058 125 void ZServiceability::initialize() {
duke@50058 126 _counters = new ZServiceabilityCounters(_min_capacity, _max_capacity);
duke@50058 127 }
duke@50058 128
duke@50058 129 MemoryPool* ZServiceability::memory_pool() {
duke@50058 130 return &_memory_pool;
duke@50058 131 }
duke@50058 132
duke@50058 133 GCMemoryManager* ZServiceability::memory_manager() {
duke@50058 134 return &_memory_manager;
duke@50058 135 }
duke@50058 136
duke@50058 137 ZServiceabilityCounters* ZServiceability::counters() {
duke@50058 138 return _counters;
duke@50058 139 }
duke@50058 140
duke@50058 141 ZServiceabilityMemoryUsageTracker::~ZServiceabilityMemoryUsageTracker() {
duke@50058 142 MemoryService::track_memory_usage();
duke@50058 143 }
duke@50058 144
duke@50058 145 ZServiceabilityManagerStatsTracer::ZServiceabilityManagerStatsTracer(bool is_gc_begin, bool is_gc_end) :
duke@50058 146 _stats(ZHeap::heap()->serviceability_memory_manager(),
duke@50058 147 ZCollectedHeap::heap()->gc_cause() /* cause */,
pliden@51083 148 true /* allMemoryPoolsAffected */,
duke@50058 149 is_gc_begin /* recordGCBeginTime */,
duke@50058 150 is_gc_begin /* recordPreGCUsage */,
duke@50058 151 true /* recordPeakUsage */,
duke@50058 152 is_gc_end /* recordPostGCusage */,
duke@50058 153 true /* recordAccumulatedGCTime */,
duke@50058 154 is_gc_end /* recordGCEndTime */,
duke@50058 155 is_gc_end /* countCollection */) {}
duke@50058 156
pliden@51763 157 ZServiceabilityCountersTracer::ZServiceabilityCountersTracer() :
pliden@51763 158 _stats(ZHeap::heap()->serviceability_counters()->collector_counters()) {}
duke@50058 159
duke@50058 160 ZServiceabilityCountersTracer::~ZServiceabilityCountersTracer() {
duke@50058 161 ZHeap::heap()->serviceability_counters()->update_sizes();
duke@50058 162 }