8136679: JFR event for adaptive IHOP
Reviewed-by: tbenson, mgerdin, sangheki, ehelin
--- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp Wed Nov 25 14:43:29 2015 +0100
@@ -1213,6 +1213,8 @@
last_unrestrained_young_length * HeapRegion::GrainBytes);
_bytes_allocated_in_old_since_last_gc = 0;
+ _ihop_control->send_trace_event(_g1->gc_tracer_stw());
+
// Note that _mmu_tracker->max_gc_time() returns the time in seconds.
double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp Wed Nov 25 14:43:29 2015 +0100
@@ -27,6 +27,7 @@
#include "gc/g1/g1ErgoVerbose.hpp"
#include "gc/g1/g1IHOPControl.hpp"
#include "gc/g1/g1Predictions.hpp"
+#include "gc/shared/gcTrace.hpp"
G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
_initial_ihop_percent(initial_ihop_percent),
@@ -62,6 +63,15 @@
last_marking_length_s());
}
+void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
+ tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
+ _target_occupancy,
+ G1CollectedHeap::heap()->used(),
+ _last_allocated_bytes,
+ _last_allocation_time_s,
+ last_marking_length_s());
+}
+
G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
G1IHOPControl(ihop_percent, target_occupancy),
_last_marking_length_s(0.0) {
@@ -166,11 +176,11 @@
}
void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
- assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
+ G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes, additional_buffer_size);
+
double allocation_rate = (double) allocated_bytes / allocation_time_s;
_allocation_rate_s.add(allocation_rate);
- _last_allocation_bytes = allocated_bytes;
_last_unrestrained_young_size = additional_buffer_size;
}
@@ -180,21 +190,7 @@
}
void G1AdaptiveIHOPControl::print() {
- ergo_verbose6(ErgoIHOP,
- "basic information",
- ergo_format_reason("value update")
- ergo_format_byte_perc("threshold")
- ergo_format_byte("target occupancy")
- ergo_format_byte("current occupancy")
- ergo_format_double("recent old gen allocation rate")
- ergo_format_double("recent marking phase length"),
- get_conc_mark_start_threshold(),
- percent_of(get_conc_mark_start_threshold(), _target_occupancy),
- _target_occupancy,
- G1CollectedHeap::heap()->used(),
- _allocation_rate_s.last(),
- _marking_times_s.last()
- );
+ G1IHOPControl::print();
size_t actual_target = actual_target_threshold();
ergo_verbose6(ErgoIHOP,
"adaptive IHOP information",
@@ -213,6 +209,17 @@
);
}
+void G1AdaptiveIHOPControl::send_trace_event(G1NewTracer* tracer) {
+ G1IHOPControl::send_trace_event(tracer);
+ tracer->report_adaptive_ihop_statistics(get_conc_mark_start_threshold(),
+ actual_target_threshold(),
+ G1CollectedHeap::heap()->used(),
+ _last_unrestrained_young_size,
+ _predictor->get_new_prediction(&_allocation_rate_s),
+ _predictor->get_new_prediction(&_marking_times_s),
+ have_enough_data_for_prediction());
+}
+
#ifndef PRODUCT
void G1AdaptiveIHOPControl::test() {
size_t const initial_threshold = 45;
--- a/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/gc/g1/g1IHOPControl.hpp Wed Nov 25 14:43:29 2015 +0100
@@ -29,6 +29,7 @@
#include "utilities/numberSeq.hpp"
class G1Predictions;
+class G1NewTracer;
// Base class for algorithms that calculate the heap occupancy at which
// concurrent marking should start. This heap usage threshold should be relative
@@ -73,6 +74,7 @@
virtual void update_marking_length(double marking_length_s) = 0;
virtual void print();
+ virtual void send_trace_event(G1NewTracer* tracer);
};
// The returned concurrent mark starting occupancy threshold is a fixed value
@@ -111,7 +113,6 @@
TruncatedSeq _marking_times_s;
TruncatedSeq _allocation_rate_s;
- size_t _last_allocation_bytes; // Most recent mutator allocation since last GC.
// The most recent unrestrained size of the young gen. This is used as an additional
// factor in the calculation of the threshold, as the threshold is based on
// non-young gen occupancy at the end of GC. For the IHOP threshold, we need to
@@ -142,6 +143,7 @@
virtual void update_marking_length(double marking_length_s);
virtual void print();
+ virtual void send_trace_event(G1NewTracer* tracer);
#ifndef PRODUCT
static void test();
#endif
--- a/hotspot/src/share/vm/gc/shared/gcTrace.cpp Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/gc/shared/gcTrace.cpp Wed Nov 25 14:43:29 2015 +0100
@@ -212,4 +212,34 @@
send_old_evacuation_statistics(old_summary);
}
+void G1NewTracer::report_basic_ihop_statistics(size_t threshold,
+ size_t target_ccupancy,
+ size_t current_occupancy,
+ size_t last_allocation_size,
+ double last_allocation_duration,
+ double last_marking_length) {
+ send_basic_ihop_statistics(threshold,
+ target_ccupancy,
+ current_occupancy,
+ last_allocation_size,
+ last_allocation_duration,
+ last_marking_length);
+}
+
+void G1NewTracer::report_adaptive_ihop_statistics(size_t threshold,
+ size_t internal_target_occupancy,
+ size_t current_occupancy,
+ size_t additional_buffer_size,
+ double predicted_allocation_rate,
+ double predicted_marking_length,
+ bool prediction_active) {
+ send_adaptive_ihop_statistics(threshold,
+ internal_target_occupancy,
+ additional_buffer_size,
+ current_occupancy,
+ predicted_allocation_rate,
+ predicted_marking_length,
+ prediction_active);
+}
+
#endif
--- a/hotspot/src/share/vm/gc/shared/gcTrace.hpp Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/gc/shared/gcTrace.hpp Wed Nov 25 14:43:29 2015 +0100
@@ -253,6 +253,20 @@
void report_evacuation_failed(EvacuationFailedInfo& ef_info);
void report_evacuation_statistics(const G1EvacSummary& young_summary, const G1EvacSummary& old_summary) const;
+
+ void report_basic_ihop_statistics(size_t threshold,
+ size_t target_occupancy,
+ size_t current_occupancy,
+ size_t last_allocation_size,
+ double last_allocation_duration,
+ double last_marking_length);
+ void report_adaptive_ihop_statistics(size_t threshold,
+ size_t internal_target_occupancy,
+ size_t current_occupancy,
+ size_t additional_buffer_size,
+ double predicted_allocation_rate,
+ double predicted_marking_length,
+ bool prediction_active);
private:
void send_g1_young_gc_event();
void send_evacuation_info_event(EvacuationInfo* info);
@@ -260,6 +274,20 @@
void send_young_evacuation_statistics(const G1EvacSummary& summary) const;
void send_old_evacuation_statistics(const G1EvacSummary& summary) const;
+
+ void send_basic_ihop_statistics(size_t threshold,
+ size_t target_occupancy,
+ size_t current_occupancy,
+ size_t last_allocation_size,
+ double last_allocation_duration,
+ double last_marking_length);
+ void send_adaptive_ihop_statistics(size_t threshold,
+ size_t internal_target_occupancy,
+ size_t current_occupancy,
+ size_t additional_buffer_size,
+ double predicted_allocation_rate,
+ double predicted_marking_length,
+ bool prediction_active);
};
#endif
--- a/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp Wed Nov 25 14:43:29 2015 +0100
@@ -35,6 +35,7 @@
#if INCLUDE_ALL_GCS
#include "gc/g1/evacuationInfo.hpp"
#include "gc/g1/g1YCTypes.hpp"
+#include "tracefiles/traceEventClasses.hpp"
#endif
// All GC dependencies against the trace framework is contained within this file.
@@ -265,6 +266,50 @@
old_evt.commit();
}
}
+
+void G1NewTracer::send_basic_ihop_statistics(size_t threshold,
+ size_t target_occupancy,
+ size_t current_occupancy,
+ size_t last_allocation_size,
+ double last_allocation_duration,
+ double last_marking_length) {
+ EventGCG1BasicIHOP evt;
+ if (evt.should_commit()) {
+ evt.set_gcId(GCId::current());
+ evt.set_threshold(threshold);
+ evt.set_targetOccupancy(target_occupancy);
+ evt.set_thresholdPercentage(target_occupancy > 0 ? threshold * 100.0 / target_occupancy : 0.0);
+ evt.set_currentOccupancy(current_occupancy);
+ evt.set_lastAllocationSize(last_allocation_size);
+ evt.set_lastAllocationDuration(last_allocation_duration);
+ evt.set_lastAllocationRate(last_allocation_duration != 0.0 ? last_allocation_size / last_allocation_duration : 0.0);
+ evt.set_lastMarkingLength(last_marking_length);
+ evt.commit();
+ }
+}
+
+void G1NewTracer::send_adaptive_ihop_statistics(size_t threshold,
+ size_t internal_target_occupancy,
+ size_t current_occupancy,
+ size_t additional_buffer_size,
+ double predicted_allocation_rate,
+ double predicted_marking_length,
+ bool prediction_active) {
+ EventGCG1AdaptiveIHOP evt;
+ if (evt.should_commit()) {
+ evt.set_gcId(GCId::current());
+ evt.set_threshold(threshold);
+ evt.set_thresholdPercentage(internal_target_occupancy > 0 ? threshold * 100.0 / internal_target_occupancy : 0.0);
+ evt.set_internalTargetOccupancy(internal_target_occupancy);
+ evt.set_currentOccupancy(current_occupancy);
+ evt.set_additionalBufferSize(additional_buffer_size);
+ evt.set_predictedAllocationRate(predicted_allocation_rate);
+ evt.set_predictedMarkingLength(predicted_marking_length);
+ evt.set_predictionActive(prediction_active);
+ evt.commit();
+ }
+}
+
#endif
static TraceStructVirtualSpace to_trace_struct(const VirtualSpaceSummary& summary) {
--- a/hotspot/src/share/vm/trace/trace.xml Tue Nov 24 10:35:52 2015 +0100
+++ b/hotspot/src/share/vm/trace/trace.xml Wed Nov 25 14:43:29 2015 +0100
@@ -369,6 +369,32 @@
<structvalue type="G1EvacStats" field="stats" label="Evacuation statistics"/>
</event>
+ <event id="GCG1BasicIHOP" path="vm/gc/detailed/g1_basic_ihop_status" label="G1 Basic IHOP statistics" is_instant="true"
+ description="Basic statistics related to current IHOP calculation">
+ <value type="UINT" field="gcId" label="GC ID" relation="GC_ID"/>
+ <value type="BYTES64" field="threshold" label="Current IHOP threshold" description="Current IHOP threshold in bytes"/>
+ <value type="BYTES64" field="thresholdPercentage" label="Current IHOP threshold in percent" description="Current IHOP threshold in percent of old gen"/>
+ <value type="BYTES64" field="targetOccupancy" label="Target occupancy" description="Target old gen occupancy to reach at the start of mixed GC in bytes"/>
+ <value type="BYTES64" field="currentOccupancy" label="Current occupancy" description="Current old gen occupancy in bytes"/>
+ <value type="BYTES64" field="lastAllocationSize" label="Last mutator allocation size" description="Mutator allocation during mutator operation since last GC in bytes"/>
+ <value type="DOUBLE" field="lastAllocationDuration" label="Last mutator operation duration" description="Time the mutator ran since last GC in seconds"/>
+ <value type="DOUBLE" field="lastAllocationRate" label="Last mutator allocation rate" description="Allocation rate of the mutator since last GC in bytes/second"/>
+ <value type="DOUBLE" field="lastMarkingLength" label="Last mutator time from initial mark to first mixed GC" description="Last time from the end of the last initial mark to the first mixed GC in seconds"/>
+ </event>
+
+ <event id="GCG1AdaptiveIHOP" path="vm/gc/detailed/g1_adaptive_ihop_status" label="G1 Adaptive IHOP statistics" is_instant="true"
+ description="Statistics related to current adaptive IHOP calculation">
+ <value type="UINT" field="gcId" label="GC ID" relation="GC_ID"/>
+ <value type="BYTES64" field="threshold" label="Current IHOP threshold" description="Current IHOP threshold in bytes"/>
+ <value type="BYTES64" field="thresholdPercentage" label="Current IHOP threshold in percent" description="Current IHOP threshold in percent of the internal target occupancy"/>
+ <value type="BYTES64" field="internalTargetOccupancy" label="Target occupancy" description="Internal target old gen occupancy to reach at the start of mixed GC in bytes"/>
+ <value type="BYTES64" field="currentOccupancy" label="Current occupancy" description="Current old gen occupancy in bytes"/>
+ <value type="BYTES64" field="additionalBufferSize" label="Additional buffer size" description="Additional buffer size in bytes"/>
+ <value type="DOUBLE" field="predictedAllocationRate" label="Predicted mutator allocation rate" description="Current predicted allocation rate for the mutator in bytes/second"/>
+ <value type="DOUBLE" field="predictedMarkingLength" label="Predicted time from initial mark to first mixed GC" description="Current predicted time from the end of the last initial mark to the first mixed GC in seconds"/>
+ <value type="BOOLEAN" field="predictionActive" label="Prediction active" description="Indicates whether the adaptive IHOP prediction is active"/>
+ </event>
+
<!-- Promotion events, Supported GCs are Parallel Scavange, G1 and CMS with Parallel New. -->
<event id="PromoteObjectInNewPLAB" path="vm/gc/detailed/object_promotion_in_new_PLAB" label="Promotion in new PLAB"
description="Object survived scavenge and was copied to a new Promotion Local Allocation Buffer (PLAB). Supported GCs are Parallel Scavange, G1 and CMS with Parallel New. Due to promotion being done in parallel an object might be reported multiple times as the GC threads race to copy all objects."