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

Tue, 26 Nov 2013 14:35:38 +0100

author
sjohanss
date
Tue, 26 Nov 2013 14:35:38 +0100
changeset 6148
55a0da3d420b
parent 5647
f175e3678be2
child 6131
86e6d691f2e1
permissions
-rw-r--r--

8027675: Full collections with Serial slower in JDK 8 compared to 7u40
Summary: Reduced the number of calls to follow_class_loader and instead marked and pushed the klass holder directly. Also removed unneeded calls to adjust_klass.
Reviewed-by: coleenp, jmasa, mgerdin, tschatzl

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()) {
sla@5237 46 event.set_gcId(_shared_gc_info.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 {
ehelin@5647 58 EventGCReferenceStatistics e(UNTIMED);
sla@5237 59 if (e.should_commit()) {
sla@5237 60 e.set_gcId(_shared_gc_info.id());
sla@5237 61 e.set_type((u1)type);
sla@5237 62 e.set_count(count);
ehelin@5647 63 e.set_endtime(os::elapsed_counter());
sla@5237 64 e.commit();
sla@5237 65 }
sla@5237 66 }
sla@5237 67
sla@5237 68 void ParallelOldTracer::send_parallel_old_event() const {
sla@5237 69 EventGCParallelOld e(UNTIMED);
sla@5237 70 if (e.should_commit()) {
sla@5237 71 e.set_gcId(_shared_gc_info.id());
sla@5237 72 e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix());
sla@5237 73 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 74 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 75 e.commit();
sla@5237 76 }
sla@5237 77 }
sla@5237 78
sla@5237 79 void YoungGCTracer::send_young_gc_event() const {
sla@5237 80 EventGCYoungGarbageCollection e(UNTIMED);
sla@5237 81 if (e.should_commit()) {
sla@5237 82 e.set_gcId(_shared_gc_info.id());
sla@5237 83 e.set_tenuringThreshold(_tenuring_threshold);
sla@5237 84 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 85 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 86 e.commit();
sla@5237 87 }
sla@5237 88 }
sla@5237 89
sla@5237 90 void OldGCTracer::send_old_gc_event() const {
sla@5237 91 EventGCOldGarbageCollection e(UNTIMED);
sla@5237 92 if (e.should_commit()) {
sla@5237 93 e.set_gcId(_shared_gc_info.id());
sla@5237 94 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 95 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 96 e.commit();
sla@5237 97 }
sla@5237 98 }
sla@5237 99
sla@5237 100 static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) {
sla@5237 101 TraceStructCopyFailed failed_info;
sla@5237 102 failed_info.set_objectCount(cf_info.failed_count());
sla@5237 103 failed_info.set_firstSize(cf_info.first_size());
sla@5237 104 failed_info.set_smallestSize(cf_info.smallest_size());
sla@5237 105 failed_info.set_totalSize(cf_info.total_size());
sla@5237 106 return failed_info;
sla@5237 107 }
sla@5237 108
sla@5237 109 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const {
ehelin@5647 110 EventPromotionFailed e(UNTIMED);
sla@5237 111 if (e.should_commit()) {
sla@5237 112 e.set_gcId(_shared_gc_info.id());
sla@5237 113 e.set_data(to_trace_struct(pf_info));
sla@5237 114 e.set_thread(pf_info.thread()->thread_id());
ehelin@5647 115 e.set_endtime(os::elapsed_counter());
sla@5237 116 e.commit();
sla@5237 117 }
sla@5237 118 }
sla@5237 119
sla@5237 120 // Common to CMS and G1
sla@5237 121 void OldGCTracer::send_concurrent_mode_failure_event() {
ehelin@5647 122 EventConcurrentModeFailure e(UNTIMED);
sla@5237 123 if (e.should_commit()) {
sla@5237 124 e.set_gcId(_shared_gc_info.id());
ehelin@5647 125 e.set_endtime(os::elapsed_counter());
sla@5237 126 e.commit();
sla@5237 127 }
sla@5237 128 }
sla@5237 129
sla@5237 130 #if INCLUDE_ALL_GCS
sla@5237 131 void G1NewTracer::send_g1_young_gc_event() {
sla@5237 132 EventGCG1GarbageCollection e(UNTIMED);
sla@5237 133 if (e.should_commit()) {
sla@5237 134 e.set_gcId(_shared_gc_info.id());
sla@5237 135 e.set_type(_g1_young_gc_info.type());
sla@5237 136 e.set_starttime(_shared_gc_info.start_timestamp());
sla@5237 137 e.set_endtime(_shared_gc_info.end_timestamp());
sla@5237 138 e.commit();
sla@5237 139 }
sla@5237 140 }
sla@5237 141
sla@5237 142 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) {
ehelin@5647 143 EventEvacuationInfo e(UNTIMED);
sla@5237 144 if (e.should_commit()) {
sla@5237 145 e.set_gcId(_shared_gc_info.id());
sla@5237 146 e.set_cSetRegions(info->collectionset_regions());
sla@5237 147 e.set_cSetUsedBefore(info->collectionset_used_before());
sla@5237 148 e.set_cSetUsedAfter(info->collectionset_used_after());
sla@5237 149 e.set_allocationRegions(info->allocation_regions());
sla@5237 150 e.set_allocRegionsUsedBefore(info->alloc_regions_used_before());
sla@5237 151 e.set_allocRegionsUsedAfter(info->alloc_regions_used_before() + info->bytes_copied());
sla@5237 152 e.set_bytesCopied(info->bytes_copied());
sla@5237 153 e.set_regionsFreed(info->regions_freed());
ehelin@5647 154 e.set_endtime(os::elapsed_counter());
sla@5237 155 e.commit();
sla@5237 156 }
sla@5237 157 }
sla@5237 158
sla@5237 159 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const {
ehelin@5647 160 EventEvacuationFailed e(UNTIMED);
sla@5237 161 if (e.should_commit()) {
sla@5237 162 e.set_gcId(_shared_gc_info.id());
sla@5237 163 e.set_data(to_trace_struct(ef_info));
ehelin@5647 164 e.set_endtime(os::elapsed_counter());
sla@5237 165 e.commit();
sla@5237 166 }
sla@5237 167 }
sla@5237 168 #endif
sla@5237 169
sla@5237 170 static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
sla@5237 171 TraceStructVirtualSpace space;
sla@5237 172 space.set_start((TraceAddress)summary.start());
sla@5237 173 space.set_committedEnd((TraceAddress)summary.committed_end());
sla@5237 174 space.set_committedSize(summary.committed_size());
sla@5237 175 space.set_reservedEnd((TraceAddress)summary.reserved_end());
sla@5237 176 space.set_reservedSize(summary.reserved_size());
sla@5237 177 return space;
sla@5237 178 }
sla@5237 179
sla@5237 180 static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) {
sla@5237 181 TraceStructObjectSpace space;
sla@5237 182 space.set_start((TraceAddress)summary.start());
sla@5237 183 space.set_end((TraceAddress)summary.end());
sla@5237 184 space.set_used(summary.used());
sla@5237 185 space.set_size(summary.size());
sla@5237 186 return space;
sla@5237 187 }
sla@5237 188
sla@5237 189 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor {
sla@5237 190 GCId _id;
sla@5237 191 GCWhen::Type _when;
sla@5237 192 public:
sla@5237 193 GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {}
sla@5237 194
sla@5237 195 void visit(const GCHeapSummary* heap_summary) const {
sla@5237 196 const VirtualSpaceSummary& heap_space = heap_summary->heap();
sla@5237 197
ehelin@5647 198 EventGCHeapSummary e(UNTIMED);
sla@5237 199 if (e.should_commit()) {
sla@5237 200 e.set_gcId(_id);
sla@5237 201 e.set_when((u1)_when);
sla@5237 202 e.set_heapSpace(to_trace_struct(heap_space));
sla@5237 203 e.set_heapUsed(heap_summary->used());
ehelin@5647 204 e.set_endtime(os::elapsed_counter());
sla@5237 205 e.commit();
sla@5237 206 }
sla@5237 207 }
sla@5237 208
sla@5237 209 void visit(const PSHeapSummary* ps_heap_summary) const {
sla@5237 210 visit((GCHeapSummary*)ps_heap_summary);
sla@5237 211
sla@5237 212 const VirtualSpaceSummary& old_summary = ps_heap_summary->old();
sla@5237 213 const SpaceSummary& old_space = ps_heap_summary->old_space();
sla@5237 214 const VirtualSpaceSummary& young_summary = ps_heap_summary->young();
sla@5237 215 const SpaceSummary& eden_space = ps_heap_summary->eden();
sla@5237 216 const SpaceSummary& from_space = ps_heap_summary->from();
sla@5237 217 const SpaceSummary& to_space = ps_heap_summary->to();
sla@5237 218
ehelin@5647 219 EventPSHeapSummary e(UNTIMED);
sla@5237 220 if (e.should_commit()) {
sla@5237 221 e.set_gcId(_id);
sla@5237 222 e.set_when((u1)_when);
sla@5237 223
sla@5237 224 e.set_oldSpace(to_trace_struct(ps_heap_summary->old()));
sla@5237 225 e.set_oldObjectSpace(to_trace_struct(ps_heap_summary->old_space()));
sla@5237 226 e.set_youngSpace(to_trace_struct(ps_heap_summary->young()));
sla@5237 227 e.set_edenSpace(to_trace_struct(ps_heap_summary->eden()));
sla@5237 228 e.set_fromSpace(to_trace_struct(ps_heap_summary->from()));
sla@5237 229 e.set_toSpace(to_trace_struct(ps_heap_summary->to()));
ehelin@5647 230 e.set_endtime(os::elapsed_counter());
sla@5237 231 e.commit();
sla@5237 232 }
sla@5237 233 }
sla@5237 234 };
sla@5237 235
sla@5237 236 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const {
sla@5237 237 GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when);
sla@5237 238 heap_summary.accept(&visitor);
sla@5237 239 }
sla@5237 240
sla@5237 241 static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
sla@5237 242 TraceStructMetaspaceSizes meta_sizes;
sla@5237 243
sla@5237 244 meta_sizes.set_capacity(sizes.capacity());
sla@5237 245 meta_sizes.set_used(sizes.used());
sla@5237 246 meta_sizes.set_reserved(sizes.reserved());
sla@5237 247
sla@5237 248 return meta_sizes;
sla@5237 249 }
sla@5237 250
sla@5237 251 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const {
ehelin@5647 252 EventMetaspaceSummary e(UNTIMED);
sla@5237 253 if (e.should_commit()) {
sla@5237 254 e.set_gcId(_shared_gc_info.id());
sla@5237 255 e.set_when((u1) when);
sla@5237 256 e.set_metaspace(to_trace_struct(meta_space_summary.meta_space()));
sla@5237 257 e.set_dataSpace(to_trace_struct(meta_space_summary.data_space()));
sla@5237 258 e.set_classSpace(to_trace_struct(meta_space_summary.class_space()));
ehelin@5647 259 e.set_endtime(os::elapsed_counter());
sla@5237 260 e.commit();
sla@5237 261 }
sla@5237 262 }
sla@5237 263
sla@5237 264 class PhaseSender : public PhaseVisitor {
sla@5237 265 GCId _gc_id;
sla@5237 266 public:
sla@5237 267 PhaseSender(GCId gc_id) : _gc_id(gc_id) {}
sla@5237 268
sla@5237 269 template<typename T>
sla@5237 270 void send_phase(PausePhase* pause) {
sla@5237 271 T event(UNTIMED);
sla@5237 272 if (event.should_commit()) {
sla@5237 273 event.set_gcId(_gc_id);
sla@5237 274 event.set_name(pause->name());
sla@5237 275 event.set_starttime(pause->start());
sla@5237 276 event.set_endtime(pause->end());
sla@5237 277 event.commit();
sla@5237 278 }
sla@5237 279 }
sla@5237 280
sla@5237 281 void visit(GCPhase* pause) { ShouldNotReachHere(); }
sla@5237 282 void visit(ConcurrentPhase* pause) { Unimplemented(); }
sla@5237 283 void visit(PausePhase* pause) {
sla@5237 284 assert(PhasesStack::PHASE_LEVELS == 5, "Need more event types");
sla@5237 285
sla@5237 286 switch (pause->level()) {
sla@5237 287 case 0: send_phase<EventGCPhasePause>(pause); break;
sla@5237 288 case 1: send_phase<EventGCPhasePauseLevel1>(pause); break;
sla@5237 289 case 2: send_phase<EventGCPhasePauseLevel2>(pause); break;
sla@5237 290 case 3: send_phase<EventGCPhasePauseLevel3>(pause); break;
sla@5237 291 default: /* Ignore sending this phase */ break;
sla@5237 292 }
sla@5237 293 }
sla@5237 294 };
sla@5237 295
sla@5237 296 void GCTracer::send_phase_events(TimePartitions* time_partitions) const {
sla@5237 297 PhaseSender phase_reporter(_shared_gc_info.id());
sla@5237 298
sla@5237 299 TimePartitionPhasesIterator iter(time_partitions);
sla@5237 300 while (iter.has_next()) {
sla@5237 301 GCPhase* phase = iter.next();
sla@5237 302 phase->accept(&phase_reporter);
sla@5237 303 }
sla@5237 304 }

mercurial