8025608: GC trace events missing nursery size information
Reviewed-by: sjohanss, mgerdin
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Thu Jun 11 11:07:03 2015 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Fri Jun 12 12:55:32 2015 +0200
@@ -3233,6 +3233,28 @@
}
#endif // PRODUCT
+G1HeapSummary G1CollectedHeap::create_g1_heap_summary() {
+ YoungList* young_list = heap()->young_list();
+
+ size_t eden_used_bytes = young_list->eden_used_bytes();
+ size_t survivor_used_bytes = young_list->survivor_used_bytes();
+
+ size_t eden_capacity_bytes =
+ (g1_policy()->young_list_target_length() * HeapRegion::GrainBytes) - survivor_used_bytes;
+
+ VirtualSpaceSummary heap_summary = create_heap_space_summary();
+ return G1HeapSummary(heap_summary, used(), eden_used_bytes, eden_capacity_bytes, survivor_used_bytes);
+}
+
+void G1CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
+ const G1HeapSummary& heap_summary = create_g1_heap_summary();
+ gc_tracer->report_gc_heap_summary(when, heap_summary);
+
+ const MetaspaceSummary& metaspace_summary = create_metaspace_summary();
+ gc_tracer->report_metaspace_summary(when, metaspace_summary);
+}
+
+
G1CollectedHeap* G1CollectedHeap::heap() {
CollectedHeap* heap = Universe::heap();
assert(heap != NULL, "Uninitialized access to G1CollectedHeap::heap()");
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp Thu Jun 11 11:07:03 2015 -0400
+++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp Fri Jun 12 12:55:32 2015 +0200
@@ -370,6 +370,8 @@
void log_gc_header();
void log_gc_footer(double pause_time_sec);
+ void trace_heap(GCWhen::Type when, const GCTracer* tracer);
+
// These are macros so that, if the assert fires, we get the correct
// line number, file, etc.
@@ -1548,6 +1550,8 @@
bool is_obj_dead_cond(const oop obj,
const VerifyOption vo) const;
+ G1HeapSummary create_g1_heap_summary();
+
// Printing
virtual void print_on(outputStream* st) const;
--- a/hotspot/src/share/vm/gc/shared/gcHeapSummary.hpp Thu Jun 11 11:07:03 2015 -0400
+++ b/hotspot/src/share/vm/gc/shared/gcHeapSummary.hpp Fri Jun 12 12:55:32 2015 +0200
@@ -78,11 +78,13 @@
class GCHeapSummary;
class PSHeapSummary;
+class G1HeapSummary;
class GCHeapSummaryVisitor {
public:
virtual void visit(const GCHeapSummary* heap_summary) const = 0;
virtual void visit(const PSHeapSummary* heap_summary) const {}
+ virtual void visit(const G1HeapSummary* heap_summary) const {}
};
class GCHeapSummary : public StackObj {
@@ -125,6 +127,22 @@
}
};
+class G1HeapSummary : public GCHeapSummary {
+ size_t _edenUsed;
+ size_t _edenCapacity;
+ size_t _survivorUsed;
+ public:
+ G1HeapSummary(VirtualSpaceSummary& heap_space, size_t heap_used, size_t edenUsed, size_t edenCapacity, size_t survivorUsed) :
+ GCHeapSummary(heap_space, heap_used), _edenUsed(edenUsed), _edenCapacity(edenCapacity), _survivorUsed(survivorUsed) { }
+ const size_t edenUsed() const { return _edenUsed; }
+ const size_t edenCapacity() const { return _edenCapacity; }
+ const size_t survivorUsed() const { return _survivorUsed; }
+
+ virtual void accept(GCHeapSummaryVisitor* visitor) const {
+ visitor->visit(this);
+ }
+};
+
class MetaspaceSummary : public StackObj {
size_t _capacity_until_GC;
MetaspaceSizes _meta_space;
--- a/hotspot/src/share/vm/gc/shared/gcTrace.hpp Thu Jun 11 11:07:03 2015 -0400
+++ b/hotspot/src/share/vm/gc/shared/gcTrace.hpp Fri Jun 12 12:55:32 2015 +0200
@@ -44,6 +44,7 @@
class MetaspaceChunkFreeListSummary;
class MetaspaceSummary;
class PSHeapSummary;
+class G1HeapSummary;
class ReferenceProcessorStats;
class TimePartitions;
class BoolObjectClosure;
--- a/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp Thu Jun 11 11:07:03 2015 -0400
+++ b/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp Fri Jun 12 12:55:32 2015 +0200
@@ -263,6 +263,20 @@
}
}
+ void visit(const G1HeapSummary* g1_heap_summary) const {
+ visit((GCHeapSummary*)g1_heap_summary);
+
+ EventG1HeapSummary e;
+ if (e.should_commit()) {
+ e.set_gcId(_gc_id.id());
+ e.set_when((u1)_when);
+ e.set_edenUsedSize(g1_heap_summary->edenUsed());
+ e.set_edenTotalSize(g1_heap_summary->edenCapacity());
+ e.set_survivorUsedSize(g1_heap_summary->survivorUsed());
+ e.commit();
+ }
+ }
+
void visit(const PSHeapSummary* ps_heap_summary) const {
visit((GCHeapSummary*)ps_heap_summary);
--- a/hotspot/src/share/vm/trace/trace.xml Thu Jun 11 11:07:03 2015 -0400
+++ b/hotspot/src/share/vm/trace/trace.xml Fri Jun 12 12:55:32 2015 +0200
@@ -264,6 +264,15 @@
<structvalue type="ObjectSpace" field="toSpace" label="To Space"/>
</event>
+ <event id="G1HeapSummary" path="vm/gc/heap/g1_summary" label="G1 Heap Summary" is_instant="true">
+ <value type="UINT" field="gcId" label="GC ID" relation="GC_ID"/>
+ <value type="GCWHEN" field="when" label="When" />
+
+ <value type="BYTES64" field="edenUsedSize" label="Eden Used Size" />
+ <value type="BYTES64" field="edenTotalSize" label="Eden Total Size" />
+ <value type="BYTES64" field="survivorUsedSize" label="Survivor Used Size" />
+ </event>
+
<event id="GCGarbageCollection" path="vm/gc/collector/garbage_collection" label="Garbage Collection"
description="Garbage collection performed by the JVM">
<value type="UINT" field="gcId" label="GC ID" relation="GC_ID" />