in src/main/java/org/opensearch/performanceanalyzer/rca/store/rca/hotheap/HighHeapUsageYoungGenRca.java [341:440]
public ResourceFlowUnit<HotResourceSummary> operate() {
if (!isCollectorCMS()) {
// return an empty flow unit. We don't want to tune the JVM when the collector is not
// CMS.
return new ResourceFlowUnit<>(System.currentTimeMillis());
}
long currTimeStamp = this.clock.millis();
counter += 1;
LOG.debug("HighHeapUsageYoungGenRca getting collection event flow units");
double fullGcCount = 0;
for (MetricFlowUnit metricFU : gc_Collection_Event.getFlowUnits()) {
if (metricFU.isEmpty()) {
continue;
}
fullGcCount =
SQLParsingUtil.readDataFromSqlResult(
metricFU.getData(),
AllMetrics.HeapDimension.MEM_TYPE.getField(),
AllMetrics.GCType.OLD_GEN.toString(),
MetricsDB.MAX);
if (Double.isNaN(fullGcCount)) {
fullGcCount = 0;
LOG.error(
"Failed to parse metric in FlowUnit from {}",
gc_Collection_Event.getClass().getName());
}
}
LOG.debug("HighHeapUsageYoungGenRca getting heap used flow units");
// parsing flowunits from heap_used and push them into sliding window
for (MetricFlowUnit metricFU : heap_Used.getFlowUnits()) {
if (metricFU.isEmpty()) {
continue;
}
double oldGenHeapUsed =
SQLParsingUtil.readDataFromSqlResult(
metricFU.getData(),
AllMetrics.HeapDimension.MEM_TYPE.getField(),
AllMetrics.GCType.OLD_GEN.toString(),
MetricsDB.MAX);
if (!Double.isNaN(oldGenHeapUsed)) {
promotionRateDeque.next(
new SlidingWindowData(
currTimeStamp, oldGenHeapUsed / CONVERT_BYTES_TO_MEGABYTES));
computePromotionHealth(oldGenHeapUsed, fullGcCount, currTimeStamp);
} else {
LOG.error(
"Failed to parse metric in FlowUnit from {}",
heap_Used.getClass().getName());
}
}
LOG.debug("HighHeapUsageYoungGenRca getting collection time flow units");
// parsing flowunits from gc_Collection_Time and push them into sliding window
for (MetricFlowUnit metricFU : gc_Collection_Time.getFlowUnits()) {
if (metricFU.isEmpty()) {
continue;
}
double totYoungGCTime =
SQLParsingUtil.readDataFromSqlResult(
metricFU.getData(),
AllMetrics.HeapDimension.MEM_TYPE.getField(),
AllMetrics.GCType.TOT_YOUNG_GC.toString(),
MetricsDB.MAX);
if (!Double.isNaN(totYoungGCTime)) {
minorGcTimeDeque.next(new SlidingWindowData(currTimeStamp, totYoungGCTime));
}
double totFullGCTime =
SQLParsingUtil.readDataFromSqlResult(
metricFU.getData(),
AllMetrics.HeapDimension.MEM_TYPE.getField(),
AllMetrics.GCType.TOT_FULL_GC.toString(),
MetricsDB.MAX);
if (!Double.isNaN(totFullGCTime)) {
fullGcTimeDeque.next(new SlidingWindowData(currTimeStamp, totFullGCTime));
} else {
LOG.error(
"Failed to parse metric in FlowUnit from {}",
gc_Collection_Time.getClass().getName());
}
}
if (counter == rcaPeriod) {
LOG.debug("HighHeapUsageYoungGenRca computing data...");
counter = 0;
double avgPromotionRate = promotionRateDeque.readAvg(TimeUnit.SECONDS);
double avgYoungGCTime = minorGcTimeDeque.readAvg(TimeUnit.SECONDS);
double avgGarbagePromoted = garbagePromotedDeque.readAvg();
double avgFullGCTime = fullGcTimeDeque.readAvg();
return computeFlowUnit(
avgPromotionRate, avgYoungGCTime, avgGarbagePromoted, avgFullGCTime);
} else {
// we return an empty FlowUnit RCA for now. Can change to healthy (or previous known RCA
// state)
LOG.debug("RCA: Empty FlowUnit returned for Young Gen RCA");
return new ResourceFlowUnit<>(this.clock.millis());
}
}