mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8005849: JEP 167: Event-Based JVM Tracing
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com> Co-authored-by: Bengt Rutisson <bengt.rutisson@oracle.com> Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com> Co-authored-by: Erik Gahlin <erik.gahlin@oracle.com> Co-authored-by: Erik Helin <erik.helin@oracle.com> Co-authored-by: Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com> Co-authored-by: Keith McGuigan <keith.mcguigan@oracle.com> Co-authored-by: Mattias Tobiasson <mattias.tobiasson@oracle.com> Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com> Co-authored-by: Mikael Auno <mikael.auno@oracle.com> Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com> Co-authored-by: Nils Loodin <nils.loodin@oracle.com> Co-authored-by: Rickard Backman <rickard.backman@oracle.com> Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com> Co-authored-by: Yekaterina Kantserova <yekaterina.kantserova@oracle.com> Reviewed-by: acorn, coleenp, sla
This commit is contained in:
parent
6b2c468c35
commit
718f3252f6
195 changed files with 7628 additions and 1484 deletions
207
hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp
Normal file
207
hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp
Normal file
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "gc_implementation/shared/gcHeapSummary.hpp"
|
||||
#include "gc_implementation/shared/gcTimer.hpp"
|
||||
#include "gc_implementation/shared/gcTrace.hpp"
|
||||
#include "gc_implementation/shared/copyFailedInfo.hpp"
|
||||
#include "memory/heapInspection.hpp"
|
||||
#include "memory/referenceProcessorStats.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
#if INCLUDE_ALL_GCS
|
||||
#include "gc_implementation/g1/evacuationInfo.hpp"
|
||||
#endif
|
||||
|
||||
#define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
|
||||
#define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
|
||||
|
||||
static jlong GCTracer_next_gc_id = 0;
|
||||
static GCId create_new_gc_id() {
|
||||
return GCTracer_next_gc_id++;
|
||||
}
|
||||
|
||||
void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {
|
||||
assert_unset_gc_id();
|
||||
|
||||
GCId gc_id = create_new_gc_id();
|
||||
_shared_gc_info.set_id(gc_id);
|
||||
_shared_gc_info.set_cause(cause);
|
||||
_shared_gc_info.set_start_timestamp(timestamp);
|
||||
}
|
||||
|
||||
void GCTracer::report_gc_start(GCCause::Cause cause, jlong timestamp) {
|
||||
assert_unset_gc_id();
|
||||
|
||||
report_gc_start_impl(cause, timestamp);
|
||||
}
|
||||
|
||||
bool GCTracer::has_reported_gc_start() const {
|
||||
return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
|
||||
}
|
||||
|
||||
void GCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
||||
assert_set_gc_id();
|
||||
|
||||
_shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
|
||||
_shared_gc_info.set_longest_pause(time_partitions->longest_pause());
|
||||
_shared_gc_info.set_end_timestamp(timestamp);
|
||||
|
||||
send_phase_events(time_partitions);
|
||||
send_garbage_collection_event();
|
||||
}
|
||||
|
||||
void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
|
||||
assert_set_gc_id();
|
||||
|
||||
report_gc_end_impl(timestamp, time_partitions);
|
||||
|
||||
_shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
|
||||
}
|
||||
|
||||
void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const {
|
||||
assert_set_gc_id();
|
||||
|
||||
send_reference_stats_event(REF_SOFT, rps.soft_count());
|
||||
send_reference_stats_event(REF_WEAK, rps.weak_count());
|
||||
send_reference_stats_event(REF_FINAL, rps.final_count());
|
||||
send_reference_stats_event(REF_PHANTOM, rps.phantom_count());
|
||||
}
|
||||
|
||||
#if INCLUDE_SERVICES
|
||||
void ObjectCountEventSenderClosure::do_cinfo(KlassInfoEntry* entry) {
|
||||
if (should_send_event(entry)) {
|
||||
send_event(entry);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectCountEventSenderClosure::send_event(KlassInfoEntry* entry) {
|
||||
_gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
|
||||
entry->words() * BytesPerWord);
|
||||
}
|
||||
|
||||
bool ObjectCountEventSenderClosure::should_send_event(KlassInfoEntry* entry) const {
|
||||
double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
|
||||
return percentage_of_heap > _size_threshold_percentage;
|
||||
}
|
||||
|
||||
void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
|
||||
assert_set_gc_id();
|
||||
|
||||
if (should_send_object_count_after_gc_event()) {
|
||||
ResourceMark rm;
|
||||
|
||||
KlassInfoTable cit(false);
|
||||
if (!cit.allocation_failed()) {
|
||||
HeapInspection hi(false, false, false, NULL);
|
||||
hi.populate_table(&cit, is_alive_cl);
|
||||
|
||||
ObjectCountEventSenderClosure event_sender(this, cit.size_of_instances_in_words());
|
||||
cit.iterate(&event_sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_summary) const {
|
||||
assert_set_gc_id();
|
||||
|
||||
send_gc_heap_summary_event(when, heap_summary);
|
||||
send_meta_space_summary_event(when, meta_space_summary);
|
||||
}
|
||||
|
||||
void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
||||
assert_set_gc_id();
|
||||
assert(_tenuring_threshold != UNSET_TENURING_THRESHOLD, "Tenuring threshold has not been reported");
|
||||
|
||||
GCTracer::report_gc_end_impl(timestamp, time_partitions);
|
||||
send_young_gc_event();
|
||||
|
||||
_tenuring_threshold = UNSET_TENURING_THRESHOLD;
|
||||
}
|
||||
|
||||
void YoungGCTracer::report_promotion_failed(const PromotionFailedInfo& pf_info) {
|
||||
assert_set_gc_id();
|
||||
|
||||
send_promotion_failed_event(pf_info);
|
||||
}
|
||||
|
||||
void YoungGCTracer::report_tenuring_threshold(const uint tenuring_threshold) {
|
||||
_tenuring_threshold = tenuring_threshold;
|
||||
}
|
||||
|
||||
void OldGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
||||
assert_set_gc_id();
|
||||
|
||||
GCTracer::report_gc_end_impl(timestamp, time_partitions);
|
||||
send_old_gc_event();
|
||||
}
|
||||
|
||||
void ParallelOldTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
||||
assert_set_gc_id();
|
||||
|
||||
OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
|
||||
send_parallel_old_event();
|
||||
}
|
||||
|
||||
void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
|
||||
assert_set_gc_id();
|
||||
|
||||
_parallel_old_gc_info.report_dense_prefix(dense_prefix);
|
||||
}
|
||||
|
||||
void OldGCTracer::report_concurrent_mode_failure() {
|
||||
assert_set_gc_id();
|
||||
|
||||
send_concurrent_mode_failure_event();
|
||||
}
|
||||
|
||||
#if INCLUDE_ALL_GCS
|
||||
void G1NewTracer::report_yc_type(G1YCType type) {
|
||||
assert_set_gc_id();
|
||||
|
||||
_g1_young_gc_info.set_type(type);
|
||||
}
|
||||
|
||||
void G1NewTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
|
||||
assert_set_gc_id();
|
||||
|
||||
YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
|
||||
send_g1_young_gc_event();
|
||||
}
|
||||
|
||||
void G1NewTracer::report_evacuation_info(EvacuationInfo* info) {
|
||||
assert_set_gc_id();
|
||||
|
||||
send_evacuation_info_event(info);
|
||||
}
|
||||
|
||||
void G1NewTracer::report_evacuation_failed(EvacuationFailedInfo& ef_info) {
|
||||
assert_set_gc_id();
|
||||
|
||||
send_evacuation_failed_event(ef_info);
|
||||
ef_info.reset();
|
||||
}
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue