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

Wed, 31 Jul 2019 14:28:51 -0400

author
kbarrett
date
Wed, 31 Jul 2019 14:28:51 -0400
changeset 9787
9f28a4cac6d9
parent 6904
0982ec23da03
child 7535
7ae4e26cb1e0
child 9858
b985cbb00e68
permissions
-rw-r--r--

8048556: Unnecessary GCLocker-initiated young GCs
Summary: Fixed recognition of unnecessary GCLocker collections.
Reviewed-by: pliden, tschatzl
Contributed-by: johnc@azul.com

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"
sla@5237 26 #include "gc_implementation/shared/gcHeapSummary.hpp"
sla@5237 27 #include "gc_implementation/shared/gcTimer.hpp"
sla@5237 28 #include "gc_implementation/shared/gcTrace.hpp"
sla@5237 29 #include "gc_implementation/shared/gcWhen.hpp"
sla@5237 30 #include "gc_implementation/shared/copyFailedInfo.hpp"
ehelin@5647 31 #include "runtime/os.hpp"
sla@5237 32 #include "trace/tracing.hpp"
sla@5237 33 #include "trace/traceBackend.hpp"
sla@5237 34 #if INCLUDE_ALL_GCS
sla@5237 35 #include "gc_implementation/g1/evacuationInfo.hpp"
sla@5237 36 #include "gc_implementation/g1/g1YCTypes.hpp"
sla@5237 37 #endif
sla@5237 38
sla@5237 39 // All GC dependencies against the trace framework is contained within this file.
sla@5237 40
sla@5237 41 typedef uintptr_t TraceAddress;
sla@5237 42
sla@5237 43 void GCTracer::send_garbage_collection_event() const {
sla@5237 44 EventGCGarbageCollection event(UNTIMED);
sla@5237 45 if (event.should_commit()) {
brutisso@6904 46 event.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 47 event.set_name(_shared_gc_info.name());
sla@5237 48 event.set_cause((u2) _shared_gc_info.cause());
sla@5237 49 event.set_sumOfPauses(_shared_gc_info.sum_of_pauses());
sla@5237 50 event.set_longestPause(_shared_gc_info.longest_pause());
sla@5237 51 event.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 52 event.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 53 event.commit();
sla@5237 54 }
sla@5237 55 }
sla@5237 56
sla@5237 57 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const {
mgronlun@6131 58 EventGCReferenceStatistics e;
sla@5237 59 if (e.should_commit()) {
brutisso@6904 60 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 61 e.set_type((u1)type);
sla@5237 62 e.set_count(count);
sla@5237 63 e.commit();
sla@5237 64 }
sla@5237 65 }
sla@5237 66
ehelin@6420 67 void GCTracer::send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspace::MetadataType mdtype,
ehelin@6420 68 const MetaspaceChunkFreeListSummary& summary) const {
ehelin@6420 69 EventMetaspaceChunkFreeListSummary e;
ehelin@6420 70 if (e.should_commit()) {
brutisso@6904 71 e.set_gcId(_shared_gc_info.gc_id().id());
ehelin@6420 72 e.set_when(when);
ehelin@6420 73 e.set_metadataType(mdtype);
ehelin@6420 74
ehelin@6420 75 e.set_specializedChunks(summary.num_specialized_chunks());
ehelin@6420 76 e.set_specializedChunksTotalSize(summary.specialized_chunks_size_in_bytes());
ehelin@6420 77
ehelin@6420 78 e.set_smallChunks(summary.num_small_chunks());
ehelin@6420 79 e.set_smallChunksTotalSize(summary.small_chunks_size_in_bytes());
ehelin@6420 80
ehelin@6420 81 e.set_mediumChunks(summary.num_medium_chunks());
ehelin@6420 82 e.set_mediumChunksTotalSize(summary.medium_chunks_size_in_bytes());
ehelin@6420 83
ehelin@6420 84 e.set_humongousChunks(summary.num_humongous_chunks());
ehelin@6420 85 e.set_humongousChunksTotalSize(summary.humongous_chunks_size_in_bytes());
ehelin@6420 86
ehelin@6420 87 e.commit();
ehelin@6420 88 }
ehelin@6420 89 }
ehelin@6420 90
sla@5237 91 void ParallelOldTracer::send_parallel_old_event() const {
sla@5237 92 EventGCParallelOld e(UNTIMED);
sla@5237 93 if (e.should_commit()) {
brutisso@6904 94 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 95 e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
sla@5237 96 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 97 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 98 e.commit();
sla@5237 99 }
sla@5237 100 }
sla@5237 101
sla@5237 102 void YoungGCTracer::send_young_gc_event() const {
sla@5237 103 EventGCYoungGarbageCollection e(UNTIMED);
sla@5237 104 if (e.should_commit()) {
brutisso@6904 105 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 106 e.set_tenuringThreshold(_tenuring_threshold);
sla@5237 107 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 108 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 109 e.commit();
sla@5237 110 }
sla@5237 111 }
sla@5237 112
sla@5237 113 void OldGCTracer::send_old_gc_event() const {
sla@5237 114 EventGCOldGarbageCollection e(UNTIMED);
sla@5237 115 if (e.should_commit()) {
brutisso@6904 116 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 117 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 118 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 119 e.commit();
sla@5237 120 }
sla@5237 121 }
sla@5237 122
sla@5237 123 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
sla@5237 124 TraceStructCopyFailed failed_info;
sla@5237 125 failed_info.set_objectCount(cf_info.failed_count());
sla@5237 126 failed_info.set_firstSize(cf_info.first_size());
sla@5237 127 failed_info.set_smallestSize(cf_info.smallest_size());
sla@5237 128 failed_info.set_totalSize(cf_info.total_size());
sla@5237 129 return failed_info;
sla@5237 130 }
sla@5237 131
sla@5237 132 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
mgronlun@6131 133 EventPromotionFailed e;
sla@5237 134 if (e.should_commit()) {
brutisso@6904 135 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 136 e.set_data(to_trace_struct(pf_info));
sla@5237 137 e.set_thread(pf_info.thread()->thread_id());
sla@5237 138 e.commit();
sla@5237 139 }
sla@5237 140 }
sla@5237 141
sla@5237 142 // Common to CMS and G1
sla@5237 143 void OldGCTracer::send_concurrent_mode_failure_event() {
mgronlun@6131 144 EventConcurrentModeFailure e;
sla@5237 145 if (e.should_commit()) {
brutisso@6904 146 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 147 e.commit();
sla@5237 148 }
sla@5237 149 }
sla@5237 150
sla@5237 151 #if INCLUDE_ALL_GCS
sla@5237 152 void G1NewTracer::send_g1_young_gc_event() {
sla@5237 153 EventGCG1GarbageCollection e(UNTIMED);
sla@5237 154 if (e.should_commit()) {
brutisso@6904 155 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 156 e.set_type(_g1_young_gc_info.type());
sla@5237 157 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 158 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 159 e.commit();
sla@5237 160 }
sla@5237 161 }
sla@5237 162
sla@5237 163 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
mgronlun@6131 164 EventEvacuationInfo e;
sla@5237 165 if (e.should_commit()) {
brutisso@6904 166 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 167 e.set_cSetRegions(info->collectionset_regions());
sla@5237 168 e.set_cSetUsedBefore(info->collectionset_used_before());
sla@5237 169 e.set_cSetUsedAfter(info->collectionset_used_after());
sla@5237 170 e.set_allocationRegions(info->allocation_regions());
sla@5237 171 e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
sla@5237 172 e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
sla@5237 173 e.set_bytesCopied(info->bytes_copied());
sla@5237 174 e.set_regionsFreed(info->regions_freed());
sla@5237 175 e.commit();
sla@5237 176 }
sla@5237 177 }
sla@5237 178
sla@5237 179 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
mgronlun@6131 180 EventEvacuationFailed e;
sla@5237 181 if (e.should_commit()) {
brutisso@6904 182 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 183 e.set_data(to_trace_struct(ef_info));
sla@5237 184 e.commit();
sla@5237 185 }
sla@5237 186 }
sla@5237 187 #endif
sla@5237 188
sla@5237 189 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
sla@5237 190 TraceStructVirtualSpace space;
sla@5237 191 space.set_start((TraceAddress)summary.start());
sla@5237 192 space.set_committedEnd((TraceAddress)summary.committed_end());
sla@5237 193 space.set_committedSize(summary.committed_size());
sla@5237 194 space.set_reservedEnd((TraceAddress)summary.reserved_end());
sla@5237 195 space.set_reservedSize(summary.reserved_size());
sla@5237 196 return space;
sla@5237 197 }
sla@5237 198
sla@5237 199 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
sla@5237 200 TraceStructObjectSpace space;
sla@5237 201 space.set_start((TraceAddress)summary.start());
sla@5237 202 space.set_end((TraceAddress)summary.end());
sla@5237 203 space.set_used(summary.used());
sla@5237 204 space.set_size(summary.size());
sla@5237 205 return space;
sla@5237 206 }
sla@5237 207
sla@5237 208 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
brutisso@6904 209 GCId _gc_id;
sla@5237 210 GCWhen::Type _when;
sla@5237 211 public:
brutisso@6904 212 GCHeapSummaryEventSender(GCId gc_id, GCWhen::Type when) : _gc_id(gc_id), _when(when) {}
sla@5237 213
sla@5237 214 void visit(const GCHeapSummary* heap_summary) const {
sla@5237 215 const VirtualSpaceSummary& heap_space = heap_summary->heap();
sla@5237 216
mgronlun@6131 217 EventGCHeapSummary e;
sla@5237 218 if (e.should_commit()) {
brutisso@6904 219 e.set_gcId(_gc_id.id());
sla@5237 220 e.set_when((u1)_when);
sla@5237 221 e.set_heapSpace(to_trace_struct(heap_space));
sla@5237 222 e.set_heapUsed(heap_summary->used());
sla@5237 223 e.commit();
sla@5237 224 }
sla@5237 225 }
sla@5237 226
sla@5237 227 void visit(const PSHeapSummary* ps_heap_summary) const {
sla@5237 228 visit((GCHeapSummary*)ps_heap_summary);
sla@5237 229
sla@5237 230 const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
sla@5237 231 const SpaceSummary& old_space = ps_heap_summary->old_space();
sla@5237 232 const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
sla@5237 233 const SpaceSummary& eden_space = ps_heap_summary->eden();
sla@5237 234 const SpaceSummary& from_space = ps_heap_summary->from();
sla@5237 235 const SpaceSummary& to_space = ps_heap_summary->to();
sla@5237 236
mgronlun@6131 237 EventPSHeapSummary e;
sla@5237 238 if (e.should_commit()) {
brutisso@6904 239 e.set_gcId(_gc_id.id());
sla@5237 240 e.set_when((u1)_when);
sla@5237 241
sla@5237 242 e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
sla@5237 243 e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
sla@5237 244 e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
sla@5237 245 e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
sla@5237 246 e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
sla@5237 247 e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
sla@5237 248 e.commit();
sla@5237 249 }
sla@5237 250 }
sla@5237 251 };
sla@5237 252
sla@5237 253 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
brutisso@6904 254 GCHeapSummaryEventSender visitor(_shared_gc_info.gc_id(), when);
sla@5237 255 heap_summary.accept(&visitor);
sla@5237 256 }
sla@5237 257
sla@5237 258 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
sla@5237 259 TraceStructMetaspaceSizes meta_sizes;
sla@5237 260
ehelin@6608 261 meta_sizes.set_committed(sizes.committed());
sla@5237 262 meta_sizes.set_used(sizes.used());
sla@5237 263 meta_sizes.set_reserved(sizes.reserved());
sla@5237 264
sla@5237 265 return meta_sizes;
sla@5237 266 }
sla@5237 267
sla@5237 268 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
mgronlun@6131 269 EventMetaspaceSummary e;
sla@5237 270 if (e.should_commit()) {
brutisso@6904 271 e.set_gcId(_shared_gc_info.gc_id().id());
sla@5237 272 e.set_when((u1) when);
ehelin@6416 273 e.set_gcThreshold(meta_space_summary.capacity_until_GC());
sla@5237 274 e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
sla@5237 275 e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
sla@5237 276 e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
sla@5237 277 e.commit();
sla@5237 278 }
sla@5237 279 }
sla@5237 280
sla@5237 281 class PhaseSender : public PhaseVisitor {
sla@5237 282 GCId _gc_id;
sla@5237 283 public:
sla@5237 284 PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
sla@5237 285
sla@5237 286 template<typename T>
sla@5237 287 void send_phase(PausePhase* pause) {
sla@5237 288 T event(UNTIMED);
sla@5237 289 if (event.should_commit()) {
brutisso@6904 290 event.set_gcId(_gc_id.id());
sla@5237 291 event.set_name(pause->name());
sla@5237 292 event.set_starttime(pause->start());
sla@5237 293 event.set_endtime(pause->end());
sla@5237 294 event.commit();
sla@5237 295 }
sla@5237 296 }
sla@5237 297
sla@5237 298 void visit(GCPhase* pause) { ShouldNotReachHere(); }
sla@5237 299 void visit(ConcurrentPhase* pause) { Unimplemented(); }
sla@5237 300 void visit(PausePhase* pause) {
sla@5237 301 assert(PhasesStack::PHASE_LEVELS == 5, "Need more event types");
sla@5237 302
sla@5237 303 switch (pause->level()) {
sla@5237 304 case 0: send_phase<EventGCPhasePause>(pause); break;
sla@5237 305 case 1: send_phase<EventGCPhasePauseLevel1>(pause); break;
sla@5237 306 case 2: send_phase<EventGCPhasePauseLevel2>(pause); break;
sla@5237 307 case 3: send_phase<EventGCPhasePauseLevel3>(pause); break;
sla@5237 308 default: /* Ignore sending this phase */ break;
sla@5237 309 }
sla@5237 310 }
sla@5237 311 };
sla@5237 312
sla@5237 313 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
brutisso@6904 314 PhaseSender phase_reporter(_shared_gc_info.gc_id());
sla@5237 315
sla@5237 316 TimePartitionPhasesIterator iter(time_partitions);
sla@5237 317 while (iter.has_next()) {
sla@5237 318 GCPhase* phase = iter.next();
sla@5237 319 phase->accept(&phase_reporter);
sla@5237 320 }
sla@5237 321 }

mercurial