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

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

author
sjohanss
date
Tue, 26 Nov 2013 14:35:38 +0100
changeset 6148
55a0da3d420b
parent 5388
6aa440bc1125
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"
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"
sla@5237 35
sla@5237 36 #if INCLUDE_ALL_GCS
sla@5237 37 #include "gc_implementation/g1/evacuationInfo.hpp"
sla@5237 38 #endif
sla@5237 39
sla@5237 40 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
sla@5237 41 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
sla@5237 42
ehelin@5387 43 static GCId GCTracer_next_gc_id = 0;
sla@5237 44 static GCId create_new_gc_id() {
sla@5237 45 return GCTracer_next_gc_id++;
sla@5237 46 }
sla@5237 47
sla@5237 48 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {
sla@5237 49 assert_unset_gc_id();
sla@5237 50
sla@5237 51 GCId gc_id = create_new_gc_id();
sla@5237 52 _shared_gc_info.set_id(gc_id);
sla@5237 53 _shared_gc_info.set_cause(cause);
sla@5237 54 _shared_gc_info.set_start_timestamp(timestamp);
sla@5237 55 }
sla@5237 56
sla@5237 57 void GCTracer::report_gc_start(GCCause::Cause cause, jlong timestamp) {
sla@5237 58 assert_unset_gc_id();
sla@5237 59
sla@5237 60 report_gc_start_impl(cause, timestamp);
sla@5237 61 }
sla@5237 62
sla@5237 63 bool GCTracer::has_reported_gc_start() const {
sla@5237 64 return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
sla@5237 65 }
sla@5237 66
sla@5237 67 void GCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
sla@5237 68 assert_set_gc_id();
sla@5237 69
sla@5237 70 _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
sla@5237 71 _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
sla@5237 72 _shared_gc_info.set_end_timestamp(timestamp);
sla@5237 73
sla@5237 74 send_phase_events(time_partitions);
sla@5237 75 send_garbage_collection_event();
sla@5237 76 }
sla@5237 77
sla@5237 78 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
sla@5237 79 assert_set_gc_id();
sla@5237 80
sla@5237 81 report_gc_end_impl(timestamp, time_partitions);
sla@5237 82
sla@5237 83 _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
sla@5237 84 }
sla@5237 85
sla@5237 86 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
sla@5237 87 assert_set_gc_id();
sla@5237 88
sla@5237 89 send_reference_stats_event(REF_SOFT, rps.soft_count());
sla@5237 90 send_reference_stats_event(REF_WEAK, rps.weak_count());
sla@5237 91 send_reference_stats_event(REF_FINAL, rps.final_count());
sla@5237 92 send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
sla@5237 93 }
sla@5237 94
sla@5237 95 #if INCLUDE_SERVICES
ehelin@5386 96 class ObjectCountEventSenderClosure : public KlassInfoClosure {
ehelin@5386 97 const GCId _gc_id;
ehelin@5386 98 const double _size_threshold_percentage;
ehelin@5386 99 const size_t _total_size_in_words;
ehelin@5388 100 const jlong _timestamp;
ehelin@5386 101
ehelin@5386 102 public:
ehelin@5388 103 ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words, jlong timestamp) :
ehelin@5386 104 _gc_id(gc_id),
ehelin@5386 105 _size_threshold_percentage(ObjectCountCutOffPercent / 100),
ehelin@5388 106 _total_size_in_words(total_size_in_words),
ehelin@5388 107 _timestamp(timestamp)
ehelin@5386 108 {}
ehelin@5386 109
ehelin@5386 110 virtual void do_cinfo(KlassInfoEntry* entry) {
ehelin@5386 111 if (should_send_event(entry)) {
ehelin@5388 112 ObjectCountEventSender::send(entry, _gc_id, _timestamp);
ehelin@5386 113 }
sla@5237 114 }
sla@5237 115
ehelin@5386 116 private:
ehelin@5386 117 bool should_send_event(const KlassInfoEntry* entry) const {
ehelin@5386 118 double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
ehelin@5386 119 return percentage_of_heap >= _size_threshold_percentage;
ehelin@5386 120 }
ehelin@5386 121 };
sla@5237 122
sla@5237 123 void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
sla@5237 124 assert_set_gc_id();
ehelin@5386 125 assert(is_alive_cl != NULL, "Must supply function to check liveness");
sla@5237 126
ehelin@5386 127 if (ObjectCountEventSender::should_send_event()) {
sla@5237 128 ResourceMark rm;
sla@5237 129
sla@5237 130 KlassInfoTable cit(false);
sla@5237 131 if (!cit.allocation_failed()) {
sla@5237 132 HeapInspection hi(false, false, false, NULL);
sla@5237 133 hi.populate_table(&cit, is_alive_cl);
sla@5237 134
ehelin@5388 135 jlong timestamp = os::elapsed_counter();
ehelin@5388 136 ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), timestamp);
sla@5237 137 cit.iterate(&event_sender);
sla@5237 138 }
sla@5237 139 }
sla@5237 140 }
ehelin@5386 141 #endif // INCLUDE_SERVICES
sla@5237 142
sla@5237 143 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_summary) const {
sla@5237 144 assert_set_gc_id();
sla@5237 145
sla@5237 146 send_gc_heap_summary_event(when, heap_summary);
sla@5237 147 send_meta_space_summary_event(when, meta_space_summary);
sla@5237 148 }
sla@5237 149
sla@5237 150 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
sla@5237 151 assert_set_gc_id();
sla@5237 152 assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
sla@5237 153
sla@5237 154 GCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 155 send_young_gc_event();
sla@5237 156
sla@5237 157 _tenuring_threshold = UNSET_TENURING_THRESHOLD;
sla@5237 158 }
sla@5237 159
sla@5237 160 void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
sla@5237 161 assert_set_gc_id();
sla@5237 162
sla@5237 163 send_promotion_failed_event(pf_info);
sla@5237 164 }
sla@5237 165
sla@5237 166 void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
sla@5237 167 _tenuring_threshold = tenuring_threshold;
sla@5237 168 }
sla@5237 169
sla@5237 170 void OldGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
sla@5237 171 assert_set_gc_id();
sla@5237 172
sla@5237 173 GCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 174 send_old_gc_event();
sla@5237 175 }
sla@5237 176
sla@5237 177 void ParallelOldTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
sla@5237 178 assert_set_gc_id();
sla@5237 179
sla@5237 180 OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 181 send_parallel_old_event();
sla@5237 182 }
sla@5237 183
sla@5237 184 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
sla@5237 185 assert_set_gc_id();
sla@5237 186
sla@5237 187 _parallel_old_gc_info.report_dense_prefix(dense_prefix);
sla@5237 188 }
sla@5237 189
sla@5237 190 void OldGCTracer::report_concurrent_mode_failure() {
sla@5237 191 assert_set_gc_id();
sla@5237 192
sla@5237 193 send_concurrent_mode_failure_event();
sla@5237 194 }
sla@5237 195
sla@5237 196 #if INCLUDE_ALL_GCS
sla@5237 197 void G1NewTracer::report_yc_type(G1YCType type) {
sla@5237 198 assert_set_gc_id();
sla@5237 199
sla@5237 200 _g1_young_gc_info.set_type(type);
sla@5237 201 }
sla@5237 202
sla@5237 203 void G1NewTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
sla@5237 204 assert_set_gc_id();
sla@5237 205
sla@5237 206 YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
sla@5237 207 send_g1_young_gc_event();
sla@5237 208 }
sla@5237 209
sla@5237 210 void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {
sla@5237 211 assert_set_gc_id();
sla@5237 212
sla@5237 213 send_evacuation_info_event(info);
sla@5237 214 }
sla@5237 215
sla@5237 216 void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {
sla@5237 217 assert_set_gc_id();
sla@5237 218
sla@5237 219 send_evacuation_failed_event(ef_info);
sla@5237 220 ef_info.reset();
sla@5237 221 }
sla@5237 222 #endif

mercurial