This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new b61f634b57e Fix the problem of inaccurate GC monitor detection at the
beginning and adjusting the alert threshold. (#11297)
b61f634b57e is described below
commit b61f634b57e83a65fed0edadacc856f2d134203c
Author: Peng Junzhi <[email protected]>
AuthorDate: Thu Oct 12 21:11:18 2023 -0500
Fix the problem of inaccurate GC monitor detection at the beginning and
adjusting the alert threshold. (#11297)
---
.../src/main/java/org/apache/iotdb/cli/Cli.java | 1 -
.../service/metric/JvmGcMonitorMetrics.java | 35 ++++++++++++++--------
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java
b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java
index b65d16ad288..54c7f223991 100644
--- a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java
+++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java
@@ -45,7 +45,6 @@ import static org.apache.iotdb.jdbc.Config.IOTDB_ERROR_PREFIX;
/** args[]: -h 127.0.0.1 -p 6667 -u root -pw root */
public class Cli extends AbstractCli {
-
private static CommandLine commandLine;
private static LineReader lineReader;
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/JvmGcMonitorMetrics.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/JvmGcMonitorMetrics.java
index 6624c3047de..db6987bbb3c 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/JvmGcMonitorMetrics.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/service/metric/JvmGcMonitorMetrics.java
@@ -45,9 +45,9 @@ public class JvmGcMonitorMetrics implements IMetricSet {
// Interval for data collection
public static final long SLEEP_INTERVAL_MS = TimeUnit.SECONDS.toMillis(5);
// Max GC time threshold
- public static final long MAX_GC_TIME_PERCENTAGE = 40L;
- // The time when IoTDB start running
- private static long startTime;
+ public static final long MAX_GC_TIME_PERCENTAGE = 30L;
+ // The time when JvmGcMonitorMetrics start running
+ private static long monitorStartTime;
private static final Logger logger =
LoggerFactory.getLogger(JvmGcMonitorMetrics.class);
private final ScheduledExecutorService scheduledGCInfoMonitor =
IoTDBThreadPoolFactory.newSingleThreadScheduledExecutor(
@@ -87,9 +87,11 @@ public class JvmGcMonitorMetrics implements IMetricSet {
curData,
GcData::getGcTimePercentage);
- startTime = System.currentTimeMillis();
+ monitorStartTime = System.currentTimeMillis();
+ // Set start time's accumulated GC Time
+ curData.setAccumulatedGcTime(getTotalGCTime());
// current collect time: startTime + start delay(50ms)
- gcDataBuf[startIdx].setValues(startTime +
TimeUnit.MILLISECONDS.toMillis(50), 0);
+ gcDataBuf[startIdx].setValues(monitorStartTime +
TimeUnit.MILLISECONDS.toMillis(50), 0);
scheduledGcMonitorFuture =
ScheduledExecutorUtil.safelyScheduleWithFixedDelay(
scheduledGCInfoMonitor,
@@ -112,21 +114,26 @@ public class JvmGcMonitorMetrics implements IMetricSet {
private void scheduledMonitoring() {
calculateGCTimePercentageWithinObservedInterval();
- if (alertHandler != null && curData.gcTimePercentage.get() >
MAX_GC_TIME_PERCENTAGE) {
+ if (alertHandler != null && curData.getGcTimePercentage() >
MAX_GC_TIME_PERCENTAGE) {
alertHandler.alert(curData.clone());
}
}
- private void calculateGCTimePercentageWithinObservedInterval() {
- long prevTotalGcTime = curData.getAccumulatedGcTime();
+ private long getTotalGCTime() {
long totalGcTime = 0;
for (GarbageCollectorMXBean gcBean :
ManagementFactory.getGarbageCollectorMXBeans()) {
totalGcTime += gcBean.getCollectionTime();
}
- long gcTimeWithinSleepInterval = totalGcTime - prevTotalGcTime;
+ return totalGcTime;
+ }
+
+ private void calculateGCTimePercentageWithinObservedInterval() {
+ long prevTotalGcTime = curData.getAccumulatedGcTime();
+ long totalGcTime = getTotalGCTime();
+ long gcTimeWithinSleepInterval = totalGcTime - prevTotalGcTime;
long curTime = System.currentTimeMillis();
- long gcMonitorRunTime = curTime - startTime;
+ long gcMonitorRunTime = curTime - monitorStartTime;
endIdx = (endIdx + 1) % bufSize;
gcDataBuf[endIdx].setValues(curTime, gcTimeWithinSleepInterval);
@@ -182,7 +189,7 @@ public class JvmGcMonitorMetrics implements IMetricSet {
* @return current observation window time, millisecond.
*/
public long getCurrentObsWindowTs() {
- return Math.min(timestamp.get() - startTime, timestamp.get() -
startObsWindowTs.get());
+ return Math.min(timestamp.get() - monitorStartTime, timestamp.get() -
startObsWindowTs.get());
}
/**
@@ -200,7 +207,7 @@ public class JvmGcMonitorMetrics implements IMetricSet {
* @return the actual start timestamp of the obs window.
*/
public long getStartObsWindowTs() {
- return Math.max(startObsWindowTs.get(), startTime);
+ return Math.max(startObsWindowTs.get(), monitorStartTime);
}
/**
@@ -231,6 +238,10 @@ public class JvmGcMonitorMetrics implements IMetricSet {
return gcTimePercentage.get();
}
+ private void setAccumulatedGcTime(long accumulatedGcTime) {
+ this.accumulatedGcTime.set(accumulatedGcTime);
+ }
+
private synchronized void update(
long inTimestamp,
long inStartObsWindowTs,