You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by yu...@apache.org on 2022/01/25 07:40:46 UTC
[iotdb] branch kyy-2022 updated: monitor
This is an automated email from the ASF dual-hosted git repository.
yuyuankang pushed a commit to branch kyy-2022
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/kyy-2022 by this push:
new ccf30ab monitor
ccf30ab is described below
commit ccf30ab70175ac1aef2ec0fe38a238d5627c679a
Author: Ring-k <yu...@hotmail.com>
AuthorDate: Tue Jan 25 15:40:05 2022 +0800
monitor
---
.../main/java/org/apache/iotdb/db/IOMonitor.java | 95 ++++++++++++++++++++++
.../org/apache/iotdb/db/utils/FileLoaderUtils.java | 8 ++
2 files changed, 103 insertions(+)
diff --git a/server/src/main/java/org/apache/iotdb/db/IOMonitor.java b/server/src/main/java/org/apache/iotdb/db/IOMonitor.java
new file mode 100644
index 0000000..ebd2fa8
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/IOMonitor.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/** @author Yuyuan Kang */
+public class IOMonitor {
+
+ public static long metaIOTime;
+ public static long dataIOTime;
+ public static long totalTime;
+ public static String sql;
+
+ public static List<Long> metaIOTimes = new ArrayList<>();
+ public static List<Long> dataIOTimes = new ArrayList<>();
+ public static List<String> sqls = new ArrayList<>();
+ public static List<Long> totalTimes = new ArrayList<>();
+
+ public static void incMeta(long v) {
+ metaIOTime += v;
+ }
+
+ private static void resetMeta() {
+ metaIOTimes.add(metaIOTime);
+ metaIOTime = 0;
+ }
+
+ public static void incDataIOTime(long v) {
+ dataIOTime += v;
+ }
+
+ private static void resetDataIOTime() {
+ dataIOTimes.add(dataIOTime);
+ dataIOTime = 0;
+ }
+
+ public static void setSQL(String v) {
+ sql = v;
+ }
+
+ public static void reset() {
+ resetMeta();
+ resetDataIOTime();
+ sqls.add(sql);
+ sql = null;
+ }
+
+ private static double getAvg(List<Long> vals) {
+ long sum = 0;
+ for (long v : vals) {
+ sum += v;
+ }
+ return (double) sum / vals.size();
+ }
+
+ public static void clear() {
+ metaIOTime = 0L;
+ dataIOTime = 0L;
+ totalTime = 0L;
+ sql = null;
+
+ metaIOTimes.clear();
+ dataIOTimes.clear();
+ sqls.clear();
+ totalTimes.clear();
+ }
+
+ @Override
+ public String toString() {
+ return "meta IO: "
+ + getAvg(metaIOTimes)
+ + ", data IO: "
+ + getAvg(dataIOTimes)
+ + ", total time: "
+ + getAvg(totalTimes);
+ }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/FileLoaderUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/FileLoaderUtils.java
index 7bbe051..4ad7580 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/FileLoaderUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/FileLoaderUtils.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.utils;
+import org.apache.iotdb.db.IOMonitor;
import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
import org.apache.iotdb.db.engine.modification.Modification;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
@@ -85,6 +86,7 @@ public class FileLoaderUtils {
}
/**
+ * @author Yuyuan Kang
* @param resource TsFile
* @param seriesPath Timeseries path
* @param allSensors measurements queried at the same time of this device
@@ -97,6 +99,7 @@ public class FileLoaderUtils {
Filter filter,
Set<String> allSensors)
throws IOException {
+ long start = System.currentTimeMillis();
TimeseriesMetadata timeSeriesMetadata;
if (resource.isClosed()) {
if (!resource.getTsFile().exists()) {
@@ -138,6 +141,8 @@ public class FileLoaderUtils {
return null;
}
}
+ long duration = System.currentTimeMillis() - start;
+ IOMonitor.incMeta(duration);
return timeSeriesMetadata;
}
@@ -159,6 +164,7 @@ public class FileLoaderUtils {
*/
public static List<IPageReader> loadPageReaderList(ChunkMetadata chunkMetaData, Filter timeFilter)
throws IOException {
+ long start = System.currentTimeMillis();
if (chunkMetaData == null) {
throw new IOException("Can't init null chunkMeta");
}
@@ -174,6 +180,8 @@ public class FileLoaderUtils {
chunkReader = new ChunkReader(chunk, timeFilter);
chunkReader.hasNextSatisfiedPage();
}
+ long duration = System.currentTimeMillis() - start;
+ IOMonitor.incDataIOTime(duration);
return chunkReader.loadPageReaderList();
} catch (IOException e) {
logger.error(