src/share/vm/gc_implementation/shared/gcTrace.cpp

Wed, 26 Mar 2014 14:15:02 +0100

author
ehelin
date
Wed, 26 Mar 2014 14:15:02 +0100
changeset 6608
fa21c9537e6e
parent 6420
9fdaa79b0c27
child 6876
710a3c8b516e
child 6904
0982ec23da03
permissions
-rw-r--r--

8035667: EventMetaspaceSummary doesn't report committed Metaspace memory
Reviewed-by: jmasa, stefank

sla@5237 1 /*
sla@5237 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
sla@5237 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sla@5237 4 *
sla@5237 5 * This code is free software; you can redistribute it and/or modify it
sla@5237 6 * under the terms of the GNU General Public License version 2 only, as
sla@5237 7 * published by the Free Software Foundation.
sla@5237 8 *
sla@5237 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sla@5237 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sla@5237 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sla@5237 12 * version 2 for more details (a copy is included in the LICENSE file that
sla@5237 13 * accompanied this code).
sla@5237 14 *
sla@5237 15 * You should have received a copy of the GNU General Public License version
sla@5237 16 * 2 along with this work; if not, write to the Free Software Foundation,
sla@5237 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sla@5237 18 *
sla@5237 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sla@5237 20 * or visit www.oracle.com if you need additional information or have any
sla@5237 21 * questions.
sla@5237 22 *
sla@5237 23 */
sla@5237 24
sla@5237 25 #include "precompiled.hpp"
ehelin@5386 26 #include "gc_implementation/shared/copyFailedInfo.hpp"
sla@5237 27 #include "gc_implementation/shared/gcHeapSummary.hpp"
sla@5237 28 #include "gc_implementation/shared/gcTimer.hpp"
sla@5237 29 #include "gc_implementation/shared/gcTrace.hpp"
ehelin@5386 30 #include "gc_implementation/shared/objectCountEventSender.hpp"
sla@5237 31 #include "memory/heapInspection.hpp"
sla@5237 32 #include "memory/referenceProcessorStats.hpp"
ehelin@5388 33 #include "runtime/os.hpp"
sla@5237 34 #include "utilities/globalDefinitions.hpp"
mgronlun@6131 35 #include "utilities/ticks.inline.hpp"
sla@5237 36
sla@5237 37 #if INCLUDE_ALL_GCS
sla@5237 38 #include "gc_implementation/g1/evacuationInfo.hpp"
sla@5237 39 #endif
sla@5237 40
sla@5237 41 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
sla@5237 42 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
sla@5237 43
ehelin@5387 44 static GCId GCTracer_next_gc_id = 0;
sla@5237 45 static GCId create_new_gc_id() {
sla@5237 46 return GCTracer_next_gc_id++;
sla@5237 47 }
sla@5237 48
mgronlun@6131 49 void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) {
sla@5237 50 assert_unset_gc_id();
sla@5237 51
sla@5237 52 GCId gc_id = create_new_gc_id();
sla@5237 53 _shared_gc_info.set_id(gc_id);
sla@5237 54 _shared_gc_info.set_cause(cause);
sla@5237 55 _shared_gc_info.set_start_timestamp(timestamp);
sla@5237 56 }
sla@5237 57
mgronlun@6131 58 void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) {
sla@5237 59 assert_unset_gc_id();
sla@5237 60
sla@5237 61 report_gc_start_impl(cause, timestamp);
sla@5237 62 }
sla@5237 63
sla@5237 64 bool GCTracer::has_reported_gc_start() const {
sla@5237 65 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
sla@5237 66 }
sla@5237 67
mgronlun@6131 68 void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
sla@5237 69 assert_set_gc_id();
sla@5237 70
sla@5237 71 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
sla@5237 72 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
sla@5237 73 _shared_gc_info.set_end_timestamp(timestamp);
sla@5237 74
sla@5237 75 send_phase_events(time_partitions);
sla@5237 76 send_garbage_collection_event();
sla@5237 77 }
sla@5237 78
mgronlun@6131 79 void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partitions) {
sla@5237 80 assert_set_gc_id();
sla@5237 81
sla@5237 82 report_gc_end_impl(timestamp, time_partitions);
sla@5237 83
sla@5237 84 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
sla@5237 85 }
sla@5237 86
sla@5237 87 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
sla@5237 88 assert_set_gc_id();
sla@5237 89
sla@5237 90 send_reference_stats_event(REF_SOFT, rps.soft_count());
sla@5237 91 send_reference_stats_event(REF_WEAK, rps.weak_count());
sla@5237 92 send_reference_stats_event(REF_FINAL, rps.final_count());
sla@5237 93 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
sla@5237 94 }
sla@5237 95
sla@5237 96 #if INCLUDE_SERVICES
ehelin@5386 97 class ObjectCountEventSenderClosure : public KlassInfoClosure {
ehelin@5386 98 const GCId _gc_id;
ehelin@5386 99 const double _size_threshold_percentage;
ehelin@5386 100 const size_t _total_size_in_words;
mgronlun@6131 101 const Ticks _timestamp;
ehelin@5386 102
ehelin@5386 103 public:
mgronlun@6131 104 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, const Ticks& timestamp) :
ehelin@5386 105 _gc_id(gc_id),
ehelin@5386 106 _size_threshold_percentage(ObjectCountCutOffPercent / 100),
ehelin@5388 107 _total_size_in_words(total_size_in_words),
ehelin@5388 108 _timestamp(timestamp)
ehelin@5386 109 {}
ehelin@5386 110
ehelin@5386 111 virtual void do_cinfo(KlassInfoEntry* entry) {
ehelin@5386 112 if (should_send_event(entry)) {
ehelin@5388 113 ObjectCountEventSender::send(entry, _gc_id, _timestamp);
ehelin@5386 114 }
sla@5237 115 }
sla@5237 116
ehelin@5386 117 private:
ehelin@5386 118 bool should_send_event(const KlassInfoEntry* entry) const {
ehelin@5386 119 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
ehelin@5386 120 return percentage_of_heap >= _size_threshold_percentage;
ehelin@5386 121 }
ehelin@5386 122 };
sla@5237 123
sla@5237 124 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
sla@5237 125 assert_set_gc_id();
ehelin@5386 126 assert(is_alive_cl != NULL, "Must supply function to check liveness");
sla@5237 127
ehelin@5386 128 if (ObjectCountEventSender::should_send_event()) {
sla@5237 129 ResourceMark rm;
sla@5237 130
sla@5237 131 KlassInfoTable cit(false);
sla@5237 132 if (!cit.allocation_failed()) {
sla@5237 133 HeapInspection hi(false, false, false, NULL);
sla@5237 134 hi.populate_table(&cit, is_alive_cl);
mgronlun@6131 135 ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), Ticks::now());
sla@5237 136 cit.iterate(&event_sender);
sla@5237 137 }
sla@5237 138 }
sla@5237 139 }
ehelin@5386 140 #endif // INCLUDE_SERVICES
sla@5237 141
ehelin@6420 142 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
sla@5237 143 assert_set_gc_id();
sla@5237 144
sla@5237 145 send_gc_heap_summary_event(when, heap_summary);
ehelin@6420 146 }
ehelin@6420 147
ehelin@6420 148 void GCTracer::report_metaspace_summary(GCWhen::Type when, const MetaspaceSummary& summary) const {
ehelin@6420 149 assert_set_gc_id();
ehelin@6420 150
ehelin@6420 151 send_meta_space_summary_event(when, summary);
ehelin@6420 152
ehelin@6420 153 send_metaspace_chunk_free_list_summary(when, Metaspace::NonClassType, summary.metaspace_chunk_free_list_summary());
ehelin@6420 154 if (UseCompressedClassPointers) {
ehelin@6420 155 send_metaspace_chunk_free_list_summary(when, Metaspace::ClassType, summary.class_chunk_free_list_summary());
ehelin@6420 156 }
sla@5237 157 }
sla@5237 158
mgronlun@6131 159 void YoungGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
sla@5237 160 assert_set_gc_id();
sla@5237 161 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
sla@5237 162
sla@5237 163 GCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 164 send_young_gc_event();
sla@5237 165
sla@5237 166 _tenuring_threshold = UNSET_TENURING_THRESHOLD;
sla@5237 167 }
sla@5237 168
sla@5237 169 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
sla@5237 170 assert_set_gc_id();
sla@5237 171
sla@5237 172 send_promotion_failed_event(pf_info);
sla@5237 173 }
sla@5237 174
sla@5237 175 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
sla@5237 176 _tenuring_threshold = tenuring_threshold;
sla@5237 177 }
sla@5237 178
mgronlun@6131 179 void OldGCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
sla@5237 180 assert_set_gc_id();
sla@5237 181
sla@5237 182 GCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 183 send_old_gc_event();
sla@5237 184 }
sla@5237 185
mgronlun@6131 186 void ParallelOldTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
sla@5237 187 assert_set_gc_id();
sla@5237 188
sla@5237 189 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 190 send_parallel_old_event();
sla@5237 191 }
sla@5237 192
sla@5237 193 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
sla@5237 194 assert_set_gc_id();
sla@5237 195
sla@5237 196 _parallel_old_gc_info.report_dense_prefix(dense_prefix);
sla@5237 197 }
sla@5237 198
sla@5237 199 void OldGCTracer::report_concurrent_mode_failure() {
sla@5237 200 assert_set_gc_id();
sla@5237 201
sla@5237 202 send_concurrent_mode_failure_event();
sla@5237 203 }
sla@5237 204
sla@5237 205 #if INCLUDE_ALL_GCS
sla@5237 206 void G1NewTracer::report_yc_type(G1YCType type) {
sla@5237 207 assert_set_gc_id();
sla@5237 208
sla@5237 209 _g1_young_gc_info.set_type(type);
sla@5237 210 }
sla@5237 211
mgronlun@6131 212 void G1NewTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) {
sla@5237 213 assert_set_gc_id();
sla@5237 214
sla@5237 215 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 216 send_g1_young_gc_event();
sla@5237 217 }
sla@5237 218
sla@5237 219 void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {
sla@5237 220 assert_set_gc_id();
sla@5237 221
sla@5237 222 send_evacuation_info_event(info);
sla@5237 223 }
sla@5237 224
sla@5237 225 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {
sla@5237 226 assert_set_gc_id();
sla@5237 227
sla@5237 228 send_evacuation_failed_event(ef_info);
sla@5237 229 ef_info.reset();
sla@5237 230 }
sla@5237 231 #endif

mercurial